source: frontend/node_modules/underscore/cjs/underscore-array-methods.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 984 bytes
Line 
1var underscore = require('./underscore.js');
2var each = require('./each.js');
3var _setup = require('./_setup.js');
4var _chainResult = require('./_chainResult.js');
5
6// Add all mutator `Array` functions to the wrapper.
7each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
8 var method = _setup.ArrayProto[name];
9 underscore.prototype[name] = function() {
10 var obj = this._wrapped;
11 if (obj != null) {
12 method.apply(obj, arguments);
13 if ((name === 'shift' || name === 'splice') && obj.length === 0) {
14 delete obj[0];
15 }
16 }
17 return _chainResult(this, obj);
18 };
19});
20
21// Add all accessor `Array` functions to the wrapper.
22each(['concat', 'join', 'slice'], function(name) {
23 var method = _setup.ArrayProto[name];
24 underscore.prototype[name] = function() {
25 var obj = this._wrapped;
26 if (obj != null) obj = method.apply(obj, arguments);
27 return _chainResult(this, obj);
28 };
29});
30
31module.exports = underscore;
Note: See TracBrowser for help on using the repository browser.