mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
Bump to v3.6.0.
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import baseBindAll from '../internal/baseBindAll';
|
||||
import baseFlatten from '../internal/baseFlatten';
|
||||
import createWrapper from '../internal/createWrapper';
|
||||
import functions from '../object/functions';
|
||||
import restParam from './restParam';
|
||||
|
||||
/** Used to compose bitmasks for wrapper metadata. */
|
||||
var BIND_FLAG = 1;
|
||||
|
||||
/**
|
||||
* Binds methods of an object to the object itself, overwriting the existing
|
||||
@@ -30,12 +34,17 @@ import functions from '../object/functions';
|
||||
* jQuery('#docs').on('click', view.onClick);
|
||||
* // => logs 'clicked docs' when the element is clicked
|
||||
*/
|
||||
function bindAll(object) {
|
||||
return baseBindAll(object,
|
||||
arguments.length > 1
|
||||
? baseFlatten(arguments, false, false, 1)
|
||||
: functions(object)
|
||||
);
|
||||
}
|
||||
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);
|
||||
}
|
||||
return object;
|
||||
});
|
||||
|
||||
export default bindAll;
|
||||
|
||||
Reference in New Issue
Block a user