data-structure-typed 0.8.18 → 1.12.9
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/.dependency-cruiser.js +449 -0
- package/.idea/data-structure-typed.iml +2 -0
- package/.idea/modules.xml +1 -1
- package/README.md +298 -2
- package/dist/data-structures/binary-tree/aa-tree.js +5 -2
- package/dist/data-structures/binary-tree/avl-tree.d.ts +58 -5
- package/dist/data-structures/binary-tree/avl-tree.js +150 -46
- package/dist/data-structures/binary-tree/b-tree.js +5 -2
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +28 -1
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +41 -13
- package/dist/data-structures/binary-tree/binary-tree.d.ts +230 -36
- package/dist/data-structures/binary-tree/binary-tree.js +747 -369
- package/dist/data-structures/binary-tree/bst.d.ts +20 -8
- package/dist/data-structures/binary-tree/bst.js +164 -107
- package/dist/data-structures/binary-tree/rb-tree.js +5 -2
- package/dist/data-structures/binary-tree/segment-tree.d.ts +7 -3
- package/dist/data-structures/binary-tree/segment-tree.js +95 -61
- package/dist/data-structures/binary-tree/splay-tree.js +5 -2
- package/dist/data-structures/binary-tree/tree-multiset.d.ts +5 -5
- package/dist/data-structures/binary-tree/tree-multiset.js +35 -11
- package/dist/data-structures/binary-tree/two-three-tree.js +5 -2
- package/dist/data-structures/graph/abstract-graph.d.ts +168 -46
- package/dist/data-structures/graph/abstract-graph.js +712 -323
- package/dist/data-structures/graph/directed-graph.d.ts +114 -12
- package/dist/data-structures/graph/directed-graph.js +372 -128
- package/dist/data-structures/graph/undirected-graph.d.ts +67 -3
- package/dist/data-structures/graph/undirected-graph.js +233 -81
- package/dist/data-structures/hash/coordinate-map.d.ts +33 -1
- package/dist/data-structures/hash/coordinate-map.js +70 -20
- package/dist/data-structures/hash/coordinate-set.d.ts +25 -0
- package/dist/data-structures/hash/coordinate-set.js +58 -15
- package/dist/data-structures/hash/index.d.ts +5 -0
- package/dist/data-structures/hash/index.js +5 -0
- package/dist/data-structures/heap/heap.d.ts +26 -37
- package/dist/data-structures/heap/heap.js +56 -60
- package/dist/data-structures/heap/max-heap.d.ts +8 -2
- package/dist/data-structures/heap/max-heap.js +32 -9
- package/dist/data-structures/heap/min-heap.d.ts +9 -2
- package/dist/data-structures/heap/min-heap.js +33 -9
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +14 -7
- package/dist/data-structures/linked-list/doubly-linked-list.js +101 -61
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +18 -19
- package/dist/data-structures/linked-list/singly-linked-list.js +312 -174
- package/dist/data-structures/matrix/matrix.d.ts +9 -0
- package/dist/data-structures/matrix/matrix.js +19 -7
- package/dist/data-structures/matrix/matrix2d.d.ts +84 -4
- package/dist/data-structures/matrix/matrix2d.js +158 -61
- package/dist/data-structures/matrix/navigator.d.ts +34 -16
- package/dist/data-structures/matrix/navigator.js +65 -18
- package/dist/data-structures/matrix/vector2d.d.ts +153 -29
- package/dist/data-structures/matrix/vector2d.js +249 -102
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +11 -2
- package/dist/data-structures/priority-queue/max-priority-queue.js +33 -8
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +11 -2
- package/dist/data-structures/priority-queue/min-priority-queue.js +33 -8
- package/dist/data-structures/priority-queue/priority-queue.d.ts +145 -21
- package/dist/data-structures/priority-queue/priority-queue.js +285 -116
- package/dist/data-structures/queue/deque.d.ts +69 -0
- package/dist/data-structures/queue/deque.js +151 -56
- package/dist/data-structures/queue/queue.d.ts +34 -37
- package/dist/data-structures/queue/queue.js +59 -61
- package/dist/data-structures/stack/stack.d.ts +29 -35
- package/dist/data-structures/stack/stack.js +51 -56
- package/dist/data-structures/trie/trie.d.ts +36 -6
- package/dist/data-structures/trie/trie.js +256 -83
- package/dist/data-structures/types/abstract-graph.d.ts +29 -0
- package/dist/data-structures/types/abstract-graph.js +2 -0
- package/dist/data-structures/types/avl-tree.d.ts +5 -0
- package/dist/data-structures/types/avl-tree.js +2 -0
- package/dist/data-structures/types/binary-tree.d.ts +16 -0
- package/dist/data-structures/types/binary-tree.js +2 -0
- package/dist/data-structures/types/bst.d.ts +7 -0
- package/dist/data-structures/types/bst.js +2 -0
- package/dist/data-structures/types/directed-graph.d.ts +10 -0
- package/dist/data-structures/types/directed-graph.js +2 -0
- package/dist/data-structures/types/doubly-linked-list.d.ts +1 -0
- package/dist/data-structures/types/doubly-linked-list.js +2 -0
- package/dist/data-structures/types/heap.d.ts +7 -0
- package/dist/data-structures/types/heap.js +2 -0
- package/dist/data-structures/types/index.d.ts +13 -0
- package/dist/data-structures/types/index.js +29 -0
- package/dist/data-structures/types/navigator.d.ts +14 -0
- package/dist/data-structures/types/navigator.js +2 -0
- package/dist/data-structures/types/priority-queue.d.ts +7 -0
- package/dist/data-structures/types/priority-queue.js +2 -0
- package/dist/data-structures/types/segment-tree.d.ts +1 -0
- package/dist/data-structures/types/segment-tree.js +2 -0
- package/dist/data-structures/types/singly-linked-list.js +2 -0
- package/dist/data-structures/types/tree-multiset.d.ts +5 -0
- package/dist/data-structures/types/tree-multiset.js +2 -0
- package/dist/utils/trampoline.d.ts +14 -0
- package/dist/utils/trampoline.js +130 -0
- package/dist/utils/types/index.js +17 -0
- package/dist/{types → utils}/types/utils.d.ts +15 -1
- package/dist/{types → utils/types}/utils.js +21 -19
- package/dist/{utils.d.ts → utils/utils.d.ts} +5 -22
- package/dist/utils/utils.js +651 -0
- package/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +85 -0
- package/docs/assets/main.js +58 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1367 -0
- package/docs/classes/AVLTree.html +2046 -0
- package/docs/classes/AVLTreeNode.html +423 -0
- package/docs/classes/AaTree.html +117 -0
- package/docs/classes/AbstractEdge.html +198 -0
- package/docs/classes/AbstractGraph.html +891 -0
- package/docs/classes/AbstractVertex.html +164 -0
- package/docs/classes/ArrayDeque.html +384 -0
- package/docs/classes/BST.html +1893 -0
- package/docs/classes/BSTNode.html +425 -0
- package/docs/classes/BTree.html +117 -0
- package/docs/classes/BinaryIndexedTree.html +244 -0
- package/docs/classes/BinaryTree.html +1754 -0
- package/docs/classes/BinaryTreeNode.html +396 -0
- package/docs/classes/Character.html +165 -0
- package/docs/classes/CoordinateMap.html +394 -0
- package/docs/classes/CoordinateSet.html +355 -0
- package/docs/classes/Deque.html +617 -0
- package/docs/classes/DirectedEdge.html +247 -0
- package/docs/classes/DirectedGraph.html +1207 -0
- package/docs/classes/DirectedVertex.html +154 -0
- package/docs/classes/DoublyLinkedList.html +619 -0
- package/docs/classes/DoublyLinkedListNode.html +160 -0
- package/docs/classes/Heap.html +315 -0
- package/docs/classes/Matrix2D.html +447 -0
- package/docs/classes/MatrixNTI2D.html +181 -0
- package/docs/classes/MaxHeap.html +325 -0
- package/docs/classes/MaxPriorityQueue.html +668 -0
- package/docs/classes/MinHeap.html +326 -0
- package/docs/classes/MinPriorityQueue.html +668 -0
- package/docs/classes/Navigator.html +285 -0
- package/docs/classes/ObjectDeque.html +289 -0
- package/docs/classes/PriorityQueue.html +643 -0
- package/docs/classes/Queue.html +337 -0
- package/docs/classes/RBTree.html +117 -0
- package/docs/classes/SegmentTree.html +234 -0
- package/docs/classes/SegmentTreeNode.html +302 -0
- package/docs/classes/SinglyLinkedList.html +1035 -0
- package/docs/classes/SinglyLinkedListNode.html +304 -0
- package/docs/classes/SplayTree.html +117 -0
- package/docs/classes/Stack.html +313 -0
- package/docs/classes/TreeMultiSet.html +1897 -0
- package/docs/classes/Trie.html +317 -0
- package/docs/classes/TrieNode.html +221 -0
- package/docs/classes/TwoThreeTree.html +117 -0
- package/docs/classes/UndirectedEdge.html +220 -0
- package/docs/classes/UndirectedGraph.html +1006 -0
- package/docs/classes/UndirectedVertex.html +154 -0
- package/docs/classes/Vector2D.html +746 -0
- package/docs/enums/CP.html +126 -0
- package/docs/enums/FamilyPosition.html +126 -0
- package/docs/enums/LoopType.html +119 -0
- package/docs/index.html +288 -0
- package/docs/modules.html +146 -0
- package/jest.config.js +5 -0
- package/package.json +33 -47
- package/rename_clear_files.sh +29 -0
- package/src/assets/complexities-diff.jpg +0 -0
- package/src/assets/data-structure-complexities.jpg +0 -0
- package/src/data-structures/binary-tree/avl-tree.ts +58 -6
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +31 -4
- package/src/data-structures/binary-tree/binary-tree.ts +460 -145
- package/src/data-structures/binary-tree/bst.ts +31 -25
- package/src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif +0 -0
- package/src/data-structures/binary-tree/diagrams/bst-rotation.gif +0 -0
- package/src/data-structures/binary-tree/diagrams/segment-tree.png +0 -0
- package/src/data-structures/binary-tree/segment-tree.ts +25 -12
- package/src/data-structures/binary-tree/tree-multiset.ts +5 -4
- package/src/data-structures/diagrams/README.md +5 -0
- package/src/data-structures/graph/abstract-graph.ts +224 -108
- package/src/data-structures/graph/diagrams/adjacency-list-pros-cons.jpg +0 -0
- package/src/data-structures/graph/diagrams/adjacency-list.jpg +0 -0
- package/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.jpg +0 -0
- package/src/data-structures/graph/diagrams/adjacency-matrix.jpg +0 -0
- package/src/data-structures/graph/diagrams/dfs-can-do.jpg +0 -0
- package/src/data-structures/graph/diagrams/edge-list-pros-cons.jpg +0 -0
- package/src/data-structures/graph/diagrams/edge-list.jpg +0 -0
- package/src/data-structures/graph/diagrams/max-flow.jpg +0 -0
- package/src/data-structures/graph/diagrams/mst.jpg +0 -0
- package/src/data-structures/graph/diagrams/tarjan-articulation-point-bridge.png +0 -0
- package/src/data-structures/graph/diagrams/tarjan-complicate-simple.png +0 -0
- package/src/data-structures/graph/diagrams/tarjan-strongly-connected-component.png +0 -0
- package/src/data-structures/graph/diagrams/tarjan.mp4 +0 -0
- package/src/data-structures/graph/diagrams/tarjan.webp +0 -0
- package/src/data-structures/graph/directed-graph.ts +132 -26
- package/src/data-structures/graph/undirected-graph.ts +78 -11
- package/src/data-structures/hash/coordinate-map.ts +33 -1
- package/src/data-structures/hash/coordinate-set.ts +25 -0
- package/src/data-structures/hash/index.ts +5 -0
- package/src/data-structures/heap/heap.ts +27 -41
- package/src/data-structures/heap/max-heap.ts +8 -2
- package/src/data-structures/heap/min-heap.ts +9 -2
- package/src/data-structures/linked-list/doubly-linked-list.ts +50 -17
- package/src/data-structures/linked-list/singly-linked-list.ts +56 -39
- package/src/data-structures/matrix/matrix.ts +11 -0
- package/src/data-structures/matrix/matrix2d.ts +90 -10
- package/src/data-structures/matrix/navigator.ts +34 -14
- package/src/data-structures/matrix/vector2d.ts +187 -63
- package/src/data-structures/priority-queue/max-priority-queue.ts +12 -3
- package/src/data-structures/priority-queue/min-priority-queue.ts +12 -3
- package/src/data-structures/priority-queue/priority-queue.ts +200 -78
- package/src/data-structures/queue/deque.ts +71 -2
- package/src/data-structures/queue/queue.ts +37 -40
- package/src/data-structures/stack/stack.ts +32 -38
- package/src/data-structures/trie/trie.ts +83 -14
- package/src/data-structures/types/abstract-graph.ts +51 -0
- package/src/data-structures/types/avl-tree.ts +6 -0
- package/src/data-structures/types/binary-tree.ts +15 -0
- package/src/data-structures/types/bst.ts +5 -0
- package/src/data-structures/types/directed-graph.ts +18 -0
- package/src/data-structures/types/doubly-linked-list.ts +1 -0
- package/src/data-structures/types/heap.ts +8 -0
- package/src/data-structures/types/index.ts +13 -0
- package/src/data-structures/types/navigator.ts +13 -0
- package/src/data-structures/types/priority-queue.ts +9 -0
- package/src/data-structures/types/segment-tree.ts +1 -0
- package/src/data-structures/types/singly-linked-list.ts +1 -0
- package/src/data-structures/types/tree-multiset.ts +3 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/trampoline.ts +51 -0
- package/src/utils/types/index.ts +1 -0
- package/src/{types → utils/types}/utils.ts +27 -5
- package/src/{utils.ts → utils/utils.ts} +41 -131
- package/tests/unit/data-structures/binary-tree/bst.test.ts +185 -0
- package/tests/unit/data-structures/graph/directed-graph.test.ts +71 -0
- package/{dist/types/data-structures/graph/index.d.ts → tests/unit/data-structures/graph/index.ts} +1 -1
- package/tests/unit/data-structures/graph/undirected-graph.ts +0 -0
- package/tsconfig.json +9 -6
- package/dist/data-structures/trampoline.d.ts +0 -25
- package/dist/data-structures/trampoline.js +0 -52
- package/dist/types/data-structures/binary-tree/aa-tree.d.ts +0 -2
- package/dist/types/data-structures/binary-tree/avl-tree.d.ts +0 -21
- package/dist/types/data-structures/binary-tree/b-tree.d.ts +0 -2
- package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -8
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +0 -140
- package/dist/types/data-structures/binary-tree/bst.d.ts +0 -32
- package/dist/types/data-structures/binary-tree/index.d.ts +0 -4
- package/dist/types/data-structures/binary-tree/rb-tree.d.ts +0 -2
- package/dist/types/data-structures/binary-tree/segment-tree.d.ts +0 -33
- package/dist/types/data-structures/binary-tree/splay-tree.d.ts +0 -2
- package/dist/types/data-structures/binary-tree/tree-multiset.d.ts +0 -11
- package/dist/types/data-structures/binary-tree/two-three-tree.d.ts +0 -2
- package/dist/types/data-structures/graph/abstract-graph.d.ts +0 -126
- package/dist/types/data-structures/graph/directed-graph.d.ts +0 -51
- package/dist/types/data-structures/graph/undirected-graph.d.ts +0 -24
- package/dist/types/data-structures/hash/coordinate-map.d.ts +0 -8
- package/dist/types/data-structures/hash/coordinate-set.d.ts +0 -7
- package/dist/types/data-structures/hash/index.d.ts +0 -1
- package/dist/types/data-structures/hash/pair.d.ts +0 -1
- package/dist/types/data-structures/hash/tree-map.d.ts +0 -1
- package/dist/types/data-structures/hash/tree-set.d.ts +0 -1
- package/dist/types/data-structures/heap/heap.d.ts +0 -72
- package/dist/types/data-structures/heap/index.d.ts +0 -3
- package/dist/types/data-structures/heap/max-heap.d.ts +0 -14
- package/dist/types/data-structures/heap/min-heap.d.ts +0 -14
- package/dist/types/data-structures/index.d.ts +0 -9
- package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +0 -59
- package/dist/types/data-structures/linked-list/index.d.ts +0 -2
- package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +0 -358
- package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +0 -1
- package/dist/types/data-structures/matrix/index.d.ts +0 -3
- package/dist/types/data-structures/matrix/matrix.d.ts +0 -9
- package/dist/types/data-structures/matrix/matrix2d.d.ts +0 -25
- package/dist/types/data-structures/matrix/navigator.d.ts +0 -31
- package/dist/types/data-structures/matrix/vector2d.d.ts +0 -74
- package/dist/types/data-structures/priority-queue/index.d.ts +0 -3
- package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +0 -4
- package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +0 -4
- package/dist/types/data-structures/priority-queue/priority-queue.d.ts +0 -36
- package/dist/types/data-structures/queue/deque.d.ts +0 -37
- package/dist/types/data-structures/queue/index.d.ts +0 -1
- package/dist/types/data-structures/queue/queue.d.ts +0 -76
- package/dist/types/data-structures/stack/index.d.ts +0 -1
- package/dist/types/data-structures/stack/stack.d.ts +0 -69
- package/dist/types/data-structures/trampoline.d.ts +0 -25
- package/dist/types/data-structures/trie/index.d.ts +0 -1
- package/dist/types/data-structures/trie/trie.d.ts +0 -28
- package/dist/types/utils.d.ts +0 -46
- package/dist/utils.js +0 -569
- package/src/data-structures/trampoline.ts +0 -91
- package/src/types/index.ts +0 -1
- /package/dist/{types/data-structures/hash/hash-table.d.ts → data-structures/types/singly-linked-list.d.ts} +0 -0
- /package/dist/{types → utils}/index.d.ts +0 -0
- /package/dist/{types → utils}/index.js +0 -0
- /package/dist/{types → utils}/types/index.d.ts +0 -0
- /package/{src/types/patches/index.d.ts → tests/unit/data-structures/graph/abstract-graph.ts} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BSTNode } from '../binary-tree';
|
|
2
|
+
import type { BinaryTreeNodeId } from './binary-tree';
|
|
3
|
+
export type BSTComparator = (a: BinaryTreeNodeId, b: BinaryTreeNodeId) => number;
|
|
4
|
+
export type BSTDeletedResult<T> = {
|
|
5
|
+
deleted: BSTNode<T> | null;
|
|
6
|
+
needBalanced: BSTNode<T> | null;
|
|
7
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { VertexId } from './abstract-graph';
|
|
2
|
+
export interface IDirectedGraph<V, E> {
|
|
3
|
+
incomingEdgesOf(vertex: V): E[];
|
|
4
|
+
outgoingEdgesOf(vertex: V): E[];
|
|
5
|
+
inDegreeOf(vertexOrId: V | VertexId): number;
|
|
6
|
+
outDegreeOf(vertexOrId: V | VertexId): number;
|
|
7
|
+
getEdgeSrc(e: E): V | null;
|
|
8
|
+
getEdgeDest(e: E): V | null;
|
|
9
|
+
}
|
|
10
|
+
export type TopologicalStatus = 0 | 1 | 2;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type DoublyLinkedListGetBy = 'node' | 'val';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './binary-tree';
|
|
2
|
+
export * from './bst';
|
|
3
|
+
export * from './avl-tree';
|
|
4
|
+
export * from './segment-tree';
|
|
5
|
+
export * from './tree-multiset';
|
|
6
|
+
export * from './abstract-graph';
|
|
7
|
+
export * from './directed-graph';
|
|
8
|
+
export * from './priority-queue';
|
|
9
|
+
export * from './heap';
|
|
10
|
+
export * from './singly-linked-list';
|
|
11
|
+
export * from './doubly-linked-list';
|
|
12
|
+
export * from './navigator';
|
|
13
|
+
export * from '../../utils/types/utils';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./binary-tree"), exports);
|
|
18
|
+
__exportStar(require("./bst"), exports);
|
|
19
|
+
__exportStar(require("./avl-tree"), exports);
|
|
20
|
+
__exportStar(require("./segment-tree"), exports);
|
|
21
|
+
__exportStar(require("./tree-multiset"), exports);
|
|
22
|
+
__exportStar(require("./abstract-graph"), exports);
|
|
23
|
+
__exportStar(require("./directed-graph"), exports);
|
|
24
|
+
__exportStar(require("./priority-queue"), exports);
|
|
25
|
+
__exportStar(require("./heap"), exports);
|
|
26
|
+
__exportStar(require("./singly-linked-list"), exports);
|
|
27
|
+
__exportStar(require("./doubly-linked-list"), exports);
|
|
28
|
+
__exportStar(require("./navigator"), exports);
|
|
29
|
+
__exportStar(require("../../utils/types/utils"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type Direction = 'up' | 'right' | 'down' | 'left';
|
|
2
|
+
export type Turning = {
|
|
3
|
+
[key in Direction]: Direction;
|
|
4
|
+
};
|
|
5
|
+
export interface NavigatorParams<T> {
|
|
6
|
+
matrix: T[][];
|
|
7
|
+
turning: Turning;
|
|
8
|
+
onMove: (cur: [number, number]) => void;
|
|
9
|
+
init: {
|
|
10
|
+
cur: [number, number];
|
|
11
|
+
charDir: Direction;
|
|
12
|
+
VISITED: T;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type SegmentTreeNodeVal = number;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright 2030 Tyler Zeng <zrwusa@gmail.com>
|
|
3
|
+
* @license MIT
|
|
4
|
+
*/
|
|
5
|
+
import { Thunk, ToThunkFn, TrlAsyncFn, TrlFn } from './types';
|
|
6
|
+
export declare const THUNK_SYMBOL: unique symbol;
|
|
7
|
+
export declare const isThunk: (fnOrValue: any) => boolean;
|
|
8
|
+
export declare const toThunk: (fn: ToThunkFn) => Thunk;
|
|
9
|
+
export declare const trampoline: (fn: TrlFn) => ((...args: [...Parameters<TrlFn>]) => any) & {
|
|
10
|
+
cont: (...args: [...Parameters<TrlFn>]) => Thunk;
|
|
11
|
+
};
|
|
12
|
+
export declare const trampolineAsync: (fn: TrlAsyncFn) => ((...args: [...Parameters<TrlAsyncFn>]) => Promise<any>) & {
|
|
13
|
+
cont: (...args: [...Parameters<TrlAsyncFn>]) => Thunk;
|
|
14
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
+
if (!m) return o;
|
|
41
|
+
var i = m.call(o), r, ar = [], e;
|
|
42
|
+
try {
|
|
43
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
+
}
|
|
45
|
+
catch (error) { e = { error: error }; }
|
|
46
|
+
finally {
|
|
47
|
+
try {
|
|
48
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
+
}
|
|
50
|
+
finally { if (e) throw e.error; }
|
|
51
|
+
}
|
|
52
|
+
return ar;
|
|
53
|
+
};
|
|
54
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
55
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
56
|
+
if (ar || !(i in from)) {
|
|
57
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
58
|
+
ar[i] = from[i];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
62
|
+
};
|
|
63
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
|
+
exports.trampolineAsync = exports.trampoline = exports.toThunk = exports.isThunk = exports.THUNK_SYMBOL = void 0;
|
|
65
|
+
exports.THUNK_SYMBOL = Symbol('thunk');
|
|
66
|
+
var isThunk = function (fnOrValue) {
|
|
67
|
+
return typeof fnOrValue === 'function' && fnOrValue.__THUNK__ === exports.THUNK_SYMBOL;
|
|
68
|
+
};
|
|
69
|
+
exports.isThunk = isThunk;
|
|
70
|
+
var toThunk = function (fn) {
|
|
71
|
+
var thunk = function () { return fn(); };
|
|
72
|
+
thunk.__THUNK__ = exports.THUNK_SYMBOL;
|
|
73
|
+
return thunk;
|
|
74
|
+
};
|
|
75
|
+
exports.toThunk = toThunk;
|
|
76
|
+
var trampoline = function (fn) {
|
|
77
|
+
var cont = function () {
|
|
78
|
+
var args = [];
|
|
79
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
80
|
+
args[_i] = arguments[_i];
|
|
81
|
+
}
|
|
82
|
+
return (0, exports.toThunk)(function () { return fn.apply(void 0, __spreadArray([], __read(args), false)); });
|
|
83
|
+
};
|
|
84
|
+
return Object.assign(function () {
|
|
85
|
+
var args = [];
|
|
86
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
87
|
+
args[_i] = arguments[_i];
|
|
88
|
+
}
|
|
89
|
+
var result = fn.apply(void 0, __spreadArray([], __read(args), false));
|
|
90
|
+
while ((0, exports.isThunk)(result) && typeof result === 'function') {
|
|
91
|
+
result = result();
|
|
92
|
+
}
|
|
93
|
+
return result;
|
|
94
|
+
}, { cont: cont });
|
|
95
|
+
};
|
|
96
|
+
exports.trampoline = trampoline;
|
|
97
|
+
var trampolineAsync = function (fn) {
|
|
98
|
+
var cont = function () {
|
|
99
|
+
var args = [];
|
|
100
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
101
|
+
args[_i] = arguments[_i];
|
|
102
|
+
}
|
|
103
|
+
return (0, exports.toThunk)(function () { return fn.apply(void 0, __spreadArray([], __read(args), false)); });
|
|
104
|
+
};
|
|
105
|
+
return Object.assign(function () {
|
|
106
|
+
var args = [];
|
|
107
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
108
|
+
args[_i] = arguments[_i];
|
|
109
|
+
}
|
|
110
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
111
|
+
var result;
|
|
112
|
+
return __generator(this, function (_a) {
|
|
113
|
+
switch (_a.label) {
|
|
114
|
+
case 0: return [4 /*yield*/, fn.apply(void 0, __spreadArray([], __read(args), false))];
|
|
115
|
+
case 1:
|
|
116
|
+
result = _a.sent();
|
|
117
|
+
_a.label = 2;
|
|
118
|
+
case 2:
|
|
119
|
+
if (!((0, exports.isThunk)(result) && typeof result === 'function')) return [3 /*break*/, 4];
|
|
120
|
+
return [4 /*yield*/, result()];
|
|
121
|
+
case 3:
|
|
122
|
+
result = _a.sent();
|
|
123
|
+
return [3 /*break*/, 2];
|
|
124
|
+
case 4: return [2 /*return*/, result];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}, { cont: cont });
|
|
129
|
+
};
|
|
130
|
+
exports.trampolineAsync = trampolineAsync;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./utils"), exports);
|
|
@@ -26,8 +26,8 @@ export type DebounceOptions = {
|
|
|
26
26
|
maxWait?: number;
|
|
27
27
|
};
|
|
28
28
|
export interface DebouncedFunction<F extends Procedure> {
|
|
29
|
-
(this: ThisParameterType<F>, ...args: Parameters<F>): void;
|
|
30
29
|
cancel: () => void;
|
|
30
|
+
(this: ThisParameterType<F>, ...args: [...Parameters<F>]): void;
|
|
31
31
|
}
|
|
32
32
|
export type MonthKey = 'January' | 'February' | 'March' | 'April' | 'May' | 'June' | 'July' | 'August' | 'September' | 'October' | 'November' | 'December';
|
|
33
33
|
export type Month = {
|
|
@@ -44,3 +44,17 @@ export declare class TreeNode<T> {
|
|
|
44
44
|
getHeight(): number;
|
|
45
45
|
}
|
|
46
46
|
export type OrderType = 'InOrder' | 'PreOrder' | 'PostOrder';
|
|
47
|
+
export type DeepProxy<T> = T extends (...args: any[]) => infer R ? (...args: [...Parameters<T>]) => DeepProxy<R> : T extends object ? {
|
|
48
|
+
[K in keyof T]: DeepProxy<T[K]>;
|
|
49
|
+
} : T;
|
|
50
|
+
export type DeepProxyOnChange = (target: any, property: string | symbol, value: any, receiver: any, descriptor: any, result: any) => void;
|
|
51
|
+
export type DeepProxyOnGet = (target: any, property: string | symbol, value: any, receiver: any, descriptor: any, result: any) => void;
|
|
52
|
+
export type CurryFunc<T> = T extends (...args: infer Args) => infer R ? Args extends [infer Arg, ...infer RestArgs] ? (arg: Arg) => CurryFunc<(...args: RestArgs) => R> : R : T;
|
|
53
|
+
export type ToThunkFn = () => ReturnType<TrlFn>;
|
|
54
|
+
declare const THUNK_SYMBOL: unique symbol;
|
|
55
|
+
export type Thunk = () => ReturnType<ToThunkFn> & {
|
|
56
|
+
__THUNK__: typeof THUNK_SYMBOL;
|
|
57
|
+
};
|
|
58
|
+
export type TrlFn = (...args: any[]) => any;
|
|
59
|
+
export type TrlAsyncFn = (...args: any[]) => any;
|
|
60
|
+
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TreeNode = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
var arr = ['1', 2, 4, 5, 6];
|
|
5
|
+
var a = 2;
|
|
6
|
+
var TreeNode = /** @class */ (function () {
|
|
7
|
+
function TreeNode(id, name, value, children) {
|
|
8
8
|
this.id = id;
|
|
9
9
|
this.name = name || '';
|
|
10
10
|
this.value = value || undefined;
|
|
@@ -18,36 +18,38 @@ class TreeNode {
|
|
|
18
18
|
// set name (name: string | undefined) {
|
|
19
19
|
// this.name = name;
|
|
20
20
|
// }
|
|
21
|
-
addChildren(children) {
|
|
21
|
+
TreeNode.prototype.addChildren = function (children) {
|
|
22
22
|
if (!this.children) {
|
|
23
23
|
this.children = [];
|
|
24
24
|
}
|
|
25
|
-
if (children instanceof
|
|
26
|
-
this.children
|
|
25
|
+
if (children instanceof TreeNode) {
|
|
26
|
+
this.children.push(children);
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
|
-
this.children.
|
|
29
|
+
this.children = this.children.concat(children);
|
|
30
30
|
}
|
|
31
|
-
}
|
|
32
|
-
getHeight() {
|
|
31
|
+
};
|
|
32
|
+
TreeNode.prototype.getHeight = function () {
|
|
33
33
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
var beginRoot = this;
|
|
35
|
+
var maxDepth = 1;
|
|
36
36
|
if (beginRoot) {
|
|
37
|
-
|
|
37
|
+
var bfs_1 = function (node, level) {
|
|
38
38
|
if (level > maxDepth) {
|
|
39
39
|
maxDepth = level;
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
var children = node.children;
|
|
42
42
|
if (children) {
|
|
43
|
-
for (
|
|
44
|
-
|
|
43
|
+
for (var i = 0, len = children.length; i < len; i++) {
|
|
44
|
+
bfs_1(children[i], level + 1);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
|
|
48
|
+
bfs_1(beginRoot, 1);
|
|
49
49
|
}
|
|
50
50
|
return maxDepth;
|
|
51
|
-
}
|
|
52
|
-
|
|
51
|
+
};
|
|
52
|
+
return TreeNode;
|
|
53
|
+
}());
|
|
53
54
|
exports.TreeNode = TreeNode;
|
|
55
|
+
var THUNK_SYMBOL = Symbol('thunk');
|
|
@@ -21,12 +21,14 @@ export declare const looseEqual: (a: any, b: any) => boolean;
|
|
|
21
21
|
export declare const strictEqual: (a: any, b: any) => boolean;
|
|
22
22
|
export declare const strictObjectIsEqual: (a: any, b: any) => boolean;
|
|
23
23
|
export declare const deepObjectStrictEqual: (object1: JSONSerializable, object2: JSONSerializable) => boolean;
|
|
24
|
-
export declare const isTypeEqual: <T>(obj: unknown) => void;
|
|
25
24
|
export declare function reverseColor(oldColor: string): string;
|
|
26
25
|
export declare const isSameStructure: (objA: unknown, objB: unknown) => boolean;
|
|
27
26
|
export declare const isLeafParent: (obj: JSONObject) => boolean;
|
|
28
27
|
export declare const addDays: (date: Date, days: number) => Date;
|
|
29
28
|
export declare class WaitManager {
|
|
29
|
+
private _time30;
|
|
30
|
+
private readonly _nXSpeed;
|
|
31
|
+
constructor(nXSpeed?: number);
|
|
30
32
|
private _time1;
|
|
31
33
|
get time1(): number;
|
|
32
34
|
private _time2;
|
|
@@ -39,32 +41,14 @@ export declare class WaitManager {
|
|
|
39
41
|
get time10(): number;
|
|
40
42
|
private _time20;
|
|
41
43
|
get time20(): number;
|
|
42
|
-
private _time30;
|
|
43
44
|
get time50(): number;
|
|
44
45
|
private _time60;
|
|
45
46
|
get time60(): number;
|
|
46
47
|
private _cusTime;
|
|
47
48
|
get cusTime(): number;
|
|
48
49
|
set cusTime(v: number);
|
|
49
|
-
private readonly _nXSpeed;
|
|
50
|
-
constructor(nXSpeed?: number);
|
|
51
50
|
}
|
|
52
51
|
export declare const wait: (ms: number, resolveValue?: any) => Promise<unknown>;
|
|
53
|
-
export declare class AuthAPIError extends Error {
|
|
54
|
-
protected serverErrorStack: string | undefined;
|
|
55
|
-
protected serverErrorCode: string | undefined;
|
|
56
|
-
constructor(serverErrorMessage: string, serverErrorCode?: string, serverErrorStack?: string);
|
|
57
|
-
}
|
|
58
|
-
export declare class BunnyAPIError extends Error {
|
|
59
|
-
protected serverErrorStack: string | undefined;
|
|
60
|
-
protected serverErrorCode: string | undefined;
|
|
61
|
-
constructor(serverErrorMessage: string, serverErrorCode?: string, serverErrorStack?: string);
|
|
62
|
-
}
|
|
63
|
-
export declare class NomicsAPIError extends Error {
|
|
64
|
-
protected serverErrorStack: string | undefined;
|
|
65
|
-
protected serverErrorCode: string | undefined;
|
|
66
|
-
constructor(serverErrorMessage: string, serverErrorCode?: string, serverErrorStack?: string);
|
|
67
|
-
}
|
|
68
52
|
export declare function extractValue<Item>(data: {
|
|
69
53
|
key: string;
|
|
70
54
|
value: Item;
|
|
@@ -92,8 +76,8 @@ export declare class StringUtil {
|
|
|
92
76
|
static toPathCase(str: string): string;
|
|
93
77
|
static toDotCase(str: string): string;
|
|
94
78
|
}
|
|
95
|
-
type
|
|
96
|
-
export declare const deepKeysConvert: (obj: any, toType?:
|
|
79
|
+
export type CaseType = 'camel' | 'snake' | 'pascal' | 'constant' | 'kebab' | 'lower' | 'title' | 'sentence' | 'path' | 'dot';
|
|
80
|
+
export declare const deepKeysConvert: (obj: any, toType?: CaseType) => any;
|
|
97
81
|
export declare const deepRemoveByKey: (obj: any, keysToBeRemoved: string[]) => any;
|
|
98
82
|
export declare const deepRenameKeys: (obj: JSONSerializable, keysMap: {
|
|
99
83
|
[x: string]: string;
|
|
@@ -119,4 +103,3 @@ export declare function zip<T = number, T1 = number>(array1: T[], array2: T1[],
|
|
|
119
103
|
x: T;
|
|
120
104
|
y: T1;
|
|
121
105
|
}[];
|
|
122
|
-
export {};
|