auto-bind-extend

extendable class for binding functions

Usage no npm install needed!

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

README

auto-bind-extend

codecov.io Build Status

a simple class that can be used to put your function context troubles to rest. Based on auto-bind

example


const BaseAutoBind = require('auto-bind-extend');

class Cool extends BaseAutoBind {
    constructor() {
        super();
        this.name = 'Cool';
    }

    say() {
        return this.name;
    }
}

let cool = new Cool();

// No matter where this function may travel, it'll stay cool
let coolSayFn = cool.say;
console.log(coolSayFn()); // Cool!

dev

npm test
npm run coverage