Add some array methods for List
This commit is contained in:
parent
3d64056c39
commit
4d75cb74d7
11
lib/list.js
11
lib/list.js
|
@ -115,6 +115,13 @@ if (_) {
|
|||
});
|
||||
}
|
||||
|
||||
['slice', 'forEach'].forEach(function (method) {
|
||||
var slice = [].slice;
|
||||
List.prototype[method] = function () {
|
||||
return Array.prototype[method].apply(this.items, slice.call(arguments));
|
||||
};
|
||||
});;
|
||||
|
||||
List.prototype.toObject = function() {
|
||||
return this.items;
|
||||
};
|
||||
|
@ -154,10 +161,6 @@ List.prototype.remove = function(obj) {
|
|||
}
|
||||
};
|
||||
|
||||
List.prototype.forEach = function(cb) {
|
||||
this.items.forEach(cb);
|
||||
};
|
||||
|
||||
List.prototype.sort = function(cb) {
|
||||
return this.items.sort(cb);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue