proxy-bind
tl;dr
from
const fn = foobarfn;
to
const fn = ;
Install
npm install proxy-bind
Import
import { bind, bond } from 'proxy-bind';
.
import { bind, bond } from 'https://deno.land/x/proxy_bind/mod.ts';
.
const { bind, bond } = require('proxy-bind');
or
.
the
bond
is only an alias to avoid naming conflict, just in case.
Example
"point-free" ish
; const push join = ; ; console; // 1-2-3-4
; const resolve = ; console; // 42console; // foobar
bind this
; const me = name: 'foo' { return `Hi , this is .`; } ; const greet = ; console; // Hi bar, this is foo.
mirror
helper
; const list push = ; ; console; // [1, 2, 3, 4]
Methodology
It uses ES6 Proxy
to bridge function calls via Function.prototype.bind
.
Caveat
- Doesn't work on primitive types:
- don't
bind(5)
- do
bind(new Number(5))
- don't
License
the MIT