extend-context
like _.bind() and _.bindAll() but extends the context (this
) instead of replacing it
Usage:
var extendContext = require('extend-context');
var someFunction = function () { console.log(this.foo); }
someFunction = extendContext(someFunction, {
foo: true
'and you know, the stuff': 82385235,
I: 93529523,
want: 2352,
'to inject into': 'someFunction\'s `this` variable'
});
To do an object of functions all at once (like _.bindAll
)
var someObject = {
foo: function () { ... },
bar: function () { ... },
baz: function () { ... }
};
someObject = extendContext.all(someObject, {
sails: require('sails')
});
someObject.foo();
someObject.bar();
someObject.baz();
License
MIT
c. Mike McNeil 2014