bind-to

1.0.1 • Public • Published

bind-to Build Status

Bind all methods in an object to a specified context and arguments

Install

$ npm install --save bind-to

Usage

var bind = require('bind-to')
var object = {
  foo: function () {
    return this.bar
  }
}
var context = {
  bar: 'baz'
}
bind(object, context)
object.foo() // => 'baz'

API

bind(object, context, args...) -> object

Returns the original object for convenience.

object

Required
Type: object

The object to bind.

context

Required
Type: any

The this value to bind to.

args...

Variadic arguments to apply to the methods.

License

MIT © Ben Drucker

Package Sidebar

Install

npm i bind-to

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • bendrucker