Bump to v4.0.0.

This commit is contained in:
John-David Dalton
2015-08-24 10:34:23 -07:00
parent 4ef16c96e5
commit 0646bacd86
665 changed files with 24828 additions and 19696 deletions

39
bindAll.js Normal file
View File

@@ -0,0 +1,39 @@
var arrayEach = require('./internal/arrayEach'),
baseFlatten = require('./internal/baseFlatten'),
bind = require('./bind'),
rest = require('./rest');
/**
* Binds methods of an object to the object itself, overwriting the existing
* method.
*
* **Note:** This method doesn't set the "length" property of bound functions.
*
* @static
* @memberOf _
* @category Util
* @param {Object} object The object to bind and assign the bound methods to.
* @param {...(string|string[])} methodNames The object method names to bind,
* specified individually or in arrays.
* @returns {Object} Returns `object`.
* @example
*
* var view = {
* 'label': 'docs',
* 'onClick': function() {
* console.log('clicked ' + this.label);
* }
* };
*
* _.bindAll(view, 'onClick');
* jQuery(element).on('click', view.onClick);
* // => logs 'clicked docs' when clicked
*/
var bindAll = rest(function(object, methodNames) {
arrayEach(baseFlatten(methodNames), function(key) {
object[key] = bind(object[key], object);
});
return object;
});
module.exports = bindAll;