data-structure-typed 1.52.6 → 1.52.7
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/README.md +33 -30
- package/benchmark/report.html +13 -13
- package/benchmark/report.json +156 -156
- package/dist/cjs/constants/index.d.ts +4 -0
- package/dist/cjs/constants/index.js +9 -0
- package/dist/cjs/constants/index.js.map +1 -0
- package/dist/cjs/data-structures/base/iterable-element-base.d.ts +8 -1
- package/dist/cjs/data-structures/base/iterable-element-base.js +10 -1
- package/dist/cjs/data-structures/base/iterable-element-base.js.map +1 -1
- package/dist/cjs/data-structures/base/iterable-entry-base.d.ts +8 -1
- package/dist/cjs/data-structures/base/iterable-entry-base.js +10 -10
- package/dist/cjs/data-structures/base/iterable-entry-base.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +31 -32
- package/dist/cjs/data-structures/binary-tree/avl-tree-multi-map.js +43 -44
- 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 +23 -24
- package/dist/cjs/data-structures/binary-tree/avl-tree.js +71 -64
- package/dist/cjs/data-structures/binary-tree/avl-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/binary-indexed-tree.js +2 -2
- package/dist/cjs/data-structures/binary-tree/binary-tree.d.ts +534 -402
- package/dist/cjs/data-structures/binary-tree/binary-tree.js +668 -597
- package/dist/cjs/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/bst.d.ts +72 -65
- package/dist/cjs/data-structures/binary-tree/bst.js +115 -113
- package/dist/cjs/data-structures/binary-tree/bst.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/rb-tree.d.ts +21 -24
- package/dist/cjs/data-structures/binary-tree/rb-tree.js +40 -39
- package/dist/cjs/data-structures/binary-tree/rb-tree.js.map +1 -1
- package/dist/cjs/data-structures/binary-tree/segment-tree.d.ts +2 -2
- package/dist/cjs/data-structures/binary-tree/segment-tree.js +2 -2
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.d.ts +28 -31
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js +44 -43
- package/dist/cjs/data-structures/binary-tree/tree-multi-map.js.map +1 -1
- package/dist/cjs/data-structures/graph/abstract-graph.d.ts +2 -2
- package/dist/cjs/data-structures/graph/abstract-graph.js +7 -4
- package/dist/cjs/data-structures/graph/abstract-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/directed-graph.d.ts +2 -2
- package/dist/cjs/data-structures/graph/directed-graph.js +4 -2
- package/dist/cjs/data-structures/graph/directed-graph.js.map +1 -1
- package/dist/cjs/data-structures/graph/undirected-graph.d.ts +2 -2
- package/dist/cjs/data-structures/hash/hash-map.d.ts +2 -2
- package/dist/cjs/data-structures/hash/hash-map.js +1 -1
- package/dist/cjs/data-structures/hash/hash-map.js.map +1 -1
- package/dist/cjs/data-structures/heap/heap.js +3 -3
- package/dist/cjs/data-structures/heap/heap.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.d.ts +2 -2
- package/dist/cjs/data-structures/linked-list/doubly-linked-list.js +7 -7
- 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 +2 -2
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js +6 -6
- package/dist/cjs/data-structures/linked-list/singly-linked-list.js.map +1 -1
- package/dist/cjs/data-structures/linked-list/skip-linked-list.d.ts +2 -2
- package/dist/cjs/data-structures/matrix/matrix.d.ts +2 -2
- package/dist/cjs/data-structures/matrix/navigator.d.ts +2 -2
- package/dist/cjs/data-structures/matrix/navigator.js +4 -2
- package/dist/cjs/data-structures/matrix/navigator.js.map +1 -1
- package/dist/cjs/data-structures/queue/deque.d.ts +3 -3
- package/dist/cjs/data-structures/queue/deque.js +29 -29
- package/dist/cjs/data-structures/queue/deque.js.map +1 -1
- package/dist/cjs/data-structures/queue/queue.d.ts +1 -1
- package/dist/cjs/data-structures/stack/stack.d.ts +2 -2
- package/dist/cjs/data-structures/trie/trie.d.ts +2 -2
- package/dist/cjs/data-structures/trie/trie.js +1 -1
- package/dist/cjs/data-structures/trie/trie.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interfaces/binary-tree.d.ts +2 -2
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.d.ts +2 -4
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.js +0 -6
- package/dist/cjs/types/data-structures/binary-tree/binary-tree.js.map +1 -1
- package/dist/mjs/constants/index.d.ts +4 -0
- package/dist/mjs/constants/index.js +5 -0
- package/dist/mjs/data-structures/base/iterable-element-base.d.ts +8 -1
- package/dist/mjs/data-structures/base/iterable-element-base.js +10 -1
- package/dist/mjs/data-structures/base/iterable-entry-base.d.ts +8 -1
- package/dist/mjs/data-structures/base/iterable-entry-base.js +10 -10
- package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.d.ts +31 -32
- package/dist/mjs/data-structures/binary-tree/avl-tree-multi-map.js +44 -44
- package/dist/mjs/data-structures/binary-tree/avl-tree.d.ts +23 -24
- package/dist/mjs/data-structures/binary-tree/avl-tree.js +72 -64
- package/dist/mjs/data-structures/binary-tree/binary-indexed-tree.js +2 -2
- package/dist/mjs/data-structures/binary-tree/binary-tree.d.ts +534 -402
- package/dist/mjs/data-structures/binary-tree/binary-tree.js +667 -591
- package/dist/mjs/data-structures/binary-tree/bst.d.ts +72 -65
- package/dist/mjs/data-structures/binary-tree/bst.js +116 -112
- package/dist/mjs/data-structures/binary-tree/rb-tree.d.ts +21 -24
- package/dist/mjs/data-structures/binary-tree/rb-tree.js +41 -38
- package/dist/mjs/data-structures/binary-tree/segment-tree.d.ts +2 -2
- package/dist/mjs/data-structures/binary-tree/segment-tree.js +2 -2
- package/dist/mjs/data-structures/binary-tree/tree-multi-map.d.ts +28 -31
- package/dist/mjs/data-structures/binary-tree/tree-multi-map.js +45 -42
- package/dist/mjs/data-structures/graph/abstract-graph.d.ts +2 -2
- package/dist/mjs/data-structures/graph/abstract-graph.js +7 -4
- package/dist/mjs/data-structures/graph/directed-graph.d.ts +2 -2
- package/dist/mjs/data-structures/graph/directed-graph.js +4 -2
- package/dist/mjs/data-structures/graph/undirected-graph.d.ts +2 -2
- package/dist/mjs/data-structures/hash/hash-map.d.ts +2 -2
- package/dist/mjs/data-structures/hash/hash-map.js +1 -1
- package/dist/mjs/data-structures/heap/heap.js +3 -3
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.d.ts +2 -2
- package/dist/mjs/data-structures/linked-list/doubly-linked-list.js +7 -7
- package/dist/mjs/data-structures/linked-list/singly-linked-list.d.ts +2 -2
- package/dist/mjs/data-structures/linked-list/singly-linked-list.js +6 -6
- package/dist/mjs/data-structures/linked-list/skip-linked-list.d.ts +2 -2
- package/dist/mjs/data-structures/matrix/matrix.d.ts +2 -2
- package/dist/mjs/data-structures/matrix/navigator.d.ts +2 -2
- package/dist/mjs/data-structures/matrix/navigator.js +4 -2
- package/dist/mjs/data-structures/queue/deque.d.ts +3 -3
- package/dist/mjs/data-structures/queue/deque.js +29 -29
- package/dist/mjs/data-structures/queue/queue.d.ts +1 -1
- package/dist/mjs/data-structures/stack/stack.d.ts +2 -2
- package/dist/mjs/data-structures/trie/trie.d.ts +2 -2
- package/dist/mjs/data-structures/trie/trie.js +1 -1
- package/dist/mjs/index.d.ts +1 -0
- package/dist/mjs/index.js +1 -0
- package/dist/mjs/interfaces/binary-tree.d.ts +2 -2
- package/dist/mjs/types/data-structures/binary-tree/binary-tree.d.ts +2 -4
- package/dist/mjs/types/data-structures/binary-tree/binary-tree.js +1 -5
- package/dist/umd/data-structure-typed.js +1343 -1615
- package/dist/umd/data-structure-typed.min.js +10 -3
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/eslint.config.mjs +69 -0
- package/package.json +30 -28
- package/src/constants/index.ts +4 -0
- package/src/data-structures/base/iterable-element-base.ts +11 -1
- package/src/data-structures/base/iterable-entry-base.ts +11 -19
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +47 -50
- package/src/data-structures/binary-tree/avl-tree.ts +69 -71
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +2 -2
- package/src/data-structures/binary-tree/binary-tree.ts +697 -725
- package/src/data-structures/binary-tree/bst.ts +123 -129
- package/src/data-structures/binary-tree/rb-tree.ts +44 -46
- package/src/data-structures/binary-tree/segment-tree.ts +2 -2
- package/src/data-structures/binary-tree/tree-multi-map.ts +48 -49
- package/src/data-structures/graph/abstract-graph.ts +6 -6
- package/src/data-structures/graph/directed-graph.ts +4 -4
- package/src/data-structures/graph/undirected-graph.ts +2 -2
- package/src/data-structures/hash/hash-map.ts +3 -3
- package/src/data-structures/heap/heap.ts +3 -3
- package/src/data-structures/linked-list/doubly-linked-list.ts +9 -9
- package/src/data-structures/linked-list/singly-linked-list.ts +8 -8
- package/src/data-structures/linked-list/skip-linked-list.ts +2 -2
- package/src/data-structures/matrix/matrix.ts +2 -2
- package/src/data-structures/matrix/navigator.ts +4 -4
- package/src/data-structures/queue/deque.ts +31 -31
- package/src/data-structures/queue/queue.ts +1 -1
- package/src/data-structures/stack/stack.ts +2 -2
- package/src/data-structures/trie/trie.ts +3 -3
- package/src/index.ts +1 -0
- package/src/interfaces/binary-tree.ts +3 -3
- package/src/types/data-structures/binary-tree/binary-tree.ts +3 -5
- package/test/config.ts +1 -7
- package/test/integration/all-in-one.test.ts +2 -2
- package/test/integration/avl-tree.test.ts +2 -2
- package/test/integration/bst.test.ts +17 -16
- package/test/integration/heap.test.js +6 -1
- package/test/unit/data-structures/binary-tree/avl-tree-multi-map.test.ts +39 -39
- package/test/unit/data-structures/binary-tree/avl-tree.test.ts +2 -2
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +51 -26
- package/test/unit/data-structures/binary-tree/bst.test.ts +41 -13
- package/test/unit/data-structures/binary-tree/overall.test.ts +0 -6
- package/test/unit/data-structures/binary-tree/rb-tree.test.ts +6 -6
- package/test/unit/data-structures/binary-tree/segment-tree.test.ts +88 -34
- package/test/unit/data-structures/binary-tree/tree-multi-map.test.ts +42 -42
- package/test/unit/data-structures/graph/abstract-graph.test.ts +1 -1
- package/test/unit/data-structures/graph/directed-graph.test.ts +4 -4
- package/test/unit/data-structures/graph/undirected-graph.test.ts +14 -2
- package/test/unit/data-structures/hash/hash-map.test.ts +1 -1
- package/test/unit/data-structures/linked-list/doubly-linked-list.test.ts +1 -1
- package/test/unit/data-structures/matrix/navigator.test.ts +2 -2
- package/test/unit/data-structures/priority-queue/min-priority-queue.test.ts +1 -1
- package/test/unit/data-structures/priority-queue/priority-queue.test.ts +4 -4
- package/test/unit/data-structures/stack/stack.test.ts +6 -0
- package/test/unit/unrestricted-interconversion.test.ts +24 -24
- package/test/utils/big-o.ts +5 -4
- package/.eslintrc.js +0 -64
|
@@ -86,8 +86,8 @@ describe('Priority Queue Performance Test', () => {
|
|
|
86
86
|
// for (let i = 0; i < 10000; i++) {
|
|
87
87
|
// pq.pop();
|
|
88
88
|
// }
|
|
89
|
-
isDebug
|
|
90
|
-
isDebug
|
|
89
|
+
if (isDebug) console.log(performance.now() - tS);
|
|
90
|
+
if (isDebug) console.log(pq.size);
|
|
91
91
|
const cS = performance.now();
|
|
92
92
|
const cpq = new CPriorityQueue();
|
|
93
93
|
|
|
@@ -98,7 +98,7 @@ describe('Priority Queue Performance Test', () => {
|
|
|
98
98
|
// for (let i = 0; i < 10000; i++) {
|
|
99
99
|
// cpq.pop();
|
|
100
100
|
// }
|
|
101
|
-
isDebug
|
|
102
|
-
isDebug
|
|
101
|
+
if (isDebug) console.log(performance.now() - cS);
|
|
102
|
+
if (isDebug) console.log(cpq.size());
|
|
103
103
|
});
|
|
104
104
|
});
|
|
@@ -18,6 +18,12 @@ describe('Stack', () => {
|
|
|
18
18
|
expect(stack.size).toBe(3);
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
+
it('should has and get', () => {
|
|
22
|
+
const stack = new Stack<number, { id: number; name: string }>([], { toElementFn: rawElement => rawElement.id });
|
|
23
|
+
expect(stack.has(1)).toBe(false);
|
|
24
|
+
expect(stack.size).toBe(0);
|
|
25
|
+
});
|
|
26
|
+
|
|
21
27
|
it('should peek at the top element without removing it', () => {
|
|
22
28
|
expect(stack.peek()).toBe(undefined);
|
|
23
29
|
stack.push(1);
|
|
@@ -48,61 +48,61 @@ const entries: [number, string][] = [
|
|
|
48
48
|
describe('conversions', () => {
|
|
49
49
|
it('Array to Queue', () => {
|
|
50
50
|
const q = new Queue<number>(orgArr);
|
|
51
|
-
isDebug
|
|
51
|
+
if (isDebug) q.print();
|
|
52
52
|
expect([...q]).toEqual([6, 1, 2, 7, 5, 3, 4, 9, 8]);
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
it('Array to Deque', () => {
|
|
56
56
|
const dq = new Deque<number>(orgArr);
|
|
57
|
-
isDebug
|
|
57
|
+
if (isDebug) dq.print();
|
|
58
58
|
expect([...dq]).toEqual([6, 1, 2, 7, 5, 3, 4, 9, 8]);
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
it('Array to SinglyLinkedList', () => {
|
|
62
62
|
const sl = new SinglyLinkedList<number>(orgArr);
|
|
63
|
-
isDebug
|
|
63
|
+
if (isDebug) sl.print();
|
|
64
64
|
expect([...sl]).toEqual([6, 1, 2, 7, 5, 3, 4, 9, 8]);
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
it('Array to DoublyLinkedList', () => {
|
|
68
68
|
const dl = new DoublyLinkedList<number>(orgArr);
|
|
69
|
-
isDebug
|
|
69
|
+
if (isDebug) dl.print();
|
|
70
70
|
expect([...dl]).toEqual([6, 1, 2, 7, 5, 3, 4, 9, 8]);
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
it('Array to Stack', () => {
|
|
74
74
|
const stack = new Stack<number>(orgArr);
|
|
75
|
-
isDebug
|
|
75
|
+
if (isDebug) stack.print();
|
|
76
76
|
expect([...stack]).toEqual([6, 1, 2, 7, 5, 3, 4, 9, 8]);
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
it('Array to MinHeap', () => {
|
|
80
80
|
const minHeap = new MinHeap<number>(orgArr);
|
|
81
|
-
isDebug
|
|
81
|
+
if (isDebug) minHeap.print();
|
|
82
82
|
expect([...minHeap]).toEqual([1, 5, 2, 7, 6, 3, 4, 9, 8]);
|
|
83
83
|
});
|
|
84
84
|
|
|
85
85
|
it('Array to MaxHeap', () => {
|
|
86
86
|
const maxHeap = new MaxHeap<number>(orgArr);
|
|
87
|
-
isDebug
|
|
87
|
+
if (isDebug) maxHeap.print();
|
|
88
88
|
expect([...maxHeap]).toEqual([9, 8, 4, 7, 5, 2, 3, 1, 6]);
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
it('Array to MinPriorityQueue', () => {
|
|
92
92
|
const minPQ = new MinPriorityQueue<number>(orgArr);
|
|
93
|
-
isDebug
|
|
93
|
+
if (isDebug) minPQ.print();
|
|
94
94
|
expect([...minPQ]).toEqual([1, 5, 2, 7, 6, 3, 4, 9, 8]);
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
it('Array to MaxPriorityQueue', () => {
|
|
98
98
|
const maxPQ = new MaxPriorityQueue<number>(orgArr);
|
|
99
|
-
isDebug
|
|
99
|
+
if (isDebug) maxPQ.print();
|
|
100
100
|
expect([...maxPQ]).toEqual([9, 8, 4, 7, 5, 2, 3, 1, 6]);
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
it('Entry Array to BinaryTree', () => {
|
|
104
104
|
const biTree = new BinaryTree<number>(entries);
|
|
105
|
-
isDebug
|
|
105
|
+
if (isDebug) biTree.print();
|
|
106
106
|
expect([...biTree]).toEqual([
|
|
107
107
|
[9, '9'],
|
|
108
108
|
[7, '7'],
|
|
@@ -119,7 +119,7 @@ describe('conversions', () => {
|
|
|
119
119
|
it('Entry Array to BST', () => {
|
|
120
120
|
const bst = new BST<number>(entries);
|
|
121
121
|
expect(bst.size).toBe(9);
|
|
122
|
-
isDebug
|
|
122
|
+
if (isDebug) bst.print();
|
|
123
123
|
expect([...bst]).toEqual([
|
|
124
124
|
[1, '1'],
|
|
125
125
|
[2, '2'],
|
|
@@ -136,7 +136,7 @@ describe('conversions', () => {
|
|
|
136
136
|
it('Entry Array to RedBlackTree', () => {
|
|
137
137
|
const rbTree = new RedBlackTree<number>(entries);
|
|
138
138
|
expect(rbTree.size).toBe(9);
|
|
139
|
-
isDebug
|
|
139
|
+
if (isDebug) rbTree.print();
|
|
140
140
|
expect([...rbTree]).toEqual([
|
|
141
141
|
[1, '1'],
|
|
142
142
|
[2, '2'],
|
|
@@ -153,7 +153,7 @@ describe('conversions', () => {
|
|
|
153
153
|
it('Entry Array to AVLTree', () => {
|
|
154
154
|
const avl = new AVLTree<number>(entries);
|
|
155
155
|
expect(avl.size).toBe(9);
|
|
156
|
-
isDebug
|
|
156
|
+
if (isDebug) avl.print();
|
|
157
157
|
expect([...avl]).toEqual([
|
|
158
158
|
[1, '1'],
|
|
159
159
|
[2, '2'],
|
|
@@ -170,7 +170,7 @@ describe('conversions', () => {
|
|
|
170
170
|
it('Entry Array to TreeMultiMap', () => {
|
|
171
171
|
const treeMulti = new TreeMultiMap<number>(entries);
|
|
172
172
|
expect(treeMulti.size).toBe(9);
|
|
173
|
-
isDebug
|
|
173
|
+
if (isDebug) treeMulti.print();
|
|
174
174
|
expect([...treeMulti]).toEqual([
|
|
175
175
|
[1, '1'],
|
|
176
176
|
[2, '2'],
|
|
@@ -186,10 +186,10 @@ describe('conversions', () => {
|
|
|
186
186
|
|
|
187
187
|
it('HashMap to RedBlackTree', () => {
|
|
188
188
|
const hm = new HashMap(entries);
|
|
189
|
-
isDebug
|
|
189
|
+
if (isDebug) hm.print();
|
|
190
190
|
const rbTree = new RedBlackTree<number>(hm);
|
|
191
191
|
expect(rbTree.size).toBe(9);
|
|
192
|
-
isDebug
|
|
192
|
+
if (isDebug) rbTree.print();
|
|
193
193
|
expect([...rbTree]).toEqual([
|
|
194
194
|
[1, '1'],
|
|
195
195
|
[2, '2'],
|
|
@@ -205,10 +205,10 @@ describe('conversions', () => {
|
|
|
205
205
|
|
|
206
206
|
it('PriorityQueue to BST', () => {
|
|
207
207
|
const pq = new MinPriorityQueue(orgArr);
|
|
208
|
-
isDebug
|
|
208
|
+
if (isDebug) pq.print();
|
|
209
209
|
const bst = new BST<number>(pq);
|
|
210
210
|
expect(bst.size).toBe(9);
|
|
211
|
-
isDebug
|
|
211
|
+
if (isDebug) bst.print();
|
|
212
212
|
expect([...bst]).toEqual([
|
|
213
213
|
[1, undefined],
|
|
214
214
|
[2, undefined],
|
|
@@ -224,10 +224,10 @@ describe('conversions', () => {
|
|
|
224
224
|
|
|
225
225
|
it('Deque to RedBlackTree', () => {
|
|
226
226
|
const dq = new Deque(orgArr);
|
|
227
|
-
isDebug
|
|
227
|
+
if (isDebug) dq.print();
|
|
228
228
|
const rbTree = new RedBlackTree<number>(dq);
|
|
229
229
|
expect(rbTree.size).toBe(9);
|
|
230
|
-
isDebug
|
|
230
|
+
if (isDebug) rbTree.print();
|
|
231
231
|
expect([...rbTree]).toEqual([
|
|
232
232
|
[1, undefined],
|
|
233
233
|
[2, undefined],
|
|
@@ -244,12 +244,12 @@ describe('conversions', () => {
|
|
|
244
244
|
it('Trie to Heap to Deque', () => {
|
|
245
245
|
const trie = new Trie(orgStrArr);
|
|
246
246
|
expect(trie.size).toBe(10);
|
|
247
|
-
isDebug
|
|
247
|
+
if (isDebug) trie.print();
|
|
248
248
|
const heap = new Heap<string>(trie, {
|
|
249
249
|
comparator: (a, b) => Number(a) - Number(b)
|
|
250
250
|
});
|
|
251
251
|
expect(heap.size).toBe(10);
|
|
252
|
-
isDebug
|
|
252
|
+
if (isDebug) heap.print();
|
|
253
253
|
expect([...heap]).toEqual([
|
|
254
254
|
'transmit',
|
|
255
255
|
'trace',
|
|
@@ -264,7 +264,7 @@ describe('conversions', () => {
|
|
|
264
264
|
]);
|
|
265
265
|
const dq = new Deque<string>(heap);
|
|
266
266
|
expect(dq.size).toBe(10);
|
|
267
|
-
isDebug
|
|
267
|
+
if (isDebug) dq.print();
|
|
268
268
|
expect([...dq]).toEqual([
|
|
269
269
|
'transmit',
|
|
270
270
|
'trace',
|
|
@@ -280,7 +280,7 @@ describe('conversions', () => {
|
|
|
280
280
|
const entries = dq.map((el, i) => <[number, string]>[i, el]);
|
|
281
281
|
const avl = new AVLTree<number, string>(entries);
|
|
282
282
|
expect(avl.size).toBe(10);
|
|
283
|
-
isDebug
|
|
283
|
+
if (isDebug) avl.print();
|
|
284
284
|
expect([...avl]).toEqual([
|
|
285
285
|
[0, 'transmit'],
|
|
286
286
|
[1, 'trace'],
|
package/test/utils/big-o.ts
CHANGED
|
@@ -158,12 +158,12 @@ export function logBigOMetricsWrap<F extends AnyFunction>(fn: F, args: Parameter
|
|
|
158
158
|
methodLog.push([runTime, maxDataSize]);
|
|
159
159
|
|
|
160
160
|
if (methodLog.length >= 20) {
|
|
161
|
-
isDebug
|
|
161
|
+
if (isDebug) console.log('triggered', methodName, methodLog);
|
|
162
162
|
const bigO = estimateBigO(
|
|
163
163
|
methodLog.map(([runTime]) => runTime),
|
|
164
164
|
methodLog.map(([runTime]) => runTime)
|
|
165
165
|
);
|
|
166
|
-
isDebug
|
|
166
|
+
if (isDebug) console.log(`Estimated Big O: ${bigO}`);
|
|
167
167
|
methodLogs.delete(methodName);
|
|
168
168
|
}
|
|
169
169
|
}
|
|
@@ -192,12 +192,13 @@ export function logBigOMetrics(target: any, propertyKey: string, descriptor: Pro
|
|
|
192
192
|
methodLog.push([runTime, maxDataSize]);
|
|
193
193
|
|
|
194
194
|
if (methodLog.length >= 20) {
|
|
195
|
-
isDebug
|
|
195
|
+
if (isDebug) console.log('triggered', methodName, methodLog);
|
|
196
196
|
const bigO = estimateBigO(
|
|
197
197
|
methodLog.map(([runTime]) => runTime),
|
|
198
198
|
methodLog.map(([runTime]) => runTime)
|
|
199
199
|
);
|
|
200
|
-
|
|
200
|
+
|
|
201
|
+
if (isDebug) console.log(`Estimated Big O: ${bigO}`);
|
|
201
202
|
methodLogs.delete(methodName);
|
|
202
203
|
}
|
|
203
204
|
}
|
package/.eslintrc.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
"parser": "@typescript-eslint/parser",
|
|
3
|
-
"plugins": [
|
|
4
|
-
"@typescript-eslint",
|
|
5
|
-
"eslint-plugin-import"
|
|
6
|
-
],
|
|
7
|
-
"extends": [
|
|
8
|
-
"plugin:@typescript-eslint/recommended",
|
|
9
|
-
"prettier"
|
|
10
|
-
],
|
|
11
|
-
"ignorePatterns": ["lib/", "dist/", "umd/", "coverage/", "docs/"],
|
|
12
|
-
"rules": {
|
|
13
|
-
"import/no-anonymous-default-export": "off",
|
|
14
|
-
"@typescript-eslint/no-unused-vars": "warn",
|
|
15
|
-
"@typescript-eslint/ban-ts-comment": "off",
|
|
16
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
17
|
-
"@typescript-eslint/no-var-requires": "off",
|
|
18
|
-
"@typescript-eslint/no-non-null-assertion": "off",
|
|
19
|
-
"lines-around-comment": [
|
|
20
|
-
"warn",
|
|
21
|
-
{
|
|
22
|
-
"beforeLineComment": false,
|
|
23
|
-
"beforeBlockComment": true,
|
|
24
|
-
"allowBlockStart": true,
|
|
25
|
-
"allowClassStart": true,
|
|
26
|
-
"allowObjectStart": true,
|
|
27
|
-
"allowArrayStart": true
|
|
28
|
-
}
|
|
29
|
-
],
|
|
30
|
-
"newline-before-return": "off",
|
|
31
|
-
"import/newline-after-import": [
|
|
32
|
-
"warn",
|
|
33
|
-
{
|
|
34
|
-
"count": 1
|
|
35
|
-
}
|
|
36
|
-
],
|
|
37
|
-
"@typescript-eslint/ban-types": [
|
|
38
|
-
"error",
|
|
39
|
-
{
|
|
40
|
-
"extendDefaults": true,
|
|
41
|
-
"types": {
|
|
42
|
-
"{}": false
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
],
|
|
46
|
-
// "brace-style": ["error", "1tbs", { "allowSingleLine": true }],
|
|
47
|
-
"object-curly-spacing": ["warn", "always"]
|
|
48
|
-
},
|
|
49
|
-
"settings": {
|
|
50
|
-
"import/parsers": {
|
|
51
|
-
"@typescript-eslint/parser": [
|
|
52
|
-
".ts"
|
|
53
|
-
]
|
|
54
|
-
},
|
|
55
|
-
"import/resolver": {
|
|
56
|
-
"typescript": {
|
|
57
|
-
"alwaysTryTypes": true,
|
|
58
|
-
"project": [
|
|
59
|
-
"./tsconfig.json"
|
|
60
|
-
]
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|