mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
Move _.bindAll to the utility category.
This commit is contained in:
66
lodash.js
66
lodash.js
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user