This commit is contained in:
2021-10-11 22:33:07 +03:00
parent 076141ad80
commit 7adfe55ea5
2 changed files with 99 additions and 12 deletions
+37
View File
@@ -177,6 +177,43 @@ kit.ready(['collection'], function () {
assertSame(x.length, 2, 'length after shift');
assertSame(x.last(), 10, 'last after shift');
xOb = {a: 'a10', b: 'b11'};
x = new kit.Collection(xOb);
x2 = x.map(function (value, key) {
return value + '!';
});
assertSame(x2.get('a'), 'a10!', 'map object');
xOb = [10, 20, 30];
x = new kit.Collection(xOb);
x2 = x.map(function (value, key) {
return value * 2;
});
assertSame(x2.last(), 60, 'map array');
xOb = {a: 'a10', b: 'b11', 10: 101};
x = new kit.Collection(xOb);
x.set(11, 111);
x2 = x.except([10]);
assertSame(x2.last(), 111, 'except last+');
assertSame(x2.length, 3, 'except length');
x3 = x2.except('11');
assertSame(x3.last(), 'b11', 'except last+');
assertSame(x3.length, 2, 'except length');
xOb = {a: 'a10', b: 'b11', 10: 101};
x = new kit.Collection(xOb);
x.set(11, 111);
x2 = x.only(['a', 'b', '11']);
assertSame(x2.last(), 111, 'only last+');
assertSame(x2.length, 3, 'only length');
x3 = x2.only('11');
assertSame(x3.last(), 111, 'only last+');
assertSame(x3.length, 1, 'only length');
x.
});