Initial commit

This commit is contained in:
2021-03-14 11:09:02 +01:00
commit 21e364ee38
1046 changed files with 126647 additions and 0 deletions

View File

@ -0,0 +1,31 @@
var _setup = require('./_setup.js');
var underscore = require('./underscore.js');
var _chainResult = require('./_chainResult.js');
var each = require('./each.js');
// Add all mutator `Array` functions to the wrapper.
each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
var method = _setup.ArrayProto[name];
underscore.prototype[name] = function() {
var obj = this._wrapped;
if (obj != null) {
method.apply(obj, arguments);
if ((name === 'shift' || name === 'splice') && obj.length === 0) {
delete obj[0];
}
}
return _chainResult(this, obj);
};
});
// Add all accessor `Array` functions to the wrapper.
each(['concat', 'join', 'slice'], function(name) {
var method = _setup.ArrayProto[name];
underscore.prototype[name] = function() {
var obj = this._wrapped;
if (obj != null) obj = method.apply(obj, arguments);
return _chainResult(this, obj);
};
});
module.exports = underscore;