data-structure-typed 0.9.16 → 1.3.1
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/LICENSE +21 -0
- package/README.md +665 -172
- package/dist/bundle.js +2 -0
- package/dist/bundle.js.LICENSE.txt +13 -0
- package/dist/data-structures/binary-tree/aa-tree.js +2 -5
- package/dist/data-structures/binary-tree/abstract-binary-tree.d.ts +364 -0
- package/dist/data-structures/binary-tree/abstract-binary-tree.js +1308 -0
- package/dist/data-structures/binary-tree/avl-tree.d.ts +85 -14
- package/dist/data-structures/binary-tree/avl-tree.js +142 -116
- package/dist/data-structures/binary-tree/b-tree.js +2 -5
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +39 -1
- package/dist/data-structures/binary-tree/binary-indexed-tree.js +54 -13
- package/dist/data-structures/binary-tree/binary-tree.d.ts +29 -126
- package/dist/data-structures/binary-tree/binary-tree.js +31 -1093
- package/dist/data-structures/binary-tree/bst.d.ts +117 -23
- package/dist/data-structures/binary-tree/bst.js +233 -240
- package/dist/data-structures/binary-tree/index.d.ts +1 -0
- package/dist/data-structures/binary-tree/index.js +1 -0
- package/dist/data-structures/binary-tree/rb-tree.d.ts +18 -1
- package/dist/data-structures/binary-tree/rb-tree.js +40 -5
- package/dist/data-structures/binary-tree/segment-tree.d.ts +61 -11
- package/dist/data-structures/binary-tree/segment-tree.js +126 -93
- package/dist/data-structures/binary-tree/splay-tree.js +2 -5
- package/dist/data-structures/binary-tree/tree-multiset.d.ts +213 -6
- package/dist/data-structures/binary-tree/tree-multiset.js +687 -34
- package/dist/data-structures/binary-tree/two-three-tree.js +2 -5
- package/dist/data-structures/graph/abstract-graph.d.ts +270 -36
- package/dist/data-structures/graph/abstract-graph.js +610 -572
- package/dist/data-structures/graph/directed-graph.d.ts +173 -16
- package/dist/data-structures/graph/directed-graph.js +345 -313
- package/dist/data-structures/graph/index.d.ts +1 -0
- package/dist/data-structures/graph/index.js +1 -0
- package/dist/data-structures/graph/map-graph.d.ts +79 -0
- package/dist/data-structures/graph/map-graph.js +111 -0
- package/dist/data-structures/graph/undirected-graph.d.ts +111 -9
- package/dist/data-structures/graph/undirected-graph.js +203 -178
- package/dist/data-structures/hash/coordinate-map.d.ts +38 -1
- package/dist/data-structures/hash/coordinate-map.js +59 -36
- package/dist/data-structures/hash/coordinate-set.d.ts +32 -2
- package/dist/data-structures/hash/coordinate-set.js +49 -33
- package/dist/data-structures/hash/hash-table.d.ts +2 -1
- package/dist/data-structures/hash/hash-table.js +4 -0
- package/dist/data-structures/hash/pair.d.ts +2 -1
- package/dist/data-structures/hash/pair.js +4 -0
- package/dist/data-structures/hash/tree-map.d.ts +2 -1
- package/dist/data-structures/hash/tree-map.js +4 -0
- package/dist/data-structures/hash/tree-set.d.ts +2 -1
- package/dist/data-structures/hash/tree-set.js +4 -0
- package/dist/data-structures/heap/heap.d.ts +62 -45
- package/dist/data-structures/heap/heap.js +124 -86
- package/dist/data-structures/heap/max-heap.d.ts +13 -5
- package/dist/data-structures/heap/max-heap.js +18 -28
- package/dist/data-structures/heap/min-heap.d.ts +14 -5
- package/dist/data-structures/heap/min-heap.js +19 -28
- package/dist/data-structures/index.d.ts +1 -1
- package/dist/data-structures/index.js +1 -1
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +193 -56
- package/dist/data-structures/linked-list/doubly-linked-list.js +484 -220
- package/dist/data-structures/linked-list/index.d.ts +1 -0
- package/dist/data-structures/linked-list/index.js +1 -0
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +117 -315
- package/dist/data-structures/linked-list/singly-linked-list.js +374 -727
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +2 -1
- package/dist/data-structures/linked-list/skip-linked-list.js +4 -0
- package/dist/data-structures/matrix/matrix.d.ts +12 -0
- package/dist/data-structures/matrix/matrix.js +21 -8
- package/dist/data-structures/matrix/matrix2d.d.ts +85 -2
- package/dist/data-structures/matrix/matrix2d.js +146 -80
- package/dist/data-structures/matrix/navigator.d.ts +36 -1
- package/dist/data-structures/matrix/navigator.js +46 -37
- package/dist/data-structures/matrix/vector2d.d.ts +142 -15
- package/dist/data-structures/matrix/vector2d.js +215 -109
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +12 -2
- package/dist/data-structures/priority-queue/max-priority-queue.js +33 -26
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +12 -2
- package/dist/data-structures/priority-queue/min-priority-queue.js +34 -26
- package/dist/data-structures/priority-queue/priority-queue.d.ts +153 -3
- package/dist/data-structures/priority-queue/priority-queue.js +244 -143
- package/dist/data-structures/queue/deque.d.ts +141 -13
- package/dist/data-structures/queue/deque.js +200 -82
- package/dist/data-structures/queue/queue.d.ts +65 -38
- package/dist/data-structures/queue/queue.js +110 -66
- package/dist/data-structures/stack/stack.d.ts +27 -32
- package/dist/data-structures/stack/stack.js +47 -53
- package/dist/data-structures/tree/index.d.ts +1 -0
- package/dist/data-structures/tree/index.js +17 -0
- package/dist/data-structures/tree/tree.d.ts +14 -0
- package/dist/data-structures/tree/tree.js +60 -0
- package/dist/data-structures/trie/trie.d.ts +33 -10
- package/dist/data-structures/trie/trie.js +123 -208
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/interfaces/abstract-binary-tree.d.ts +90 -0
- package/dist/interfaces/abstract-graph.d.ts +17 -0
- package/dist/interfaces/avl-tree.d.ts +9 -0
- package/dist/interfaces/binary-tree.d.ts +6 -0
- package/dist/interfaces/bst.d.ts +17 -0
- package/dist/interfaces/directed-graph.d.ts +12 -0
- package/{src/data-structures/types/index.ts → dist/interfaces/index.d.ts} +10 -8
- package/dist/interfaces/index.js +31 -0
- package/{src/data-structures/hash/hash-table.ts → dist/interfaces/priority-queue.d.ts} +1 -1
- package/dist/interfaces/rb-tree.d.ts +8 -0
- package/dist/interfaces/segment-tree.d.ts +1 -0
- package/dist/interfaces/singly-linked-list.d.ts +1 -0
- package/dist/interfaces/singly-linked-list.js +2 -0
- package/dist/interfaces/tree-multiset.d.ts +7 -0
- package/dist/interfaces/tree-multiset.js +2 -0
- package/dist/interfaces/undirected-graph.d.ts +5 -0
- package/dist/interfaces/undirected-graph.js +2 -0
- package/dist/types/data-structures/abstract-binary-tree.d.ts +34 -0
- package/dist/types/data-structures/abstract-binary-tree.js +25 -0
- package/dist/types/data-structures/abstract-graph.d.ts +11 -0
- package/dist/types/data-structures/abstract-graph.js +2 -0
- package/dist/types/data-structures/avl-tree.d.ts +4 -0
- package/dist/types/data-structures/avl-tree.js +2 -0
- package/dist/types/data-structures/binary-tree.d.ts +4 -0
- package/dist/types/data-structures/binary-tree.js +2 -0
- package/dist/types/data-structures/bst.d.ts +13 -0
- package/dist/types/data-structures/bst.js +9 -0
- package/dist/types/data-structures/directed-graph.d.ts +6 -0
- package/dist/types/data-structures/directed-graph.js +9 -0
- package/dist/types/data-structures/doubly-linked-list.d.ts +1 -0
- package/dist/types/data-structures/doubly-linked-list.js +2 -0
- package/dist/types/data-structures/heap.d.ts +3 -0
- package/dist/types/data-structures/heap.js +2 -0
- package/dist/{data-structures/types → types/data-structures}/index.d.ts +3 -1
- package/dist/{data-structures/types → types/data-structures}/index.js +3 -1
- package/dist/types/data-structures/map-graph.d.ts +1 -0
- package/dist/types/data-structures/map-graph.js +2 -0
- package/dist/{data-structures/types → types/data-structures}/navigator.d.ts +2 -2
- package/dist/types/data-structures/navigator.js +2 -0
- package/dist/{data-structures/types → types/data-structures}/priority-queue.d.ts +2 -2
- package/dist/types/data-structures/priority-queue.js +2 -0
- package/dist/types/data-structures/rb-tree.d.ts +8 -0
- package/dist/types/data-structures/rb-tree.js +8 -0
- package/dist/types/data-structures/segment-tree.js +2 -0
- package/dist/types/data-structures/singly-linked-list.d.ts +1 -0
- package/dist/types/data-structures/singly-linked-list.js +2 -0
- package/dist/types/data-structures/tree-multiset.d.ts +4 -0
- package/dist/types/data-structures/tree-multiset.js +2 -0
- package/dist/types/helpers.d.ts +1 -0
- package/dist/types/helpers.js +2 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +19 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/index.js +18 -0
- package/dist/types/utils/utils.d.ts +7 -0
- package/dist/types/utils/utils.js +2 -0
- package/dist/types/utils/validate-type.d.ts +19 -0
- package/dist/types/utils/validate-type.js +2 -0
- package/dist/utils/utils.d.ts +17 -103
- package/dist/utils/utils.js +40 -625
- package/package.json +134 -23
- package/.idea/data-structure-typed.iml +0 -12
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/dist/data-structures/trampoline.d.ts +0 -16
- package/dist/data-structures/trampoline.js +0 -130
- package/dist/data-structures/types/abstract-graph.d.ts +0 -29
- package/dist/data-structures/types/avl-tree.d.ts +0 -5
- package/dist/data-structures/types/binary-tree.d.ts +0 -16
- package/dist/data-structures/types/bst.d.ts +0 -7
- package/dist/data-structures/types/directed-graph.d.ts +0 -10
- package/dist/data-structures/types/doubly-linked-list.d.ts +0 -1
- package/dist/data-structures/types/heap.d.ts +0 -7
- package/dist/data-structures/types/singly-linked-list.d.ts +0 -5
- package/dist/data-structures/types/tree-multiset.d.ts +0 -5
- package/dist/data-structures/types/utils.d.ts +0 -52
- package/dist/data-structures/types/utils.js +0 -54
- package/src/data-structures/binary-tree/aa-tree.ts +0 -3
- package/src/data-structures/binary-tree/avl-tree.ts +0 -227
- package/src/data-structures/binary-tree/b-tree.ts +0 -3
- package/src/data-structures/binary-tree/binary-indexed-tree.ts +0 -33
- package/src/data-structures/binary-tree/binary-tree.ts +0 -1133
- package/src/data-structures/binary-tree/bst.ts +0 -395
- 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/index.ts +0 -11
- package/src/data-structures/binary-tree/rb-tree.ts +0 -3
- package/src/data-structures/binary-tree/segment-tree.ts +0 -172
- package/src/data-structures/binary-tree/splay-tree.ts +0 -3
- package/src/data-structures/binary-tree/tree-multiset.ts +0 -18
- package/src/data-structures/binary-tree/two-three-tree.ts +0 -3
- package/src/data-structures/diagrams/README.md +0 -7
- package/src/data-structures/graph/abstract-graph.ts +0 -753
- package/src/data-structures/graph/diagrams/adjacency-list-pros-cons.png +0 -0
- package/src/data-structures/graph/diagrams/adjacency-list.png +0 -0
- package/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.png +0 -0
- package/src/data-structures/graph/diagrams/adjacency-matrix.png +0 -0
- package/src/data-structures/graph/diagrams/dfs-can-do.png +0 -0
- package/src/data-structures/graph/diagrams/edge-list-pros-cons.png +0 -0
- package/src/data-structures/graph/diagrams/edge-list.png +0 -0
- package/src/data-structures/graph/diagrams/max-flow.png +0 -0
- package/src/data-structures/graph/diagrams/mst.png +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/directed-graph.ts +0 -306
- package/src/data-structures/graph/index.ts +0 -3
- package/src/data-structures/graph/undirected-graph.ts +0 -155
- package/src/data-structures/hash/coordinate-map.ts +0 -24
- package/src/data-structures/hash/coordinate-set.ts +0 -20
- package/src/data-structures/hash/index.ts +0 -6
- package/src/data-structures/heap/heap.ts +0 -127
- package/src/data-structures/heap/index.ts +0 -3
- package/src/data-structures/heap/max-heap.ts +0 -23
- package/src/data-structures/heap/min-heap.ts +0 -25
- package/src/data-structures/index.ts +0 -12
- package/src/data-structures/linked-list/doubly-linked-list.ts +0 -250
- package/src/data-structures/linked-list/index.ts +0 -2
- package/src/data-structures/linked-list/singly-linked-list.ts +0 -736
- package/src/data-structures/linked-list/skip-linked-list.ts +0 -1
- package/src/data-structures/matrix/index.ts +0 -4
- package/src/data-structures/matrix/matrix.ts +0 -13
- package/src/data-structures/matrix/matrix2d.ts +0 -125
- package/src/data-structures/matrix/navigator.ts +0 -87
- package/src/data-structures/matrix/vector2d.ts +0 -189
- package/src/data-structures/priority-queue/index.ts +0 -3
- package/src/data-structures/priority-queue/max-priority-queue.ts +0 -13
- package/src/data-structures/priority-queue/min-priority-queue.ts +0 -13
- package/src/data-structures/priority-queue/priority-queue.ts +0 -200
- package/src/data-structures/queue/deque.ts +0 -139
- package/src/data-structures/queue/index.ts +0 -2
- package/src/data-structures/queue/queue.ts +0 -122
- package/src/data-structures/stack/index.ts +0 -1
- package/src/data-structures/stack/stack.ts +0 -103
- package/src/data-structures/trampoline.ts +0 -51
- package/src/data-structures/trie/index.ts +0 -1
- package/src/data-structures/trie/trie.ts +0 -203
- package/src/data-structures/types/abstract-graph.ts +0 -51
- package/src/data-structures/types/avl-tree.ts +0 -6
- package/src/data-structures/types/binary-tree.ts +0 -15
- package/src/data-structures/types/bst.ts +0 -5
- package/src/data-structures/types/directed-graph.ts +0 -18
- package/src/data-structures/types/doubly-linked-list.ts +0 -1
- package/src/data-structures/types/heap.ts +0 -8
- package/src/data-structures/types/navigator.ts +0 -12
- package/src/data-structures/types/priority-queue.ts +0 -9
- package/src/data-structures/types/segment-tree.ts +0 -1
- package/src/data-structures/types/singly-linked-list.ts +0 -15
- package/src/data-structures/types/tree-multiset.ts +0 -3
- package/src/data-structures/types/utils.ts +0 -173
- package/src/index.ts +0 -1
- package/src/utils/index.ts +0 -1
- package/src/utils/utils.ts +0 -505
- package/tsconfig.json +0 -56
- /package/dist/{data-structures/types/abstract-graph.js → interfaces/abstract-binary-tree.js} +0 -0
- /package/dist/{data-structures/types/avl-tree.js → interfaces/abstract-graph.js} +0 -0
- /package/dist/{data-structures/types/binary-tree.js → interfaces/avl-tree.js} +0 -0
- /package/dist/{data-structures/types/bst.js → interfaces/binary-tree.js} +0 -0
- /package/dist/{data-structures/types/directed-graph.js → interfaces/bst.js} +0 -0
- /package/dist/{data-structures/types/doubly-linked-list.js → interfaces/directed-graph.js} +0 -0
- /package/{src/data-structures/hash/pair.ts → dist/interfaces/doubly-linked-list.d.ts} +0 -0
- /package/dist/{data-structures/types/heap.js → interfaces/doubly-linked-list.js} +0 -0
- /package/{src/data-structures/hash/tree-map.ts → dist/interfaces/heap.d.ts} +0 -0
- /package/dist/{data-structures/types/navigator.js → interfaces/heap.js} +0 -0
- /package/{src/data-structures/hash/tree-set.ts → dist/interfaces/navigator.d.ts} +0 -0
- /package/dist/{data-structures/types/priority-queue.js → interfaces/navigator.js} +0 -0
- /package/dist/{data-structures/types/segment-tree.js → interfaces/priority-queue.js} +0 -0
- /package/dist/{data-structures/types/singly-linked-list.js → interfaces/rb-tree.js} +0 -0
- /package/dist/{data-structures/types/tree-multiset.js → interfaces/segment-tree.js} +0 -0
- /package/dist/{data-structures/types → types/data-structures}/segment-tree.d.ts +0 -0
package/dist/utils/utils.js
CHANGED
|
@@ -1,38 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -42,569 +8,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
42
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
9
|
});
|
|
44
10
|
};
|
|
45
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
-
function step(op) {
|
|
50
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
52
|
-
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;
|
|
53
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
-
switch (op[0]) {
|
|
55
|
-
case 0: case 1: t = op; break;
|
|
56
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
-
default:
|
|
60
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
-
if (t[2]) _.ops.pop();
|
|
65
|
-
_.trys.pop(); continue;
|
|
66
|
-
}
|
|
67
|
-
op = body.call(thisArg, _);
|
|
68
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
var __values = (this && this.__values) || function(o) {
|
|
73
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
74
|
-
if (m) return m.call(o);
|
|
75
|
-
if (o && typeof o.length === "number") return {
|
|
76
|
-
next: function () {
|
|
77
|
-
if (o && i >= o.length) o = void 0;
|
|
78
|
-
return { value: o && o[i++], done: !o };
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
82
|
-
};
|
|
83
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
84
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
85
|
-
if (!m) return o;
|
|
86
|
-
var i = m.call(o), r, ar = [], e;
|
|
87
|
-
try {
|
|
88
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
89
|
-
}
|
|
90
|
-
catch (error) { e = { error: error }; }
|
|
91
|
-
finally {
|
|
92
|
-
try {
|
|
93
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
94
|
-
}
|
|
95
|
-
finally { if (e) throw e.error; }
|
|
96
|
-
}
|
|
97
|
-
return ar;
|
|
98
|
-
};
|
|
99
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
100
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
101
|
-
if (ar || !(i in from)) {
|
|
102
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
103
|
-
ar[i] = from[i];
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
107
|
-
};
|
|
108
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
109
|
-
exports.
|
|
110
|
-
|
|
111
|
-
function randomText(length) {
|
|
112
|
-
var result = '';
|
|
113
|
-
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
114
|
-
var charactersLength = characters.length;
|
|
115
|
-
for (var i = 0; i < length; i++) {
|
|
116
|
-
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
117
|
-
}
|
|
118
|
-
return result;
|
|
119
|
-
}
|
|
120
|
-
exports.randomText = randomText;
|
|
121
|
-
var uuidV4 = function () {
|
|
12
|
+
exports.trampolineAsync = exports.trampoline = exports.toThunk = exports.isThunk = exports.THUNK_SYMBOL = exports.arrayRemove = exports.uuidV4 = void 0;
|
|
13
|
+
const uuidV4 = function () {
|
|
122
14
|
return 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function (c) {
|
|
123
|
-
|
|
15
|
+
const r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
|
124
16
|
return v.toString(16);
|
|
125
17
|
});
|
|
126
18
|
};
|
|
127
19
|
exports.uuidV4 = uuidV4;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
this._id = this._prefix + '0';
|
|
132
|
-
}
|
|
133
|
-
IncrementId.prototype.getId = function () {
|
|
134
|
-
var _a = this, _id = _a._id, _prefix = _a._prefix;
|
|
135
|
-
if (!_id) {
|
|
136
|
-
this._id = _prefix + '0';
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
var idNumStr = _id.substr(_prefix.length, _id.length - _prefix.length);
|
|
140
|
-
var newIdNum = parseInt(idNumStr, 10) + 1;
|
|
141
|
-
this._id = _prefix + newIdNum.toString();
|
|
142
|
-
}
|
|
143
|
-
return this._id;
|
|
144
|
-
};
|
|
145
|
-
return IncrementId;
|
|
146
|
-
}());
|
|
147
|
-
exports.IncrementId = IncrementId;
|
|
148
|
-
function incrementId(prefix) {
|
|
149
|
-
var _prefix = prefix ? prefix : '';
|
|
150
|
-
var _id = _prefix + '0';
|
|
151
|
-
return function id() {
|
|
152
|
-
var idNumStr = _id.substr(_prefix.length, _id.length - _prefix.length);
|
|
153
|
-
var newIdNum = parseInt(idNumStr, 10) + 1;
|
|
154
|
-
_id = _prefix + newIdNum.toString();
|
|
155
|
-
return _id;
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
exports.incrementId = incrementId;
|
|
159
|
-
var getValue = function (obj, names) { return names.map(function (i) { return obj[i]; }); };
|
|
160
|
-
exports.getValue = getValue;
|
|
161
|
-
var isObject = function (object) { return object != null && typeof object === 'object'; };
|
|
162
|
-
exports.isObject = isObject;
|
|
163
|
-
var looseEqual = function (a, b) { return a == b; };
|
|
164
|
-
exports.looseEqual = looseEqual;
|
|
165
|
-
var strictEqual = function (a, b) { return a === b; };
|
|
166
|
-
exports.strictEqual = strictEqual;
|
|
167
|
-
var strictObjectIsEqual = function (a, b) { return Object.is(a, b); };
|
|
168
|
-
exports.strictObjectIsEqual = strictObjectIsEqual;
|
|
169
|
-
var deepObjectStrictEqual = function (object1, object2) {
|
|
170
|
-
var e_1, _a;
|
|
171
|
-
var keys1 = Object.keys(object1);
|
|
172
|
-
var keys2 = Object.keys(object2);
|
|
173
|
-
if (keys1.length !== keys2.length) {
|
|
174
|
-
return false;
|
|
175
|
-
}
|
|
176
|
-
try {
|
|
177
|
-
for (var keys1_1 = __values(keys1), keys1_1_1 = keys1_1.next(); !keys1_1_1.done; keys1_1_1 = keys1_1.next()) {
|
|
178
|
-
var key = keys1_1_1.value;
|
|
179
|
-
var val1 = object1[key];
|
|
180
|
-
var val2 = object2[key];
|
|
181
|
-
var areObjects = (0, exports.isObject)(val1) && (0, exports.isObject)(val2);
|
|
182
|
-
if (areObjects && !(0, exports.deepObjectStrictEqual)(val1, val2) ||
|
|
183
|
-
!areObjects && val1 !== val2) {
|
|
184
|
-
return false;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
189
|
-
finally {
|
|
190
|
-
try {
|
|
191
|
-
if (keys1_1_1 && !keys1_1_1.done && (_a = keys1_1.return)) _a.call(keys1_1);
|
|
192
|
-
}
|
|
193
|
-
finally { if (e_1) throw e_1.error; }
|
|
194
|
-
}
|
|
195
|
-
return true;
|
|
196
|
-
};
|
|
197
|
-
exports.deepObjectStrictEqual = deepObjectStrictEqual;
|
|
198
|
-
function reverseColor(oldColor) {
|
|
199
|
-
var oldColorTemp = '0x' + oldColor.replace(/#/g, '');
|
|
200
|
-
var str = '000000' + (0xFFFFFF - Number(oldColorTemp)).toString(16);
|
|
201
|
-
return '#' + str.substring(str.length - 6, str.length);
|
|
202
|
-
}
|
|
203
|
-
exports.reverseColor = reverseColor;
|
|
204
|
-
var isSameStructure = function (objA, objB) {
|
|
205
|
-
var objATraversable = objA;
|
|
206
|
-
var objBTraversable = objB;
|
|
207
|
-
var objAKeys = Object.keys(objATraversable);
|
|
208
|
-
var objBKeys = Object.keys(objBTraversable);
|
|
209
|
-
var isSame = true;
|
|
210
|
-
if (objAKeys.length !== objBKeys.length) {
|
|
211
|
-
return isSame = false;
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
objAKeys.forEach(function (i) {
|
|
215
|
-
if (!objBKeys.includes(i)) {
|
|
216
|
-
return isSame = false;
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
return isSame;
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
exports.isSameStructure = isSameStructure;
|
|
223
|
-
var isLeafParent = function (obj) {
|
|
224
|
-
var isLeaf = true;
|
|
225
|
-
Object.values(obj).forEach(function (value) {
|
|
226
|
-
if (typeof value === 'object' && value instanceof Array) {
|
|
227
|
-
value.forEach(function (item) {
|
|
228
|
-
if (typeof item === 'object') {
|
|
229
|
-
return false;
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
return isLeaf = true;
|
|
233
|
-
}
|
|
234
|
-
if (!['string', 'boolean', 'number', 'undefined', 'function'].includes(typeof value) && (value !== null)) {
|
|
235
|
-
return isLeaf = false;
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
return isLeaf;
|
|
239
|
-
};
|
|
240
|
-
exports.isLeafParent = isLeafParent;
|
|
241
|
-
var addDays = function (date, days) {
|
|
242
|
-
date.setDate(date.getDate() + days);
|
|
243
|
-
return date;
|
|
244
|
-
};
|
|
245
|
-
exports.addDays = addDays;
|
|
246
|
-
var WaitManager = /** @class */ (function () {
|
|
247
|
-
function WaitManager(nXSpeed) {
|
|
248
|
-
this._time30 = 20000;
|
|
249
|
-
this._nXSpeed = 1;
|
|
250
|
-
this._time1 = 1000;
|
|
251
|
-
this._time2 = 2000;
|
|
252
|
-
this._time3 = 3000;
|
|
253
|
-
this._time4 = 4000;
|
|
254
|
-
this._time10 = 10000;
|
|
255
|
-
this._time20 = 20000;
|
|
256
|
-
this._time60 = 60000;
|
|
257
|
-
this._cusTime = 1000;
|
|
258
|
-
if (nXSpeed === undefined)
|
|
259
|
-
nXSpeed = 1;
|
|
260
|
-
this._nXSpeed = nXSpeed;
|
|
261
|
-
}
|
|
262
|
-
Object.defineProperty(WaitManager.prototype, "time1", {
|
|
263
|
-
get: function () {
|
|
264
|
-
return this._time1 / this._nXSpeed;
|
|
265
|
-
},
|
|
266
|
-
enumerable: false,
|
|
267
|
-
configurable: true
|
|
268
|
-
});
|
|
269
|
-
Object.defineProperty(WaitManager.prototype, "time2", {
|
|
270
|
-
get: function () {
|
|
271
|
-
return this._time2 / this._nXSpeed;
|
|
272
|
-
},
|
|
273
|
-
enumerable: false,
|
|
274
|
-
configurable: true
|
|
275
|
-
});
|
|
276
|
-
Object.defineProperty(WaitManager.prototype, "time3", {
|
|
277
|
-
get: function () {
|
|
278
|
-
return this._time3 / this._nXSpeed;
|
|
279
|
-
},
|
|
280
|
-
enumerable: false,
|
|
281
|
-
configurable: true
|
|
282
|
-
});
|
|
283
|
-
Object.defineProperty(WaitManager.prototype, "time4", {
|
|
284
|
-
get: function () {
|
|
285
|
-
return this._time4 / this._nXSpeed;
|
|
286
|
-
},
|
|
287
|
-
enumerable: false,
|
|
288
|
-
configurable: true
|
|
289
|
-
});
|
|
290
|
-
Object.defineProperty(WaitManager.prototype, "time10", {
|
|
291
|
-
get: function () {
|
|
292
|
-
return this._time10 / this._nXSpeed;
|
|
293
|
-
},
|
|
294
|
-
enumerable: false,
|
|
295
|
-
configurable: true
|
|
296
|
-
});
|
|
297
|
-
Object.defineProperty(WaitManager.prototype, "time20", {
|
|
298
|
-
get: function () {
|
|
299
|
-
return this._time20 / this._nXSpeed;
|
|
300
|
-
},
|
|
301
|
-
enumerable: false,
|
|
302
|
-
configurable: true
|
|
303
|
-
});
|
|
304
|
-
Object.defineProperty(WaitManager.prototype, "time50", {
|
|
305
|
-
get: function () {
|
|
306
|
-
return this._time30 / this._nXSpeed;
|
|
307
|
-
},
|
|
308
|
-
enumerable: false,
|
|
309
|
-
configurable: true
|
|
310
|
-
});
|
|
311
|
-
Object.defineProperty(WaitManager.prototype, "time60", {
|
|
312
|
-
get: function () {
|
|
313
|
-
return this._time60 / this._nXSpeed;
|
|
314
|
-
},
|
|
315
|
-
enumerable: false,
|
|
316
|
-
configurable: true
|
|
317
|
-
});
|
|
318
|
-
Object.defineProperty(WaitManager.prototype, "cusTime", {
|
|
319
|
-
get: function () {
|
|
320
|
-
return this._cusTime / this._nXSpeed;
|
|
321
|
-
},
|
|
322
|
-
set: function (v) {
|
|
323
|
-
this._cusTime = v;
|
|
324
|
-
},
|
|
325
|
-
enumerable: false,
|
|
326
|
-
configurable: true
|
|
327
|
-
});
|
|
328
|
-
return WaitManager;
|
|
329
|
-
}());
|
|
330
|
-
exports.WaitManager = WaitManager;
|
|
331
|
-
var wait = function (ms, resolveValue) { return __awaiter(void 0, void 0, void 0, function () {
|
|
332
|
-
return __generator(this, function (_a) {
|
|
333
|
-
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
334
|
-
setTimeout(function () {
|
|
335
|
-
var finalResolveValue = resolveValue || true;
|
|
336
|
-
resolve(finalResolveValue);
|
|
337
|
-
}, ms);
|
|
338
|
-
})];
|
|
339
|
-
});
|
|
340
|
-
}); };
|
|
341
|
-
exports.wait = wait;
|
|
342
|
-
function extractValue(data) {
|
|
343
|
-
var result = [];
|
|
344
|
-
if (data && data.length > 0) {
|
|
345
|
-
result = data.map(function (item) { return item.value; });
|
|
346
|
-
}
|
|
347
|
-
return result;
|
|
348
|
-
}
|
|
349
|
-
exports.extractValue = extractValue;
|
|
350
|
-
function keyValueToArray(data) {
|
|
351
|
-
var e_2, _a;
|
|
352
|
-
var itemArray = [];
|
|
353
|
-
var keys = Object.keys(data);
|
|
354
|
-
try {
|
|
355
|
-
for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
|
|
356
|
-
var i = keys_1_1.value;
|
|
357
|
-
itemArray.push(__assign(__assign({}, data[i]), { _id: i }));
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
361
|
-
finally {
|
|
362
|
-
try {
|
|
363
|
-
if (keys_1_1 && !keys_1_1.done && (_a = keys_1.return)) _a.call(keys_1);
|
|
364
|
-
}
|
|
365
|
-
finally { if (e_2) throw e_2.error; }
|
|
366
|
-
}
|
|
367
|
-
return itemArray;
|
|
368
|
-
}
|
|
369
|
-
exports.keyValueToArray = keyValueToArray;
|
|
370
|
-
function minuted(time) {
|
|
371
|
-
var minutes = Math.floor(time / 60000).toString();
|
|
372
|
-
var seconds = Math.floor((time % 60000) / 1000).toString().padStart(2, '0');
|
|
373
|
-
return "".concat(minutes, ":").concat(seconds);
|
|
374
|
-
}
|
|
375
|
-
exports.minuted = minuted;
|
|
376
|
-
function randomDate(start, end, specificProbabilityStart, specificProbability) {
|
|
377
|
-
if (!start)
|
|
378
|
-
start = new Date('1970-1-1');
|
|
379
|
-
if (!end)
|
|
380
|
-
end = new Date();
|
|
381
|
-
if (specificProbabilityStart) {
|
|
382
|
-
if (!specificProbability)
|
|
383
|
-
specificProbability = 0.5;
|
|
384
|
-
if (Math.random() <= specificProbability) {
|
|
385
|
-
return new Date(specificProbabilityStart.getTime() + Math.random() * (end.getTime() - specificProbabilityStart.getTime()));
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
return new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime()));
|
|
389
|
-
}
|
|
390
|
-
exports.randomDate = randomDate;
|
|
391
|
-
var capitalizeWords = function (str) { return str.replace(/(?:^|\s)\S/g, function (a) { return a.toUpperCase(); }); };
|
|
392
|
-
exports.capitalizeWords = capitalizeWords;
|
|
393
|
-
var capitalizeFirstLetter = function (str) { return str.charAt(0).toUpperCase() + str.slice(1); };
|
|
394
|
-
exports.capitalizeFirstLetter = capitalizeFirstLetter;
|
|
395
|
-
var comparerArray = function (otherArray, limitKeys) {
|
|
396
|
-
return function (current) {
|
|
397
|
-
return otherArray.filter(function (other) {
|
|
398
|
-
if (!limitKeys) {
|
|
399
|
-
return _.isEqual(current, other);
|
|
400
|
-
}
|
|
401
|
-
else {
|
|
402
|
-
// TODO
|
|
403
|
-
}
|
|
404
|
-
}).length == 0;
|
|
405
|
-
};
|
|
406
|
-
};
|
|
407
|
-
exports.comparerArray = comparerArray;
|
|
408
|
-
var onlyInA = function (a, b) { return a.filter((0, exports.comparerArray)(b)); };
|
|
409
|
-
exports.onlyInA = onlyInA;
|
|
410
|
-
var onlyInB = function (a, b) { return b.filter((0, exports.comparerArray)(a)); };
|
|
411
|
-
exports.onlyInB = onlyInB;
|
|
412
|
-
var diffAB = function (a, b) { return (0, exports.onlyInA)(a, b).concat((0, exports.onlyInB)(a, b)); };
|
|
413
|
-
exports.diffAB = diffAB;
|
|
414
|
-
var StringUtil = /** @class */ (function () {
|
|
415
|
-
function StringUtil() {
|
|
416
|
-
}
|
|
417
|
-
// camelCase
|
|
418
|
-
StringUtil.toCamelCase = function (str) {
|
|
419
|
-
return _.camelCase(str);
|
|
420
|
-
};
|
|
421
|
-
// snake_case
|
|
422
|
-
StringUtil.toSnakeCase = function (str) {
|
|
423
|
-
return _.snakeCase(str);
|
|
424
|
-
};
|
|
425
|
-
// PascalCase
|
|
426
|
-
StringUtil.toPascalCase = function (str) {
|
|
427
|
-
return _.startCase(_.camelCase(str)).replace(/ /g, '');
|
|
428
|
-
};
|
|
429
|
-
// CONSTANT_CASE
|
|
430
|
-
StringUtil.toConstantCase = function (str) {
|
|
431
|
-
return _.upperCase(str).replace(/ /g, '_');
|
|
432
|
-
};
|
|
433
|
-
// kebab-case
|
|
434
|
-
StringUtil.toKebabCase = function (str) {
|
|
435
|
-
return _.kebabCase(str);
|
|
436
|
-
};
|
|
437
|
-
// lowercase
|
|
438
|
-
StringUtil.toLowerCase = function (str) {
|
|
439
|
-
return _.lowerCase(str).replace(/ /g, '');
|
|
440
|
-
};
|
|
441
|
-
// Title Case
|
|
442
|
-
StringUtil.toTitleCase = function (str) {
|
|
443
|
-
return _.startCase(_.camelCase(str));
|
|
444
|
-
};
|
|
445
|
-
// Sentence case
|
|
446
|
-
StringUtil.toSentenceCase = function (str) {
|
|
447
|
-
return _.upperFirst(_.lowerCase(str));
|
|
448
|
-
};
|
|
449
|
-
// path/case
|
|
450
|
-
StringUtil.toPathCase = function (str) {
|
|
451
|
-
return _.lowerCase(str).replace(/ /g, '/');
|
|
452
|
-
};
|
|
453
|
-
// dot.case
|
|
454
|
-
StringUtil.toDotCase = function (str) {
|
|
455
|
-
return _.lowerCase(str).replace(/ /g, '.');
|
|
456
|
-
};
|
|
457
|
-
return StringUtil;
|
|
458
|
-
}());
|
|
459
|
-
exports.StringUtil = StringUtil;
|
|
460
|
-
var deepKeysConvert = function (obj, toType) {
|
|
461
|
-
var _toType = toType || 'snake';
|
|
462
|
-
if (Array.isArray(obj)) {
|
|
463
|
-
return obj.map(function (v) { return (0, exports.deepKeysConvert)(v, _toType); });
|
|
464
|
-
}
|
|
465
|
-
else if (obj !== null && obj.constructor === Object) {
|
|
466
|
-
return Object.keys(obj).reduce(function (result, key) {
|
|
467
|
-
var _a;
|
|
468
|
-
var newKey = '';
|
|
469
|
-
switch (_toType) {
|
|
470
|
-
case 'camel':
|
|
471
|
-
newKey = StringUtil.toCamelCase(key);
|
|
472
|
-
break;
|
|
473
|
-
case 'snake':
|
|
474
|
-
newKey = StringUtil.toSnakeCase(key);
|
|
475
|
-
break;
|
|
476
|
-
case 'pascal':
|
|
477
|
-
newKey = StringUtil.toPascalCase(key);
|
|
478
|
-
break;
|
|
479
|
-
case 'constant':
|
|
480
|
-
newKey = StringUtil.toConstantCase(key);
|
|
481
|
-
break;
|
|
482
|
-
case 'kebab':
|
|
483
|
-
newKey = StringUtil.toKebabCase(key);
|
|
484
|
-
break;
|
|
485
|
-
case 'lower':
|
|
486
|
-
newKey = StringUtil.toLowerCase(key);
|
|
487
|
-
break;
|
|
488
|
-
case 'title':
|
|
489
|
-
newKey = StringUtil.toTitleCase(key);
|
|
490
|
-
break;
|
|
491
|
-
case 'sentence':
|
|
492
|
-
newKey = StringUtil.toSentenceCase(key);
|
|
493
|
-
break;
|
|
494
|
-
case 'path':
|
|
495
|
-
newKey = StringUtil.toPathCase(key);
|
|
496
|
-
break;
|
|
497
|
-
case 'dot':
|
|
498
|
-
newKey = StringUtil.toDotCase(key);
|
|
499
|
-
break;
|
|
500
|
-
default:
|
|
501
|
-
newKey = StringUtil.toDotCase(key);
|
|
502
|
-
break;
|
|
503
|
-
}
|
|
504
|
-
return __assign(__assign({}, result), (_a = {}, _a[newKey] = (0, exports.deepKeysConvert)(obj[key], _toType), _a));
|
|
505
|
-
}, {});
|
|
506
|
-
}
|
|
507
|
-
return obj;
|
|
508
|
-
};
|
|
509
|
-
exports.deepKeysConvert = deepKeysConvert;
|
|
510
|
-
var deepRemoveByKey = function (obj, keysToBeRemoved) {
|
|
511
|
-
var result = _.transform(obj, function (result, value, key) {
|
|
512
|
-
if (_.isObject(value)) {
|
|
513
|
-
value = (0, exports.deepRemoveByKey)(value, keysToBeRemoved);
|
|
514
|
-
}
|
|
515
|
-
if (!keysToBeRemoved.includes(key)) {
|
|
516
|
-
_.isArray(obj) ? result.push(value) : result[key] = value;
|
|
517
|
-
}
|
|
518
|
-
});
|
|
519
|
-
return result;
|
|
520
|
-
};
|
|
521
|
-
exports.deepRemoveByKey = deepRemoveByKey;
|
|
522
|
-
var deepRenameKeys = function (obj, keysMap) {
|
|
523
|
-
return _.transform(obj, function (result, value, key) {
|
|
524
|
-
var currentKey = keysMap[key] || key;
|
|
525
|
-
result[currentKey] = _.isObject(value) ? (0, exports.deepRenameKeys)(value, keysMap) : value;
|
|
526
|
-
});
|
|
527
|
-
};
|
|
528
|
-
exports.deepRenameKeys = deepRenameKeys;
|
|
529
|
-
var deepReplaceValues = function (obj, keyReducerMap) {
|
|
530
|
-
var newObject = _.clone(obj);
|
|
531
|
-
_.each(obj, function (val, key) {
|
|
532
|
-
for (var item in keyReducerMap) {
|
|
533
|
-
if (key === item) {
|
|
534
|
-
newObject[key] = keyReducerMap[item](newObject);
|
|
535
|
-
}
|
|
536
|
-
else if (typeof (val) === 'object' || val instanceof Array) {
|
|
537
|
-
newObject[key] = (0, exports.deepReplaceValues)(val, keyReducerMap);
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
});
|
|
541
|
-
return newObject;
|
|
542
|
-
};
|
|
543
|
-
exports.deepReplaceValues = deepReplaceValues;
|
|
544
|
-
// TODO determine depth and pass root node as a param through callback
|
|
545
|
-
var deepAdd = function (obj, keyReducerMap, isItemRootParent) {
|
|
546
|
-
var newObject = _.clone(obj);
|
|
547
|
-
if (_.isObject(newObject) && !_.isArray(newObject)) {
|
|
548
|
-
for (var item in keyReducerMap) {
|
|
549
|
-
newObject[item] = keyReducerMap[item](newObject);
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
_.each(obj, function (val, key) {
|
|
553
|
-
if (_.isObject(val)) {
|
|
554
|
-
for (var item in keyReducerMap) {
|
|
555
|
-
// @ts-ignore
|
|
556
|
-
newObject[key] = (0, exports.deepAdd)(val, keyReducerMap, isItemRootParent);
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
});
|
|
560
|
-
return newObject;
|
|
561
|
-
};
|
|
562
|
-
exports.deepAdd = deepAdd;
|
|
563
|
-
var styleString = function (color) { return "color: ".concat(color, "; font-weight: bold"); };
|
|
564
|
-
var styleHeader = function (header) { return "%c[".concat(header, "]"); };
|
|
565
|
-
exports.bunnyConsole = {
|
|
566
|
-
log: function (headerLog) {
|
|
567
|
-
if (headerLog === void 0) { headerLog = 'bunny'; }
|
|
568
|
-
var args = [];
|
|
569
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
570
|
-
args[_i - 1] = arguments[_i];
|
|
571
|
-
}
|
|
572
|
-
return console.log.apply(console, __spreadArray([styleHeader(headerLog), styleString('black')], __read(args), false));
|
|
573
|
-
},
|
|
574
|
-
warn: function (headerLog) {
|
|
575
|
-
if (headerLog === void 0) { headerLog = 'bunny'; }
|
|
576
|
-
var args = [];
|
|
577
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
578
|
-
args[_i - 1] = arguments[_i];
|
|
579
|
-
}
|
|
580
|
-
return console.warn.apply(console, __spreadArray([styleHeader(headerLog), styleString('orange')], __read(args), false));
|
|
581
|
-
},
|
|
582
|
-
error: function (headerLog) {
|
|
583
|
-
if (headerLog === void 0) { headerLog = 'bunny'; }
|
|
584
|
-
var args = [];
|
|
585
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
586
|
-
args[_i - 1] = arguments[_i];
|
|
587
|
-
}
|
|
588
|
-
return console.error.apply(console, __spreadArray([styleHeader(headerLog), styleString('red')], __read(args), false));
|
|
589
|
-
}
|
|
590
|
-
};
|
|
591
|
-
var timeStart = function () {
|
|
592
|
-
return performance ? performance.now() : new Date().getTime();
|
|
593
|
-
};
|
|
594
|
-
exports.timeStart = timeStart;
|
|
595
|
-
var timeEnd = function (startTime, headerLog, consoleConditionFn) {
|
|
596
|
-
var timeSpent = (performance ? performance.now() : new Date().getTime()) - startTime;
|
|
597
|
-
var isPassCondition = consoleConditionFn ? consoleConditionFn(timeSpent) : true;
|
|
598
|
-
if (isPassCondition) {
|
|
599
|
-
exports.bunnyConsole.log(headerLog ? headerLog : 'time spent', timeSpent.toFixed(2));
|
|
600
|
-
}
|
|
601
|
-
};
|
|
602
|
-
exports.timeEnd = timeEnd;
|
|
603
|
-
var arrayRemove = function (array, predicate) {
|
|
604
|
-
var i = -1, len = array ? array.length : 0;
|
|
605
|
-
var result = [];
|
|
20
|
+
const arrayRemove = function (array, predicate) {
|
|
21
|
+
let i = -1, len = array ? array.length : 0;
|
|
22
|
+
const result = [];
|
|
606
23
|
while (++i < len) {
|
|
607
|
-
|
|
24
|
+
const value = array[i];
|
|
608
25
|
if (predicate(value, i, array)) {
|
|
609
26
|
result.push(value);
|
|
610
27
|
Array.prototype.splice.call(array, i--, 1);
|
|
@@ -614,38 +31,36 @@ var arrayRemove = function (array, predicate) {
|
|
|
614
31
|
return result;
|
|
615
32
|
};
|
|
616
33
|
exports.arrayRemove = arrayRemove;
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
}
|
|
651
|
-
exports.zip = zip;
|
|
34
|
+
exports.THUNK_SYMBOL = Symbol('thunk');
|
|
35
|
+
const isThunk = (fnOrValue) => {
|
|
36
|
+
return typeof fnOrValue === 'function' && fnOrValue.__THUNK__ === exports.THUNK_SYMBOL;
|
|
37
|
+
};
|
|
38
|
+
exports.isThunk = isThunk;
|
|
39
|
+
const toThunk = (fn) => {
|
|
40
|
+
const thunk = () => fn();
|
|
41
|
+
thunk.__THUNK__ = exports.THUNK_SYMBOL;
|
|
42
|
+
return thunk;
|
|
43
|
+
};
|
|
44
|
+
exports.toThunk = toThunk;
|
|
45
|
+
const trampoline = (fn) => {
|
|
46
|
+
const cont = (...args) => (0, exports.toThunk)(() => fn(...args));
|
|
47
|
+
return Object.assign((...args) => {
|
|
48
|
+
let result = fn(...args);
|
|
49
|
+
while ((0, exports.isThunk)(result) && typeof result === 'function') {
|
|
50
|
+
result = result();
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}, { cont });
|
|
54
|
+
};
|
|
55
|
+
exports.trampoline = trampoline;
|
|
56
|
+
const trampolineAsync = (fn) => {
|
|
57
|
+
const cont = (...args) => (0, exports.toThunk)(() => fn(...args));
|
|
58
|
+
return Object.assign((...args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
let result = yield fn(...args);
|
|
60
|
+
while ((0, exports.isThunk)(result) && typeof result === 'function') {
|
|
61
|
+
result = yield result();
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}), { cont });
|
|
65
|
+
};
|
|
66
|
+
exports.trampolineAsync = trampolineAsync;
|