Move _.bindAll to the utility category.

This commit is contained in:
John-David Dalton
2016-01-01 16:17:55 -06:00
parent f830612f17
commit 3e155bdbb9

View File

@@ -8240,39 +8240,6 @@
return createWrapper(func, bitmask, thisArg, partials, holders);
});
/**
* 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 Function
* @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;
});
/**
* Creates a function that invokes the method at `object[key]` and prepends
* any additional `_.bindKey` arguments to those provided to the bound function.
@@ -12820,6 +12787,39 @@
}
});
/**
* 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 Utility
* @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;
});
/**
* Creates a function that invokes the predicate properties of `source` with
* the corresponding property values of a given object, returning `true` if