source: frontend/node_modules/underscore/modules/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: 925 bytes
Line 
1import _ from './underscore.js';
2import each from './each.js';
3import { ArrayProto } from './_setup.js';
4import chainResult from './_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 = ArrayProto[name];
9 _.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 = ArrayProto[name];
24 _.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
31export default _;
Note: See TracBrowser for help on using the repository browser.