npm.io
1.0.5 • Published 7 years ago

abind

Licence
MIT
Version
1.0.5
Deps
0
Size
25 kB
Vulns
0
Weekly
0
Stars
1

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
Name Type Description
instance Object Instance to bind
options Object Optional settings
options.proto Object Prototype to bind
options.excludes string[] Names to exclude

License

This software is released under the MIT License.

Keywords