1.0.5 • Published 5 years ago

abind v1.0.5

Weekly downloads
5,295
License
MIT
Repository
github
Last release
5 years ago

abind

Build Status npm Version JS Standard

Auto bind instance methods of classes.

Installation

$ npm install abind --save

Usage

'use strict'

const abind = require('abind')

class Talker {
  constructor (name) {
    this.name = name
    abind(this)
  }

  sayHi () {
    return `Hi, i'm ${this.name}`
  }
}

let { sayHi } = new Talker('Tom')

console.log(sayHi()) // -> Hi, i'm Tom

Signature

abind(instance, options) -> Object

Params

NameTypeDescription
instanceObjectInstance to bind
optionsObjectOptional settings
options.protoObjectPrototype to bind
options.excludesstring[]Names to exclude

License

This software is released under the MIT License.

Links