data-structure-typed 0.8.18 → 0.9.16

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.
Files changed (213) hide show
  1. package/.idea/modules.xml +1 -1
  2. package/README.md +197 -2
  3. package/dist/data-structures/binary-tree/aa-tree.js +5 -2
  4. package/dist/data-structures/binary-tree/avl-tree.d.ts +1 -5
  5. package/dist/data-structures/binary-tree/avl-tree.js +93 -46
  6. package/dist/data-structures/binary-tree/b-tree.js +5 -2
  7. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +1 -1
  8. package/dist/data-structures/binary-tree/binary-indexed-tree.js +14 -13
  9. package/dist/data-structures/binary-tree/binary-tree.d.ts +20 -32
  10. package/dist/data-structures/binary-tree/binary-tree.js +480 -370
  11. package/dist/data-structures/binary-tree/bst.d.ts +4 -8
  12. package/dist/data-structures/binary-tree/bst.js +152 -107
  13. package/dist/data-structures/binary-tree/rb-tree.js +5 -2
  14. package/dist/data-structures/binary-tree/segment-tree.d.ts +3 -3
  15. package/dist/data-structures/binary-tree/segment-tree.js +91 -61
  16. package/dist/data-structures/binary-tree/splay-tree.js +5 -2
  17. package/dist/data-structures/binary-tree/tree-multiset.d.ts +1 -5
  18. package/dist/data-structures/binary-tree/tree-multiset.js +31 -11
  19. package/dist/data-structures/binary-tree/two-three-tree.js +5 -2
  20. package/dist/data-structures/graph/abstract-graph.d.ts +5 -33
  21. package/dist/data-structures/graph/abstract-graph.js +546 -311
  22. package/dist/data-structures/graph/directed-graph.d.ts +5 -13
  23. package/dist/data-structures/graph/directed-graph.js +250 -128
  24. package/dist/data-structures/graph/undirected-graph.d.ts +4 -3
  25. package/dist/data-structures/graph/undirected-graph.js +166 -81
  26. package/dist/data-structures/hash/coordinate-map.d.ts +1 -1
  27. package/dist/data-structures/hash/coordinate-map.js +38 -20
  28. package/dist/data-structures/hash/coordinate-set.js +33 -15
  29. package/dist/data-structures/hash/index.d.ts +5 -0
  30. package/dist/data-structures/hash/index.js +5 -0
  31. package/dist/data-structures/heap/heap.d.ts +2 -8
  32. package/dist/data-structures/heap/heap.js +36 -31
  33. package/dist/data-structures/heap/max-heap.d.ts +3 -2
  34. package/dist/data-structures/heap/max-heap.js +27 -9
  35. package/dist/data-structures/heap/min-heap.d.ts +3 -2
  36. package/dist/data-structures/heap/min-heap.js +27 -9
  37. package/dist/data-structures/index.d.ts +1 -0
  38. package/dist/data-structures/index.js +1 -0
  39. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +0 -1
  40. package/dist/data-structures/linked-list/doubly-linked-list.js +56 -53
  41. package/dist/data-structures/linked-list/singly-linked-list.d.ts +8 -12
  42. package/dist/data-structures/linked-list/singly-linked-list.js +308 -174
  43. package/dist/data-structures/matrix/matrix.js +8 -7
  44. package/dist/data-structures/matrix/matrix2d.d.ts +5 -5
  45. package/dist/data-structures/matrix/matrix2d.js +80 -63
  46. package/dist/data-structures/matrix/navigator.d.ts +2 -16
  47. package/dist/data-structures/matrix/navigator.js +37 -18
  48. package/dist/data-structures/matrix/vector2d.d.ts +18 -18
  49. package/dist/data-structures/matrix/vector2d.js +117 -94
  50. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +3 -2
  51. package/dist/data-structures/priority-queue/max-priority-queue.js +25 -8
  52. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +3 -2
  53. package/dist/data-structures/priority-queue/min-priority-queue.js +25 -8
  54. package/dist/data-structures/priority-queue/priority-queue.d.ts +15 -21
  55. package/dist/data-structures/priority-queue/priority-queue.js +159 -116
  56. package/dist/data-structures/queue/deque.js +82 -56
  57. package/dist/data-structures/queue/queue.d.ts +9 -10
  58. package/dist/data-structures/queue/queue.js +34 -34
  59. package/dist/data-structures/stack/stack.d.ts +9 -10
  60. package/dist/data-structures/stack/stack.js +31 -31
  61. package/dist/data-structures/trampoline.d.ts +14 -23
  62. package/dist/data-structures/trampoline.js +103 -25
  63. package/dist/data-structures/trie/trie.d.ts +13 -3
  64. package/dist/data-structures/trie/trie.js +234 -80
  65. package/dist/data-structures/types/abstract-graph.d.ts +29 -0
  66. package/dist/data-structures/types/abstract-graph.js +2 -0
  67. package/dist/data-structures/types/avl-tree.d.ts +5 -0
  68. package/dist/data-structures/types/avl-tree.js +2 -0
  69. package/dist/data-structures/types/binary-tree.d.ts +16 -0
  70. package/dist/data-structures/types/binary-tree.js +2 -0
  71. package/dist/data-structures/types/bst.d.ts +7 -0
  72. package/dist/data-structures/types/bst.js +2 -0
  73. package/dist/data-structures/types/directed-graph.d.ts +10 -0
  74. package/dist/data-structures/types/directed-graph.js +2 -0
  75. package/dist/data-structures/types/doubly-linked-list.d.ts +1 -0
  76. package/dist/data-structures/types/doubly-linked-list.js +2 -0
  77. package/dist/data-structures/types/heap.d.ts +7 -0
  78. package/dist/data-structures/types/heap.js +2 -0
  79. package/dist/data-structures/types/index.d.ts +13 -0
  80. package/dist/data-structures/types/index.js +29 -0
  81. package/dist/data-structures/types/navigator.d.ts +14 -0
  82. package/dist/data-structures/types/navigator.js +2 -0
  83. package/dist/data-structures/types/priority-queue.d.ts +7 -0
  84. package/dist/data-structures/types/priority-queue.js +2 -0
  85. package/dist/data-structures/types/segment-tree.d.ts +1 -0
  86. package/dist/data-structures/types/segment-tree.js +2 -0
  87. package/dist/data-structures/types/singly-linked-list.d.ts +5 -0
  88. package/dist/data-structures/types/singly-linked-list.js +2 -0
  89. package/dist/data-structures/types/tree-multiset.d.ts +5 -0
  90. package/dist/data-structures/types/tree-multiset.js +2 -0
  91. package/dist/{types → data-structures/types}/utils.d.ts +7 -1
  92. package/dist/{types → data-structures/types}/utils.js +20 -19
  93. package/dist/{utils.d.ts → utils/utils.d.ts} +6 -23
  94. package/dist/utils/utils.js +651 -0
  95. package/package.json +20 -42
  96. package/src/data-structures/binary-tree/avl-tree.ts +1 -6
  97. package/src/data-structures/binary-tree/binary-indexed-tree.ts +4 -4
  98. package/src/data-structures/binary-tree/binary-tree.ts +184 -139
  99. package/src/data-structures/binary-tree/bst.ts +15 -24
  100. package/src/data-structures/binary-tree/diagrams/avl-tree-inserting.gif +0 -0
  101. package/src/data-structures/binary-tree/diagrams/bst-rotation.gif +0 -0
  102. package/src/data-structures/binary-tree/diagrams/segment-tree.png +0 -0
  103. package/src/data-structures/binary-tree/segment-tree.ts +20 -12
  104. package/src/data-structures/binary-tree/tree-multiset.ts +1 -4
  105. package/src/data-structures/diagrams/README.md +7 -0
  106. package/src/data-structures/graph/abstract-graph.ts +58 -94
  107. package/src/data-structures/graph/diagrams/adjacency-list-pros-cons.png +0 -0
  108. package/src/data-structures/graph/diagrams/adjacency-list.png +0 -0
  109. package/src/data-structures/graph/diagrams/adjacency-matrix-pros-cons.png +0 -0
  110. package/src/data-structures/graph/diagrams/adjacency-matrix.png +0 -0
  111. package/src/data-structures/graph/diagrams/dfs-can-do.png +0 -0
  112. package/src/data-structures/graph/diagrams/edge-list-pros-cons.png +0 -0
  113. package/src/data-structures/graph/diagrams/edge-list.png +0 -0
  114. package/src/data-structures/graph/diagrams/max-flow.png +0 -0
  115. package/src/data-structures/graph/diagrams/mst.png +0 -0
  116. package/src/data-structures/graph/diagrams/tarjan-articulation-point-bridge.png +0 -0
  117. package/src/data-structures/graph/diagrams/tarjan-complicate-simple.png +0 -0
  118. package/src/data-structures/graph/diagrams/tarjan-strongly-connected-component.png +0 -0
  119. package/src/data-structures/graph/diagrams/tarjan.mp4 +0 -0
  120. package/src/data-structures/graph/directed-graph.ts +12 -28
  121. package/src/data-structures/graph/undirected-graph.ts +11 -10
  122. package/src/data-structures/hash/coordinate-map.ts +1 -1
  123. package/src/data-structures/hash/index.ts +5 -0
  124. package/src/data-structures/heap/heap.ts +2 -11
  125. package/src/data-structures/heap/max-heap.ts +3 -2
  126. package/src/data-structures/heap/min-heap.ts +3 -2
  127. package/src/data-structures/index.ts +1 -0
  128. package/src/data-structures/linked-list/doubly-linked-list.ts +1 -9
  129. package/src/data-structures/linked-list/singly-linked-list.ts +18 -32
  130. package/src/data-structures/matrix/matrix2d.ts +11 -11
  131. package/src/data-structures/matrix/navigator.ts +2 -14
  132. package/src/data-structures/matrix/vector2d.ts +52 -52
  133. package/src/data-structures/priority-queue/max-priority-queue.ts +4 -3
  134. package/src/data-structures/priority-queue/min-priority-queue.ts +4 -3
  135. package/src/data-structures/priority-queue/priority-queue.ts +70 -78
  136. package/src/data-structures/queue/deque.ts +2 -2
  137. package/src/data-structures/queue/queue.ts +12 -13
  138. package/src/data-structures/stack/stack.ts +12 -13
  139. package/src/data-structures/trampoline.ts +31 -71
  140. package/src/data-structures/trie/trie.ts +61 -11
  141. package/src/data-structures/types/abstract-graph.ts +51 -0
  142. package/src/data-structures/types/avl-tree.ts +6 -0
  143. package/src/data-structures/types/binary-tree.ts +15 -0
  144. package/src/data-structures/types/bst.ts +5 -0
  145. package/src/data-structures/types/directed-graph.ts +18 -0
  146. package/src/data-structures/types/doubly-linked-list.ts +1 -0
  147. package/src/data-structures/types/heap.ts +8 -0
  148. package/src/data-structures/types/index.ts +13 -0
  149. package/src/data-structures/types/navigator.ts +12 -0
  150. package/src/data-structures/types/priority-queue.ts +9 -0
  151. package/src/data-structures/types/segment-tree.ts +1 -0
  152. package/src/data-structures/types/singly-linked-list.ts +15 -0
  153. package/src/data-structures/types/tree-multiset.ts +3 -0
  154. package/src/{types → data-structures/types}/utils.ts +20 -5
  155. package/src/utils/index.ts +1 -0
  156. package/src/{utils.ts → utils/utils.ts} +32 -132
  157. package/tsconfig.json +9 -6
  158. package/dist/types/data-structures/binary-tree/aa-tree.d.ts +0 -2
  159. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +0 -21
  160. package/dist/types/data-structures/binary-tree/b-tree.d.ts +0 -2
  161. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -8
  162. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +0 -140
  163. package/dist/types/data-structures/binary-tree/bst.d.ts +0 -32
  164. package/dist/types/data-structures/binary-tree/index.d.ts +0 -4
  165. package/dist/types/data-structures/binary-tree/rb-tree.d.ts +0 -2
  166. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +0 -33
  167. package/dist/types/data-structures/binary-tree/splay-tree.d.ts +0 -2
  168. package/dist/types/data-structures/binary-tree/tree-multiset.d.ts +0 -11
  169. package/dist/types/data-structures/binary-tree/two-three-tree.d.ts +0 -2
  170. package/dist/types/data-structures/graph/abstract-graph.d.ts +0 -126
  171. package/dist/types/data-structures/graph/directed-graph.d.ts +0 -51
  172. package/dist/types/data-structures/graph/index.d.ts +0 -3
  173. package/dist/types/data-structures/graph/undirected-graph.d.ts +0 -24
  174. package/dist/types/data-structures/hash/coordinate-map.d.ts +0 -8
  175. package/dist/types/data-structures/hash/coordinate-set.d.ts +0 -7
  176. package/dist/types/data-structures/hash/hash-table.d.ts +0 -1
  177. package/dist/types/data-structures/hash/index.d.ts +0 -1
  178. package/dist/types/data-structures/hash/pair.d.ts +0 -1
  179. package/dist/types/data-structures/hash/tree-map.d.ts +0 -1
  180. package/dist/types/data-structures/hash/tree-set.d.ts +0 -1
  181. package/dist/types/data-structures/heap/heap.d.ts +0 -72
  182. package/dist/types/data-structures/heap/index.d.ts +0 -3
  183. package/dist/types/data-structures/heap/max-heap.d.ts +0 -14
  184. package/dist/types/data-structures/heap/min-heap.d.ts +0 -14
  185. package/dist/types/data-structures/index.d.ts +0 -9
  186. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +0 -59
  187. package/dist/types/data-structures/linked-list/index.d.ts +0 -2
  188. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +0 -358
  189. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +0 -1
  190. package/dist/types/data-structures/matrix/index.d.ts +0 -3
  191. package/dist/types/data-structures/matrix/matrix.d.ts +0 -9
  192. package/dist/types/data-structures/matrix/matrix2d.d.ts +0 -25
  193. package/dist/types/data-structures/matrix/navigator.d.ts +0 -31
  194. package/dist/types/data-structures/matrix/vector2d.d.ts +0 -74
  195. package/dist/types/data-structures/priority-queue/index.d.ts +0 -3
  196. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +0 -4
  197. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +0 -4
  198. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +0 -36
  199. package/dist/types/data-structures/queue/deque.d.ts +0 -37
  200. package/dist/types/data-structures/queue/index.d.ts +0 -1
  201. package/dist/types/data-structures/queue/queue.d.ts +0 -76
  202. package/dist/types/data-structures/stack/index.d.ts +0 -1
  203. package/dist/types/data-structures/stack/stack.d.ts +0 -69
  204. package/dist/types/data-structures/trampoline.d.ts +0 -25
  205. package/dist/types/data-structures/trie/index.d.ts +0 -1
  206. package/dist/types/data-structures/trie/trie.d.ts +0 -28
  207. package/dist/types/types/index.d.ts +0 -1
  208. package/dist/types/types/utils.d.ts +0 -46
  209. package/dist/utils.js +0 -569
  210. package/src/types/index.ts +0 -1
  211. package/src/types/patches/index.d.ts +0 -0
  212. /package/dist/{types → utils}/index.d.ts +0 -0
  213. /package/dist/{types → utils}/index.js +0 -0
@@ -0,0 +1,651 @@
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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
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
+ Object.defineProperty(exports, "__esModule", { value: true });
109
+ exports.zip = exports.memo = exports.arrayRemove = exports.timeEnd = exports.timeStart = exports.bunnyConsole = exports.deepAdd = exports.deepReplaceValues = exports.deepRenameKeys = exports.deepRemoveByKey = exports.deepKeysConvert = exports.StringUtil = exports.diffAB = exports.onlyInB = exports.onlyInA = exports.comparerArray = exports.capitalizeFirstLetter = exports.capitalizeWords = exports.randomDate = exports.minuted = exports.keyValueToArray = exports.extractValue = exports.wait = exports.WaitManager = exports.addDays = exports.isLeafParent = exports.isSameStructure = exports.reverseColor = exports.deepObjectStrictEqual = exports.strictObjectIsEqual = exports.strictEqual = exports.looseEqual = exports.isObject = exports.getValue = exports.incrementId = exports.IncrementId = exports.uuidV4 = exports.randomText = void 0;
110
+ var _ = __importStar(require("lodash"));
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 () {
122
+ return 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function (c) {
123
+ var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
124
+ return v.toString(16);
125
+ });
126
+ };
127
+ exports.uuidV4 = uuidV4;
128
+ var IncrementId = /** @class */ (function () {
129
+ function IncrementId(prefix) {
130
+ this._prefix = prefix ? prefix : '';
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 = [];
606
+ while (++i < len) {
607
+ var value = array[i];
608
+ if (predicate(value, i, array)) {
609
+ result.push(value);
610
+ Array.prototype.splice.call(array, i--, 1);
611
+ len--;
612
+ }
613
+ }
614
+ return result;
615
+ };
616
+ exports.arrayRemove = arrayRemove;
617
+ function memo() {
618
+ var cache = {};
619
+ // eslint-disable-next-line @typescript-eslint/ban-types
620
+ return function (target, propertyKey, descriptor) {
621
+ var originalMethod = descriptor.value;
622
+ descriptor.value = function () {
623
+ var args = [];
624
+ for (var _i = 0; _i < arguments.length; _i++) {
625
+ args[_i] = arguments[_i];
626
+ }
627
+ var cacheKey = "__cacheKey__".concat(args.toString());
628
+ // eslint-disable-next-line no-prototype-builtins
629
+ if (!cache.hasOwnProperty(cacheKey)) {
630
+ cache[cacheKey] = originalMethod.apply(this, args);
631
+ }
632
+ return cache[cacheKey];
633
+ };
634
+ };
635
+ }
636
+ exports.memo = memo;
637
+ function zip(array1, array2, options) {
638
+ var zipped = [];
639
+ var zippedObjCoords = [];
640
+ var isToObj = (options ? options : { isToObj: false }).isToObj;
641
+ for (var i = 0; i < array1.length; i++) {
642
+ if (isToObj) {
643
+ zippedObjCoords.push({ x: array1[i], y: array2[i] });
644
+ }
645
+ else {
646
+ zipped.push([array1[i], array2[i]]);
647
+ }
648
+ }
649
+ return isToObj ? zippedObjCoords : zipped;
650
+ }
651
+ exports.zip = zip;