Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

abind

1.0.3 • Public • Published

abind

Build Status Code Climate Code Coverage npm Version JS Standard

Aubo bind instance methods of classes.

Installation

$ npm install abind --save

Usage

'use strict'
 
const abind = require('abind')
 
class Talker {
  constructor (name) {
    const s = this
    s.name = name
    abind(s)
  }
 
  sayHi () {
    const s = this
    return `Hi, i'm ${s.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.

Links

Keywords

install

npm i abind

Downloadsweekly downloads

1,945

version

1.0.3

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability