Skip to content

Latest commit

 

History

History
44 lines (30 loc) · 651 Bytes

README.md

File metadata and controls

44 lines (30 loc) · 651 Bytes

itsjoekent-bind

Automatically bind all functions of a class to itself.

Usage

const bind = require('itsjoekent-bind');

class Example {
  constructor() {
    this.ref = 'ok';

    bind.all(this, Example);
  }

  howdy(cb) {
    return setTimeout(() => cb(this.ref), 0);
  }
}

new Example().howdy(console.log); // 'ok'

Installation

$ npm install itsjoekent-bind

Tests

$ npm install
$ npm test

Apart of itsjoekent/packages

Very opinionated ™️ suite of NPM packages I use to quickly build cool shit. https://github.com/itsjoekent/packages

License

MIT