context-binder

Automatically bind 'this' to every class method created outside of constructor

Usage no npm install needed!

<script type="module">
  import contextBinder from 'https://cdn.skypack.dev/context-binder';
</script>

README

Build Status codecov


Automatic Context Binding

AboutInstallUsage

About

This is a small package that automatically binds 'this' context to every method outside of your class constructor.

Install

npm i --save context-binder

Usage

const contextBind = require('context-binder');

class Test {
  constructor() {
    contextBind(this);
  }

  foo() {
    // do something
  }

  bar() {
    // do something
  }
};