mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 08:57:49 +00:00
Rename _.lateBind to _.bindKey. [closes #114]
Former-commit-id: 971e56cb86b5298ba2a9f92365f0463665d27230
This commit is contained in:
78
lodash.js
78
lodash.js
@@ -2429,7 +2429,7 @@
|
||||
* else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.some([null, 0, 'yes', false]);
|
||||
* _.some([null, 0, 'yes', false], Boolean);
|
||||
* // => true
|
||||
*/
|
||||
function some(collection, callback, thisArg) {
|
||||
@@ -3244,6 +3244,43 @@
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function that, when called, invokes `object[methodName]` and
|
||||
* prepends any additional `bindKey` arguments to those passed to the bound
|
||||
* function. This method differs from `_.bind` by allowing bound functions to
|
||||
* reference methods that will be redefined or don't yet exist.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Functions
|
||||
* @param {Object} object The object the method belongs to.
|
||||
* @param {String} methodName The method name.
|
||||
* @param {Mixed} [arg1, arg2, ...] Arguments to be partially applied.
|
||||
* @returns {Function} Returns the new bound function.
|
||||
* @example
|
||||
*
|
||||
* var object = {
|
||||
* 'name': 'moe',
|
||||
* 'greet': function(greeting) {
|
||||
* return greeting + ' ' + this.name;
|
||||
* }
|
||||
* };
|
||||
*
|
||||
* var func = _.bindKey(object, 'greet', 'hi');
|
||||
* func();
|
||||
* // => 'hi moe'
|
||||
*
|
||||
* object.greet = function(greeting) {
|
||||
* return greeting + ', ' + this.name + '!';
|
||||
* };
|
||||
*
|
||||
* func();
|
||||
* // => 'hi, moe!'
|
||||
*/
|
||||
function bindKey(object, methodName) {
|
||||
return createBound(methodName, object, slice.call(arguments, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function that is the composition of the passed functions,
|
||||
* where each function consumes the return value of the function that follows.
|
||||
@@ -3365,43 +3402,6 @@
|
||||
return setTimeout(function() { func.apply(undefined, args); }, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function that, when called, invokes `object[methodName]` and
|
||||
* prepends any additional `lateBind` arguments to those passed to the bound
|
||||
* function. This method differs from `_.bind` by allowing bound functions to
|
||||
* reference methods that will be redefined or don't yet exist.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Functions
|
||||
* @param {Object} object The object the method belongs to.
|
||||
* @param {String} methodName The method name.
|
||||
* @param {Mixed} [arg1, arg2, ...] Arguments to be partially applied.
|
||||
* @returns {Function} Returns the new bound function.
|
||||
* @example
|
||||
*
|
||||
* var object = {
|
||||
* 'name': 'moe',
|
||||
* 'greet': function(greeting) {
|
||||
* return greeting + ' ' + this.name;
|
||||
* }
|
||||
* };
|
||||
*
|
||||
* var func = _.lateBind(object, 'greet', 'hi');
|
||||
* func();
|
||||
* // => 'hi moe'
|
||||
*
|
||||
* object.greet = function(greeting) {
|
||||
* return greeting + ', ' + this.name + '!';
|
||||
* };
|
||||
*
|
||||
* func();
|
||||
* // => 'hi, moe!'
|
||||
*/
|
||||
function lateBind(object, methodName) {
|
||||
return createBound(methodName, object, slice.call(arguments, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function that memoizes the result of `func`. If `resolver` is
|
||||
* passed, it will be used to determine the cache key for storing the result
|
||||
@@ -4083,6 +4083,7 @@
|
||||
lodash.after = after;
|
||||
lodash.bind = bind;
|
||||
lodash.bindAll = bindAll;
|
||||
lodash.bindKey = bindKey;
|
||||
lodash.chain = chain;
|
||||
lodash.clone = clone;
|
||||
lodash.compact = compact;
|
||||
@@ -4132,7 +4133,6 @@
|
||||
lodash.keys = keys;
|
||||
lodash.last = last;
|
||||
lodash.lastIndexOf = lastIndexOf;
|
||||
lodash.lateBind = lateBind;
|
||||
lodash.map = map;
|
||||
lodash.max = max;
|
||||
lodash.memoize = memoize;
|
||||
|
||||
Reference in New Issue
Block a user