yaab

1.0.3 • Public • Published

Yaab (Yet another auto binder)

CircleCI codecov npm version

Forces class methods to be bound to instances. There are plenty of libraries to do this already, but this one is my one. Also I wrote tests.

Preconfigured for React, i.e. ignores render() and component...() methods.

Installation

Via npm:

$ npm install --save yaab

Usage

import bindMethods from 'yaab';

class TestClass {
	constructor() {
		this.property = 'value';
		bindMethods(this);
	}

	method() {
		return this.property;
	}
}

const instance = new TestClass();
const { method } = instance;

console.log(method()); // => 'value'

API

bindMethods(obj, [ignoredMethods])

Binds all methods on the object to itself.

obj

Object with methods to be bound. Typically a "this" at the end of a constructor.

ignoredMethods

Array of method names to ignore.

Readme

Keywords

none

Package Sidebar

Install

npm i yaab

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

13 kB

Total Files

12

Last publish

Collaborators

  • dan1elhughes