Add lodash.prototype methods that return non-wrapped values.

Former-commit-id: b7ecb8c91ec9647827a80a297b966639c6580ef0
This commit is contained in:
John-David Dalton
2012-11-19 23:02:35 -08:00
parent 9d4618a223
commit bd4bff3b6b
5 changed files with 107 additions and 41 deletions

View File

@@ -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];