abind
Aubo bind instance methods of classes.
Last updated 3 years ago by okunishinishi .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install abind 
SYNC missed versions from official npm registry.

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.

Links

Current Tags

  • 1.0.5                                ...           latest (22 days ago)

6 Versions

  • 1.0.5                                ...           22 days ago
  • 1.0.4                                ...           a month ago
  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           3 years ago

Copyright 2014 - 2016 © taobao.org |