mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 19:37:49 +00:00
Bump to v4.0.0.
This commit is contained in:
@@ -1,33 +1,28 @@
|
||||
/**
|
||||
* lodash 3.1.0 (Custom Build) <https://lodash.com/>
|
||||
* Build: `lodash modern modularize exports="npm" -o ./`
|
||||
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
|
||||
* Based on Underscore.js 1.8.2 <http://underscorejs.org/LICENSE>
|
||||
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
* lodash 4.0.0 (Custom Build) <https://lodash.com/>
|
||||
* Build: `lodash modularize exports="npm" -o ./`
|
||||
* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
|
||||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
||||
* Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
* Available under MIT license <https://lodash.com/license>
|
||||
*/
|
||||
var baseFlatten = require('lodash._baseflatten'),
|
||||
createWrapper = require('lodash._createwrapper'),
|
||||
functions = require('lodash.functions'),
|
||||
restParam = require('lodash.restparam');
|
||||
|
||||
/** Used to compose bitmasks for wrapper metadata. */
|
||||
var BIND_FLAG = 1;
|
||||
var arrayEach = require('lodash._arrayeach'),
|
||||
baseFlatten = require('lodash._baseflatten'),
|
||||
bind = require('lodash.bind'),
|
||||
rest = require('lodash.rest');
|
||||
|
||||
/**
|
||||
* Binds methods of an object to the object itself, overwriting the existing
|
||||
* method. Method names may be specified as individual arguments or as arrays
|
||||
* of method names. If no method names are provided all enumerable function
|
||||
* properties, own and inherited, of `object` are bound.
|
||||
* method.
|
||||
*
|
||||
* **Note:** This method does not set the "length" property of bound functions.
|
||||
* **Note:** This method doesn't set the "length" property of bound functions.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Function
|
||||
* @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 as individual method names or arrays of method names.
|
||||
* @param {...(string|string[])} methodNames The object method names to bind,
|
||||
* specified individually or in arrays.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @example
|
||||
*
|
||||
@@ -38,20 +33,14 @@ var BIND_FLAG = 1;
|
||||
* }
|
||||
* };
|
||||
*
|
||||
* _.bindAll(view);
|
||||
* jQuery('#docs').on('click', view.onClick);
|
||||
* // => logs 'clicked docs' when the element is clicked
|
||||
* _.bindAll(view, 'onClick');
|
||||
* jQuery(element).on('click', view.onClick);
|
||||
* // => logs 'clicked docs' when clicked
|
||||
*/
|
||||
var bindAll = restParam(function(object, methodNames) {
|
||||
methodNames = methodNames.length ? baseFlatten(methodNames) : functions(object);
|
||||
|
||||
var index = -1,
|
||||
length = methodNames.length;
|
||||
|
||||
while (++index < length) {
|
||||
var key = methodNames[index];
|
||||
object[key] = createWrapper(object[key], BIND_FLAG, object);
|
||||
}
|
||||
var bindAll = rest(function(object, methodNames) {
|
||||
arrayEach(baseFlatten(methodNames), function(key) {
|
||||
object[key] = bind(object[key], object);
|
||||
});
|
||||
return object;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user