arrow-bind

Change context in arrow function

Usage no npm install needed!

<script type="module">
  import arrowBind from 'https://cdn.skypack.dev/arrow-bind';
</script>

README

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" }