data-structure-typed 2.1.1 → 2.1.2
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 +19 -7
- package/dist/cjs/index.cjs +22 -22
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.mjs +22 -22
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/bst.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +2 -2
- package/dist/types/data-structures/binary-tree/tree-counter.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +1 -1
- package/dist/types/data-structures/heap/heap.d.ts +4 -4
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +1 -1
- package/dist/types/interfaces/binary-tree.d.ts +1 -1
- package/dist/umd/data-structure-typed.js +87 -165
- package/dist/umd/data-structure-typed.js.map +1 -1
- package/dist/umd/data-structure-typed.min.js +2 -2
- package/dist/umd/data-structure-typed.min.js.map +1 -1
- package/jest.integration.config.js +7 -3
- package/package.json +11 -7
- package/src/data-structures/binary-tree/avl-tree-counter.ts +4 -4
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +1 -1
- package/src/data-structures/binary-tree/avl-tree.ts +2 -2
- package/src/data-structures/binary-tree/binary-tree.ts +4 -4
- package/src/data-structures/binary-tree/bst.ts +1 -1
- package/src/data-structures/binary-tree/red-black-tree.ts +2 -2
- package/src/data-structures/binary-tree/tree-counter.ts +4 -4
- package/src/data-structures/binary-tree/tree-multi-map.ts +1 -1
- package/src/data-structures/heap/heap.ts +5 -5
- package/src/data-structures/linked-list/singly-linked-list.ts +2 -2
- package/src/interfaces/binary-tree.ts +1 -1
- package/test/integration/compile.test.mjs +159 -0
- package/test/integration/compile.test.ts +176 -0
- package/test/integration/heap.test.js +1 -1
- package/test/integration/index.html +1 -1
- package/test/unit/data-structures/binary-tree/binary-tree.test.ts +3 -3
- package/{tsconfig-base.json → tsconfig.base.json} +0 -1
- package/tsconfig.test.json +1 -0
- package/{tsconfig-types.json → tsconfig.types.json} +1 -3
- package/tsup.config.js +2 -3
- package/dist/index.cjs +0 -13091
- package/dist/index.cjs.map +0 -1
- package/dist/index.js +0 -13013
- package/dist/index.js.map +0 -1
- package/test/integration/compile.js +0 -144
- package/test/integration/compile.mjs +0 -135
- package/test/integration/compile.ts +0 -171
- /package/{tsup.node.config.ts → tsup.node.config.js} +0 -0
package/dist/esm/index.mjs
CHANGED
|
@@ -2057,7 +2057,7 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
2057
2057
|
* @param value - Value to wrap in a node.
|
|
2058
2058
|
* @returns A new SinglyLinkedListNode instance.
|
|
2059
2059
|
*/
|
|
2060
|
-
|
|
2060
|
+
createNode(value) {
|
|
2061
2061
|
return new SinglyLinkedListNode(value);
|
|
2062
2062
|
}
|
|
2063
2063
|
/**
|
|
@@ -2077,7 +2077,7 @@ var _SinglyLinkedList = class _SinglyLinkedList extends LinearLinkedBase {
|
|
|
2077
2077
|
*/
|
|
2078
2078
|
_ensureNode(elementOrNode) {
|
|
2079
2079
|
if (this.isNode(elementOrNode)) return elementOrNode;
|
|
2080
|
-
return this.
|
|
2080
|
+
return this.createNode(elementOrNode);
|
|
2081
2081
|
}
|
|
2082
2082
|
/**
|
|
2083
2083
|
* (Protected) Normalize input into a node predicate.
|
|
@@ -4810,7 +4810,7 @@ var _FibonacciHeap = class _FibonacciHeap {
|
|
|
4810
4810
|
* @returns This heap.
|
|
4811
4811
|
*/
|
|
4812
4812
|
push(element) {
|
|
4813
|
-
const node = this.
|
|
4813
|
+
const node = this.createNode(element);
|
|
4814
4814
|
node.left = node;
|
|
4815
4815
|
node.right = node;
|
|
4816
4816
|
this.mergeWithRoot(node);
|
|
@@ -4909,7 +4909,7 @@ var _FibonacciHeap = class _FibonacciHeap {
|
|
|
4909
4909
|
this._size += heapToMerge.size;
|
|
4910
4910
|
heapToMerge.clear();
|
|
4911
4911
|
}
|
|
4912
|
-
|
|
4912
|
+
createNode(element) {
|
|
4913
4913
|
return new FibonacciHeapNode(element);
|
|
4914
4914
|
}
|
|
4915
4915
|
isEmpty() {
|
|
@@ -7069,7 +7069,7 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
7069
7069
|
* @param [value] - The value for the new node (used if not in Map mode).
|
|
7070
7070
|
* @returns The newly created node.
|
|
7071
7071
|
*/
|
|
7072
|
-
|
|
7072
|
+
createNode(key, value) {
|
|
7073
7073
|
return new BinaryTreeNode(key, this._isMapMode ? void 0 : value);
|
|
7074
7074
|
}
|
|
7075
7075
|
/**
|
|
@@ -8239,9 +8239,9 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
8239
8239
|
if (key === void 0) return [void 0, void 0];
|
|
8240
8240
|
else if (key === null) return [null, void 0];
|
|
8241
8241
|
const finalValue = value != null ? value : entryValue;
|
|
8242
|
-
return [this.
|
|
8242
|
+
return [this.createNode(key, finalValue), finalValue];
|
|
8243
8243
|
}
|
|
8244
|
-
return [this.
|
|
8244
|
+
return [this.createNode(keyNodeOrEntry, value), value];
|
|
8245
8245
|
}
|
|
8246
8246
|
/**
|
|
8247
8247
|
* (Protected) Helper for cloning. Performs a BFS and adds all nodes to the new tree.
|
|
@@ -8326,7 +8326,7 @@ var _BinaryTree = class _BinaryTree extends IterableEntryBase {
|
|
|
8326
8326
|
destNode = this.ensureNode(destNode);
|
|
8327
8327
|
if (srcNode && destNode) {
|
|
8328
8328
|
const { key, value } = destNode;
|
|
8329
|
-
const tempNode = this.
|
|
8329
|
+
const tempNode = this.createNode(key, value);
|
|
8330
8330
|
if (tempNode) {
|
|
8331
8331
|
destNode.key = srcNode.key;
|
|
8332
8332
|
if (!this._isMapMode) destNode.value = srcNode.value;
|
|
@@ -8592,7 +8592,7 @@ var _BST = class _BST extends BinaryTree {
|
|
|
8592
8592
|
* @param [value] - The value for the new node (used if not in Map mode).
|
|
8593
8593
|
* @returns The newly created BSTNode.
|
|
8594
8594
|
*/
|
|
8595
|
-
|
|
8595
|
+
createNode(key, value) {
|
|
8596
8596
|
return new BSTNode(key, this._isMapMode ? void 0 : value);
|
|
8597
8597
|
}
|
|
8598
8598
|
/**
|
|
@@ -9828,7 +9828,7 @@ var _AVLTree = class _AVLTree extends BST {
|
|
|
9828
9828
|
* @param [value] - The value for the new node.
|
|
9829
9829
|
* @returns The newly created AVLTreeNode.
|
|
9830
9830
|
*/
|
|
9831
|
-
|
|
9831
|
+
createNode(key, value) {
|
|
9832
9832
|
return new AVLTreeNode(key, this._isMapMode ? void 0 : value);
|
|
9833
9833
|
}
|
|
9834
9834
|
/**
|
|
@@ -9959,7 +9959,7 @@ var _AVLTree = class _AVLTree extends BST {
|
|
|
9959
9959
|
const destNodeEnsured = this.ensureNode(destNode);
|
|
9960
9960
|
if (srcNodeEnsured && destNodeEnsured) {
|
|
9961
9961
|
const { key, value, height } = destNodeEnsured;
|
|
9962
|
-
const tempNode = this.
|
|
9962
|
+
const tempNode = this.createNode(key, value);
|
|
9963
9963
|
if (tempNode) {
|
|
9964
9964
|
tempNode.height = height;
|
|
9965
9965
|
destNodeEnsured.key = srcNodeEnsured.key;
|
|
@@ -10284,7 +10284,7 @@ var _RedBlackTree = class _RedBlackTree extends BST {
|
|
|
10284
10284
|
* @param color - See parameter type for details.
|
|
10285
10285
|
* @returns A new RedBlackTreeNode instance.
|
|
10286
10286
|
*/
|
|
10287
|
-
|
|
10287
|
+
createNode(key, value, color = "BLACK") {
|
|
10288
10288
|
return new RedBlackTreeNode(key, this._isMapMode ? void 0 : value, color);
|
|
10289
10289
|
}
|
|
10290
10290
|
/**
|
|
@@ -10721,7 +10721,7 @@ var _AVLTreeMultiMap = class _AVLTreeMultiMap extends AVLTree {
|
|
|
10721
10721
|
this.addMany(keysNodesEntriesOrRaws);
|
|
10722
10722
|
}
|
|
10723
10723
|
}
|
|
10724
|
-
|
|
10724
|
+
createNode(key, value = []) {
|
|
10725
10725
|
return new AVLTreeMultiMapNode(key, this._isMapMode ? [] : value);
|
|
10726
10726
|
}
|
|
10727
10727
|
/**
|
|
@@ -10940,7 +10940,7 @@ var _TreeMultiMap = class _TreeMultiMap extends RedBlackTree {
|
|
|
10940
10940
|
this.addMany(keysNodesEntriesOrRaws);
|
|
10941
10941
|
}
|
|
10942
10942
|
}
|
|
10943
|
-
|
|
10943
|
+
createNode(key, value = []) {
|
|
10944
10944
|
return new TreeMultiMapNode(key, this._isMapMode ? [] : value);
|
|
10945
10945
|
}
|
|
10946
10946
|
/**
|
|
@@ -11151,7 +11151,7 @@ var _TreeCounter = class _TreeCounter extends RedBlackTree {
|
|
|
11151
11151
|
this.dfs((node) => sum += node ? node.count : 0);
|
|
11152
11152
|
return sum;
|
|
11153
11153
|
}
|
|
11154
|
-
|
|
11154
|
+
createNode(key, value, color = "BLACK", count) {
|
|
11155
11155
|
return new TreeCounterNode(key, this._isMapMode ? void 0 : value, count, color);
|
|
11156
11156
|
}
|
|
11157
11157
|
/**
|
|
@@ -11386,9 +11386,9 @@ var _TreeCounter = class _TreeCounter extends RedBlackTree {
|
|
|
11386
11386
|
const [key, entryValue] = keyNodeOrEntry;
|
|
11387
11387
|
if (key === void 0 || key === null) return [void 0, void 0];
|
|
11388
11388
|
const finalValue = value != null ? value : entryValue;
|
|
11389
|
-
return [this.
|
|
11389
|
+
return [this.createNode(key, finalValue, "BLACK", count), finalValue];
|
|
11390
11390
|
}
|
|
11391
|
-
return [this.
|
|
11391
|
+
return [this.createNode(keyNodeOrEntry, value, "BLACK", count), value];
|
|
11392
11392
|
}
|
|
11393
11393
|
/**
|
|
11394
11394
|
* (Protected) Swap keys/values/counters between the source and destination nodes.
|
|
@@ -11402,7 +11402,7 @@ var _TreeCounter = class _TreeCounter extends RedBlackTree {
|
|
|
11402
11402
|
destNode = this.ensureNode(destNode);
|
|
11403
11403
|
if (srcNode && destNode) {
|
|
11404
11404
|
const { key, value, count, color } = destNode;
|
|
11405
|
-
const tempNode = this.
|
|
11405
|
+
const tempNode = this.createNode(key, value, color, count);
|
|
11406
11406
|
if (tempNode) {
|
|
11407
11407
|
tempNode.color = color;
|
|
11408
11408
|
destNode.key = srcNode.key;
|
|
@@ -11519,7 +11519,7 @@ var _AVLTreeCounter = class _AVLTreeCounter extends AVLTree {
|
|
|
11519
11519
|
this.dfs((node) => sum += node.count);
|
|
11520
11520
|
return sum;
|
|
11521
11521
|
}
|
|
11522
|
-
|
|
11522
|
+
createNode(key, value, count) {
|
|
11523
11523
|
return new AVLTreeCounterNode(key, this._isMapMode ? void 0 : value, count);
|
|
11524
11524
|
}
|
|
11525
11525
|
/**
|
|
@@ -11719,9 +11719,9 @@ var _AVLTreeCounter = class _AVLTreeCounter extends AVLTree {
|
|
|
11719
11719
|
const [key, entryValue] = keyNodeOrEntry;
|
|
11720
11720
|
if (key === void 0 || key === null) return [void 0, void 0];
|
|
11721
11721
|
const finalValue = value != null ? value : entryValue;
|
|
11722
|
-
return [this.
|
|
11722
|
+
return [this.createNode(key, finalValue, count), finalValue];
|
|
11723
11723
|
}
|
|
11724
|
-
return [this.
|
|
11724
|
+
return [this.createNode(keyNodeOrEntry, value, count), value];
|
|
11725
11725
|
}
|
|
11726
11726
|
/**
|
|
11727
11727
|
* (Protected) Swap keys/values/counters between the source and destination nodes.
|
|
@@ -11735,7 +11735,7 @@ var _AVLTreeCounter = class _AVLTreeCounter extends AVLTree {
|
|
|
11735
11735
|
destNode = this.ensureNode(destNode);
|
|
11736
11736
|
if (srcNode && destNode) {
|
|
11737
11737
|
const { key, value, count, height } = destNode;
|
|
11738
|
-
const tempNode = this.
|
|
11738
|
+
const tempNode = this.createNode(key, value, count);
|
|
11739
11739
|
if (tempNode) {
|
|
11740
11740
|
tempNode.height = height;
|
|
11741
11741
|
destNode.key = srcNode.key;
|