Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
bind all the functions on an object
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitignore
.jshintrc
Readme.md
component.json
index.js
package.json

Readme.md

objbind

objbind takes an object and returns an object that inherits from it with all the enumerable functions bound to the first object. confused? here's an example:

var winston = require('winston')
  , objbind = require('objbind')
  , myWinston = objbind(winston, 'nathan says')
myWinston.info('hi')
console.log(myWinston.loggers === winston.loggers)

output:

info: nathan says hi
true

objbind(obj, args...)

  • newObj = Object.create(obj)
  • for each enumerable function property of obj, assign fn.bind(obj, args...) to the same key on newObj
  • return newObj
Something went wrong with that request. Please try again.