npm.io
1.0.11 • Published 7 years ago

arrow-bind

Licence
ISC
Version
1.0.11
Deps
0
Size
2 kB
Vulns
0
Weekly
0

Easy bind a context to an arrow function:)

const { bindArrow } = require('arrow-bind');
// OR
import { bindArrow } from 'arrow-bind';

const arrowFunc = () => console.log(this);
arrowFunc() // window

const newContext = { event: "changed context" };

const arrowChCx = bindArrow(arrowFunc, newContext);
arrowChCx() // { event: "changed context" }

Keywords