data-structure-typed 1.54.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/benchmark/report.html +26 -2
- package/benchmark/report.json +292 -42
- package/dist/cjs/data-structures/base/iterable-element-base.d.ts +14 -40
- package/dist/cjs/data-structures/base/iterable-element-base.js +14 -11
- package/dist/cjs/data-structures/base/iterable-element-base.js.map +1 -1
- package/dist/cjs/data-structures/base/linear-base.d.ts +277 -0
- package/dist/cjs/data-structures/base/linear-base.js +553 -0
- package/dist/cjs/data-structures/base/linear-base.js.map +1 -0
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +12 -8
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +50 -37
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree.d.ts +64 -0
- package/dist/cjs/data-structures/binary-tree/avl-tree.js +64 -0
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +62 -0
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +67 -5
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.d.ts +3 -3
- package/dist/cjs/data-structures/binary-tree/bst.js +14 -14
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/red-black-tree.d.ts +1 -7
- package/dist/cjs/data-structures/binary-tree/red-black-tree.js +1 -7
- package/dist/cjs/data-structures/binary-tree/red-black-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +175 -14
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +210 -40
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
- package/dist/cjs/data-structures/graph/abstract-graph.js +2 -2
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/cjs/data-structures/heap/heap.d.ts +3 -11
- package/dist/cjs/data-structures/heap/heap.js +0 -10
- package/dist/cjs/data-structures/heap/heap.js.map +1 -1
- package/dist/cjs/data-structures/heap/max-heap.d.ts +2 -2
- package/dist/cjs/data-structures/heap/max-heap.js.map +1 -1
- package/dist/cjs/data-structures/heap/min-heap.d.ts +2 -2
- package/dist/cjs/data-structures/heap/min-heap.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +65 -94
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +131 -146
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/singly-linked-list.d.ts +79 -75
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js +217 -169
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.d.ts +2 -2
- package/dist/cjs/data-structures/priority-queue/max-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.d.ts +2 -2
- package/dist/cjs/data-structures/priority-queue/min-priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/priority-queue/priority-queue.d.ts +2 -2
- package/dist/cjs/data-structures/priority-queue/priority-queue.js.map +1 -1
- package/dist/cjs/data-structures/queue/deque.d.ts +130 -91
- package/dist/cjs/data-structures/queue/deque.js +269 -169
- package/dist/cjs/data-structures/queue/deque.js.map +1 -1
- package/dist/cjs/data-structures/queue/queue.d.ts +84 -40
- package/dist/cjs/data-structures/queue/queue.js +134 -50
- package/dist/cjs/data-structures/queue/queue.js.map +1 -1
- package/dist/cjs/data-structures/stack/stack.d.ts +3 -11
- package/dist/cjs/data-structures/stack/stack.js +0 -10
- package/dist/cjs/data-structures/stack/stack.js.map +1 -1
- package/dist/cjs/data-structures/trie/trie.d.ts +4 -3
- package/dist/cjs/data-structures/trie/trie.js +3 -0
- package/dist/cjs/data-structures/trie/trie.js.map +1 -1
- package/dist/cjs/types/data-structures/base/base.d.ts +9 -4
- package/dist/cjs/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -1
- package/dist/cjs/types/data-structures/binary-tree/tree-multi-map.d.ts +1 -1
- package/dist/cjs/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -2
- package/dist/cjs/types/data-structures/linked-list/singly-linked-list.d.ts +2 -2
- package/dist/cjs/types/data-structures/queue/deque.d.ts +2 -3
- package/dist/cjs/types/data-structures/queue/queue.d.ts +2 -2
- package/dist/esm/data-structures/base/iterable-element-base.d.ts +14 -40
- package/dist/esm/data-structures/base/iterable-element-base.js +14 -11
- package/dist/esm/data-structures/base/iterable-element-base.js.map +1 -1
- package/dist/esm/data-structures/base/linear-base.d.ts +277 -0
- package/dist/esm/data-structures/base/linear-base.js +549 -0
- package/dist/esm/data-structures/base/linear-base.js.map +1 -0
- package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.d.ts +12 -8
- package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js +50 -36
- package/dist/esm/data-structures/binary-tree/avl-tree-multi-map.js.map +1 -1
- package/dist/esm/data-structures/binary-tree/avl-tree.d.ts +64 -0
- package/dist/esm/data-structures/binary-tree/avl-tree.js +64 -0
- package/dist/esm/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/esm/data-structures/binary-tree/binary-tree.d.ts +62 -0
- package/dist/esm/data-structures/binary-tree/binary-tree.js +67 -5
- package/dist/esm/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/esm/data-structures/binary-tree/bst.d.ts +3 -3
- package/dist/esm/data-structures/binary-tree/bst.js +14 -12
- package/dist/esm/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/esm/data-structures/binary-tree/red-black-tree.d.ts +1 -7
- package/dist/esm/data-structures/binary-tree/red-black-tree.js +1 -7
- package/dist/esm/data-structures/binary-tree/red-black-tree.js.map +1 -1
- package/dist/esm/data-structures/binary-tree/tree-multi-map.d.ts +175 -14
- package/dist/esm/data-structures/binary-tree/tree-multi-map.js +210 -39
- package/dist/esm/data-structures/binary-tree/tree-multi-map.js.map +1 -1
- package/dist/esm/data-structures/graph/abstract-graph.js +2 -2
- package/dist/esm/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/esm/data-structures/heap/heap.d.ts +3 -11
- package/dist/esm/data-structures/heap/heap.js +0 -10
- package/dist/esm/data-structures/heap/heap.js.map +1 -1
- package/dist/esm/data-structures/heap/max-heap.d.ts +2 -2
- package/dist/esm/data-structures/heap/max-heap.js.map +1 -1
- package/dist/esm/data-structures/heap/min-heap.d.ts +2 -2
- package/dist/esm/data-structures/heap/min-heap.js.map +1 -1
- package/dist/esm/data-structures/linked-list/doubly-linked-list.d.ts +65 -94
- package/dist/esm/data-structures/linked-list/doubly-linked-list.js +132 -148
- package/dist/esm/data-structures/linked-list/doubly-linked-list.js.map +1 -1
- package/dist/esm/data-structures/linked-list/singly-linked-list.d.ts +79 -75
- package/dist/esm/data-structures/linked-list/singly-linked-list.js +217 -170
- package/dist/esm/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/esm/data-structures/priority-queue/max-priority-queue.d.ts +2 -2
- package/dist/esm/data-structures/priority-queue/max-priority-queue.js.map +1 -1
- package/dist/esm/data-structures/priority-queue/min-priority-queue.d.ts +2 -2
- package/dist/esm/data-structures/priority-queue/min-priority-queue.js.map +1 -1
- package/dist/esm/data-structures/priority-queue/priority-queue.d.ts +2 -2
- package/dist/esm/data-structures/priority-queue/priority-queue.js.map +1 -1
- package/dist/esm/data-structures/queue/deque.d.ts +130 -91
- package/dist/esm/data-structures/queue/deque.js +269 -169
- package/dist/esm/data-structures/queue/deque.js.map +1 -1
- package/dist/esm/data-structures/queue/queue.d.ts +84 -40
- package/dist/esm/data-structures/queue/queue.js +135 -51
- package/dist/esm/data-structures/queue/queue.js.map +1 -1
- package/dist/esm/data-structures/stack/stack.d.ts +3 -11
- package/dist/esm/data-structures/stack/stack.js +0 -10
- package/dist/esm/data-structures/stack/stack.js.map +1 -1
- package/dist/esm/data-structures/trie/trie.d.ts +4 -3
- package/dist/esm/data-structures/trie/trie.js +3 -0
- package/dist/esm/data-structures/trie/trie.js.map +1 -1
- package/dist/esm/types/data-structures/base/base.d.ts +9 -4
- package/dist/esm/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -1
- package/dist/esm/types/data-structures/binary-tree/tree-multi-map.d.ts +1 -1
- package/dist/esm/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -2
- package/dist/esm/types/data-structures/linked-list/singly-linked-list.d.ts +2 -2
- package/dist/esm/types/data-structures/queue/deque.d.ts +2 -3
- package/dist/esm/types/data-structures/queue/queue.d.ts +2 -2
- package/dist/umd/data-structure-typed.js +1246 -635
- package/dist/umd/data-structure-typed.min.js +3 -3
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/package.json +6 -6
- package/src/data-structures/base/iterable-element-base.ts +29 -20
- package/src/data-structures/base/linear-base.ts +649 -0
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +51 -36
- package/src/data-structures/binary-tree/avl-tree.ts +64 -0
- package/src/data-structures/binary-tree/binary-tree.ts +5 -5
- package/src/data-structures/binary-tree/bst.ts +9 -9
- package/src/data-structures/binary-tree/tree-multi-map.ts +214 -40
- package/src/data-structures/graph/abstract-graph.ts +2 -2
- package/src/data-structures/heap/heap.ts +3 -14
- package/src/data-structures/heap/max-heap.ts +2 -2
- package/src/data-structures/heap/min-heap.ts +2 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +144 -160
- package/src/data-structures/linked-list/singly-linked-list.ts +241 -185
- package/src/data-structures/priority-queue/max-priority-queue.ts +2 -5
- package/src/data-structures/priority-queue/min-priority-queue.ts +2 -5
- package/src/data-structures/priority-queue/priority-queue.ts +2 -2
- package/src/data-structures/queue/deque.ts +286 -183
- package/src/data-structures/queue/queue.ts +149 -63
- package/src/data-structures/stack/stack.ts +3 -18
- package/src/data-structures/trie/trie.ts +7 -3
- package/src/types/data-structures/base/base.ts +17 -8
- package/src/types/data-structures/binary-tree/avl-tree-multi-map.ts +1 -1
- package/src/types/data-structures/binary-tree/tree-multi-map.ts +1 -1
- package/src/types/data-structures/linked-list/doubly-linked-list.ts +2 -2
- package/src/types/data-structures/linked-list/singly-linked-list.ts +2 -2
- package/src/types/data-structures/queue/deque.ts +2 -3
- package/src/types/data-structures/queue/queue.ts +2 -2
- package/test/integration/all-in-one.test.ts +1 -1
- package/test/integration/avl-tree.test.ts +1 -1
- package/test/integration/bst.test.ts +2 -2
- package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +168 -0
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +15 -14
- package/test/unit/data-structures/binary-tree/red-black-tree.test.ts +1 -1
- package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +165 -7
- package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +135 -27
- package/test/unit/data-structures/linked-list/singly-linked-list.test.ts +111 -11
- package/test/unit/data-structures/queue/deque.test.ts +241 -60
- package/test/unit/data-structures/queue/queue.test.ts +118 -19
- package/test/unit/unrestricted-interconversion.test.ts +1 -1
|
@@ -37,6 +37,16 @@ describe('SinglyLinkedList Operation Test', () => {
|
|
|
37
37
|
list.push(2);
|
|
38
38
|
expect(list.toArray()).toEqual([1, 2]);
|
|
39
39
|
});
|
|
40
|
+
|
|
41
|
+
it('push with maxLen', () => {
|
|
42
|
+
const list = new SinglyLinkedList<number>([], { maxLen: 10 });
|
|
43
|
+
for (let i = 0; i < 1000; i++) {
|
|
44
|
+
list.push(i);
|
|
45
|
+
}
|
|
46
|
+
expect(list.maxLen).toBe(10);
|
|
47
|
+
expect(list.length).toBe(10);
|
|
48
|
+
expect(list.first).toBe(990);
|
|
49
|
+
});
|
|
40
50
|
});
|
|
41
51
|
|
|
42
52
|
describe('pop', () => {
|
|
@@ -187,7 +197,7 @@ describe('SinglyLinkedList Operation Test', () => {
|
|
|
187
197
|
list.push(3);
|
|
188
198
|
list.clear();
|
|
189
199
|
expect(list.toArray()).toEqual([]);
|
|
190
|
-
expect(list.
|
|
200
|
+
expect(list.length).toBe(0);
|
|
191
201
|
expect(list.isEmpty()).toBe(true);
|
|
192
202
|
});
|
|
193
203
|
});
|
|
@@ -277,10 +287,10 @@ describe('SinglyLinkedList Operation Test', () => {
|
|
|
277
287
|
|
|
278
288
|
describe('getLength', () => {
|
|
279
289
|
it('should return the correct length of the list', () => {
|
|
280
|
-
expect(list.
|
|
290
|
+
expect(list.length).toBe(0);
|
|
281
291
|
list.push(1);
|
|
282
292
|
list.push(2);
|
|
283
|
-
expect(list.
|
|
293
|
+
expect(list.length).toBe(2);
|
|
284
294
|
});
|
|
285
295
|
});
|
|
286
296
|
|
|
@@ -290,14 +300,14 @@ describe('SinglyLinkedList Operation Test', () => {
|
|
|
290
300
|
list.push(2);
|
|
291
301
|
list.push(3);
|
|
292
302
|
const removed = list.deleteAt(1);
|
|
293
|
-
expect(removed).toBe(
|
|
303
|
+
expect(removed).toBe(2);
|
|
294
304
|
expect(list.toArray()).toEqual([1, 3]);
|
|
295
305
|
});
|
|
296
306
|
|
|
297
307
|
it('should return undefined for an out-of-bounds index', () => {
|
|
298
308
|
list.push(1);
|
|
299
309
|
const removed = list.deleteAt(1);
|
|
300
|
-
expect(removed).toBe(
|
|
310
|
+
expect(removed).toBe(undefined);
|
|
301
311
|
});
|
|
302
312
|
|
|
303
313
|
it('should delete and return the first element', () => {
|
|
@@ -308,7 +318,7 @@ describe('SinglyLinkedList Operation Test', () => {
|
|
|
308
318
|
const removed = list.deleteAt(0);
|
|
309
319
|
expect(list.first).toBe(2);
|
|
310
320
|
expect(list.last).toBe(2);
|
|
311
|
-
expect(removed).toBe(
|
|
321
|
+
expect(removed).toBe(1);
|
|
312
322
|
expect(list.toArray()).toEqual([2]);
|
|
313
323
|
});
|
|
314
324
|
|
|
@@ -316,7 +326,7 @@ describe('SinglyLinkedList Operation Test', () => {
|
|
|
316
326
|
list.push(1);
|
|
317
327
|
list.push(2);
|
|
318
328
|
const removed = list.deleteAt(1);
|
|
319
|
-
expect(removed).toBe(
|
|
329
|
+
expect(removed).toBe(2);
|
|
320
330
|
expect(list.toArray()).toEqual([1]);
|
|
321
331
|
});
|
|
322
332
|
});
|
|
@@ -448,6 +458,95 @@ describe('SinglyLinkedList Operation Test', () => {
|
|
|
448
458
|
});
|
|
449
459
|
});
|
|
450
460
|
|
|
461
|
+
describe('SinglyLinkedList Additional Methods', () => {
|
|
462
|
+
// Slice method implementation and test
|
|
463
|
+
test('slice should return a new list with specified range', () => {
|
|
464
|
+
const list = new SinglyLinkedList([1, 2, 3, 4, 5]);
|
|
465
|
+
const slicedList = list.slice(1, 4);
|
|
466
|
+
|
|
467
|
+
expect(slicedList.toArray()).toEqual([2, 3, 4]);
|
|
468
|
+
expect(list.length).toBe(5); // Original list unchanged
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
// Splice method implementation
|
|
472
|
+
test('splice should modify list and return removed elements', () => {
|
|
473
|
+
const list = new SinglyLinkedList([1, 2, 3, 4, 5]);
|
|
474
|
+
const removedList = list.splice(2, 2, 6, 7);
|
|
475
|
+
|
|
476
|
+
expect(list.toArray()).toEqual([1, 2, 6, 7, 5]);
|
|
477
|
+
expect(removedList.toArray()).toEqual([3, 4]);
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
// Concat method test
|
|
481
|
+
test('concat should combine multiple lists', () => {
|
|
482
|
+
const list1 = new SinglyLinkedList([1, 2]);
|
|
483
|
+
const list2 = new SinglyLinkedList([3, 4]);
|
|
484
|
+
const list3 = new SinglyLinkedList([5, 6]);
|
|
485
|
+
|
|
486
|
+
const concatenatedList = list1.concat(list2, list3);
|
|
487
|
+
expect(concatenatedList.toArray()).toEqual([1, 2, 3, 4, 5, 6]);
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
// Sort method test
|
|
491
|
+
test('sort should order elements in ascending order', () => {
|
|
492
|
+
const list = new SinglyLinkedList([5, 2, 8, 1, 9]);
|
|
493
|
+
list.sort((a, b) => a - b);
|
|
494
|
+
|
|
495
|
+
expect(list.toArray()).toEqual([1, 2, 5, 8, 9]);
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
// Reverse method test
|
|
499
|
+
test('reverse should invert the list order', () => {
|
|
500
|
+
const list = new SinglyLinkedList([1, 2, 3, 4, 5]);
|
|
501
|
+
list.reverse();
|
|
502
|
+
|
|
503
|
+
expect(list.toArray()).toEqual([5, 4, 3, 2, 1]);
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
// Join method test
|
|
507
|
+
test('join should convert list to string with separator', () => {
|
|
508
|
+
const list = new SinglyLinkedList(['a', 'b', 'c']);
|
|
509
|
+
|
|
510
|
+
expect(list.join('-')).toBe('a-b-c');
|
|
511
|
+
expect(list.join()).toBe('a,b,c');
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
// IndexOf method test
|
|
515
|
+
test('indexOf should return first occurrence index', () => {
|
|
516
|
+
const list = new SinglyLinkedList([1, 2, 3, 2, 1]);
|
|
517
|
+
|
|
518
|
+
expect(list.indexOf(2)).toBe(1);
|
|
519
|
+
expect(list.indexOf(4)).toBe(-1);
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
// LastIndexOf method test
|
|
523
|
+
test('lastIndexOf should return last occurrence index', () => {
|
|
524
|
+
const list = new SinglyLinkedList([1, 2, 3, 2, 1]);
|
|
525
|
+
|
|
526
|
+
expect(list.lastIndexOf(2)).toBe(3);
|
|
527
|
+
expect(list.lastIndexOf(4)).toBe(-1);
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
// findIndex method test
|
|
531
|
+
test('findIndex should return first occurrence index', () => {
|
|
532
|
+
const list = new SinglyLinkedList([1, 2, 3, 2, 1]);
|
|
533
|
+
expect(list.findIndex(item => item === 2)).toBe(1);
|
|
534
|
+
expect(list.findIndex(item => item === 4)).toBe(-1);
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
// fill method test
|
|
538
|
+
test('fill should return fill all the list', () => {
|
|
539
|
+
let list = new SinglyLinkedList([1, 2, 3, 2, 1]);
|
|
540
|
+
expect([...list.fill(9)]).toEqual([9, 9, 9, 9, 9]);
|
|
541
|
+
list = new SinglyLinkedList([1, 2, 3, 2, 1]);
|
|
542
|
+
expect([...list.fill(9, 2, 3)]).toEqual([1, 2, 9, 2, 1]);
|
|
543
|
+
list = new SinglyLinkedList([1, 2, 3, 2, 1]);
|
|
544
|
+
expect([...list.fill(9, -3, -2)]).toEqual([1, 2, 9, 2, 1]);
|
|
545
|
+
list = new SinglyLinkedList([1, 2, 3, 2, 1]);
|
|
546
|
+
expect([...list.fill(9, -2, -3)]).toEqual([1, 2, 3, 2, 1]);
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
|
|
451
550
|
describe('SinglyLinkedList', () => {
|
|
452
551
|
let list: SinglyLinkedList<number>;
|
|
453
552
|
|
|
@@ -458,7 +557,7 @@ describe('SinglyLinkedList', () => {
|
|
|
458
557
|
it('should initialize an empty list', () => {
|
|
459
558
|
expect(list.head).toBe(undefined);
|
|
460
559
|
expect(list.tail).toBe(undefined);
|
|
461
|
-
expect(list.
|
|
560
|
+
expect(list.length).toBe(0);
|
|
462
561
|
});
|
|
463
562
|
|
|
464
563
|
it('should push elements to the end of the list', () => {
|
|
@@ -466,7 +565,7 @@ describe('SinglyLinkedList', () => {
|
|
|
466
565
|
list.push(2);
|
|
467
566
|
expect(list.head!.value).toBe(1);
|
|
468
567
|
expect(list.tail!.value).toBe(2);
|
|
469
|
-
expect(list.
|
|
568
|
+
expect(list.length).toBe(2);
|
|
470
569
|
});
|
|
471
570
|
|
|
472
571
|
it('should pop elements from the end of the list', () => {
|
|
@@ -476,7 +575,7 @@ describe('SinglyLinkedList', () => {
|
|
|
476
575
|
expect(popped).toBe(2);
|
|
477
576
|
expect(list.head!.value).toBe(1);
|
|
478
577
|
expect(list.tail!.value).toBe(1);
|
|
479
|
-
expect(list.
|
|
578
|
+
expect(list.length).toBe(1);
|
|
480
579
|
});
|
|
481
580
|
|
|
482
581
|
it('should reverse the list', () => {
|
|
@@ -545,7 +644,8 @@ describe('iterable methods', () => {
|
|
|
545
644
|
expect(sl.some(element => element > 2)).toBe(true);
|
|
546
645
|
|
|
547
646
|
expect([...sl.filter(element => element > 2)]).toEqual([3]);
|
|
548
|
-
|
|
647
|
+
const mappedSl = sl.map(element => element * 2);
|
|
648
|
+
expect([...mappedSl]).toEqual([2, 4, 6]);
|
|
549
649
|
expect(sl.reduce((accumulator, element) => accumulator + element, 0)).toEqual(6);
|
|
550
650
|
});
|
|
551
651
|
});
|