Skip to content

Instantly share code, notes, and snippets.

@ayamflow
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayamflow/387d19a0ae658f0de8b6 to your computer and use it in GitHub Desktop.
Save ayamflow/387d19a0ae658f0de8b6 to your computer and use it in GitHub Desktop.
bindAll standalone from underscore
module.exports = function(obj) {
var funcs = Array.prototype.slice.call(arguments, 1);
if (funcs.length === 0) throw new Error('bindAll must be passed function names');
funcs.forEach(function(f) {
obj[f] = obj[f].bind(obj);
});
return obj;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment