1.0.3 • Published 5 years ago

yaab v1.0.3

Weekly downloads
17
License
MIT
Repository
github
Last release
5 years ago

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.

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago