Add some array methods for List

This commit is contained in:
Anatoliy Chakkaev 2013-02-18 16:18:09 +08:00
parent 3d64056c39
commit 4d75cb74d7
1 changed files with 7 additions and 4 deletions

View File

@ -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);
};