UNPKG

mout

Version:

Modular Utilities

19 lines (14 loc) 503 B
var functions = require('./functions'); var bind = require('../function/bind'); var forEach = require('../array/forEach'); /** * Binds methods of the object to be run in it's own context. */ function bindAll(obj, rest_methodNames){ var keys = arguments.length > 1? Array.prototype.slice.call(arguments, 1) : functions(obj); forEach(keys, function(key){ obj[key] = bind(obj[key], obj); }); } module.exports = bindAll;