1 var arrayEach = require('./_arrayEach'),
2 baseFlatten = require('./_baseFlatten'),
3 bind = require('./bind'),
4 rest = require('./rest');
7 * Binds methods of an object to the object itself, overwriting the existing
10 * **Note:** This method doesn't set the "length" property of bound functions.
15 * @param {Object} object The object to bind and assign the bound methods to.
16 * @param {...(string|string[])} methodNames The object method names to bind,
17 * specified individually or in arrays.
18 * @returns {Object} Returns `object`.
23 * 'onClick': function() {
24 * console.log('clicked ' + this.label);
28 * _.bindAll(view, 'onClick');
29 * jQuery(element).on('click', view.onClick);
30 * // => logs 'clicked docs' when clicked
32 var bindAll = rest(function(object, methodNames) {
33 arrayEach(baseFlatten(methodNames), function(key) {
34 object[key] = bind(object[key], object);
39 module.exports = bindAll;