mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
Add lodash.prototype methods that return non-wrapped values.
Former-commit-id: b7ecb8c91ec9647827a80a297b966639c6580ef0
This commit is contained in:
14
lodash.js
14
lodash.js
@@ -4225,6 +4225,20 @@
|
||||
lodash.prototype.value = wrapperValue;
|
||||
lodash.prototype.valueOf = wrapperValue;
|
||||
|
||||
// add all methods that return non-wrapped values
|
||||
forEach(filter(functions(lodash), function(methodName) {
|
||||
return /^(?:contains|every|find|first|has|is[A-Z].+|last|reduce.*|some)$/.test(methodName);
|
||||
}),
|
||||
function(methodName) {
|
||||
var func = lodash[methodName];
|
||||
|
||||
lodash.prototype[methodName] = function() {
|
||||
var args = [this.__wrapped__];
|
||||
push.apply(args, arguments);
|
||||
return func.apply(lodash, args);
|
||||
};
|
||||
});
|
||||
|
||||
// add all mutator Array functions to the wrapper.
|
||||
forEach(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
|
||||
var func = arrayRef[methodName];
|
||||
|
||||
Reference in New Issue
Block a user