doubly-linked-list-typed 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (281) hide show
  1. package/dist/cjs/index.cjs +1299 -0
  2. package/dist/cjs/index.cjs.map +1 -0
  3. package/dist/esm/index.mjs +1294 -0
  4. package/dist/esm/index.mjs.map +1 -0
  5. package/dist/types/data-structures/base/index.d.ts +2 -1
  6. package/dist/types/data-structures/binary-tree/avl-tree-counter.d.ts +182 -2
  7. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +135 -2
  8. package/dist/types/data-structures/binary-tree/avl-tree.d.ts +291 -2
  9. package/dist/types/data-structures/binary-tree/binary-indexed-tree.d.ts +174 -1
  10. package/dist/types/data-structures/binary-tree/binary-tree.d.ts +754 -29
  11. package/dist/types/data-structures/binary-tree/bst.d.ts +413 -12
  12. package/dist/types/data-structures/binary-tree/index.d.ts +3 -2
  13. package/dist/types/data-structures/binary-tree/red-black-tree.d.ts +208 -3
  14. package/dist/types/data-structures/binary-tree/segment-tree.d.ts +160 -1
  15. package/dist/types/data-structures/binary-tree/tree-counter.d.ts +190 -2
  16. package/dist/types/data-structures/binary-tree/tree-multi-map.d.ts +270 -2
  17. package/dist/types/data-structures/graph/abstract-graph.d.ts +340 -14
  18. package/dist/types/data-structures/graph/directed-graph.d.ts +207 -1
  19. package/dist/types/data-structures/graph/index.d.ts +2 -1
  20. package/dist/types/data-structures/graph/map-graph.d.ts +78 -1
  21. package/dist/types/data-structures/graph/undirected-graph.d.ts +188 -1
  22. package/dist/types/data-structures/hash/hash-map.d.ts +345 -19
  23. package/dist/types/data-structures/hash/index.d.ts +0 -1
  24. package/dist/types/data-structures/heap/heap.d.ts +503 -5
  25. package/dist/types/data-structures/heap/index.d.ts +2 -0
  26. package/dist/types/data-structures/heap/max-heap.d.ts +32 -1
  27. package/dist/types/data-structures/heap/min-heap.d.ts +33 -1
  28. package/dist/types/data-structures/index.d.ts +7 -7
  29. package/dist/types/data-structures/linked-list/doubly-linked-list.d.ts +769 -2
  30. package/dist/types/data-structures/linked-list/singly-linked-list.d.ts +451 -2
  31. package/dist/types/data-structures/linked-list/skip-linked-list.d.ts +27 -4
  32. package/dist/types/data-structures/matrix/index.d.ts +1 -1
  33. package/dist/types/data-structures/matrix/matrix.d.ts +168 -7
  34. package/dist/types/data-structures/matrix/navigator.d.ts +54 -13
  35. package/dist/types/data-structures/priority-queue/max-priority-queue.d.ts +27 -1
  36. package/dist/types/data-structures/priority-queue/min-priority-queue.d.ts +26 -1
  37. package/dist/types/data-structures/priority-queue/priority-queue.d.ts +15 -2
  38. package/dist/types/data-structures/queue/deque.d.ts +431 -4
  39. package/dist/types/data-structures/queue/queue.d.ts +308 -4
  40. package/dist/types/data-structures/stack/stack.d.ts +306 -2
  41. package/dist/types/data-structures/tree/tree.d.ts +62 -1
  42. package/dist/types/data-structures/trie/trie.d.ts +350 -4
  43. package/dist/types/index.d.ts +11 -2
  44. package/dist/{interfaces → types/interfaces}/binary-tree.d.ts +1 -1
  45. package/dist/types/types/data-structures/base/index.d.ts +1 -0
  46. package/dist/types/types/data-structures/binary-tree/avl-tree-counter.d.ts +2 -0
  47. package/dist/types/types/data-structures/binary-tree/avl-tree-multi-map.d.ts +2 -0
  48. package/dist/types/types/data-structures/binary-tree/avl-tree.d.ts +2 -0
  49. package/dist/types/types/data-structures/binary-tree/binary-indexed-tree.d.ts +1 -0
  50. package/dist/types/types/data-structures/binary-tree/binary-tree.d.ts +29 -0
  51. package/dist/types/types/data-structures/binary-tree/bst.d.ts +12 -0
  52. package/dist/{data-structures → types/types/data-structures}/binary-tree/index.d.ts +2 -3
  53. package/dist/types/types/data-structures/binary-tree/red-black-tree.d.ts +3 -0
  54. package/dist/types/types/data-structures/binary-tree/segment-tree.d.ts +1 -0
  55. package/dist/types/types/data-structures/binary-tree/tree-counter.d.ts +2 -0
  56. package/dist/types/types/data-structures/binary-tree/tree-multi-map.d.ts +2 -0
  57. package/dist/types/types/data-structures/graph/abstract-graph.d.ts +14 -0
  58. package/dist/types/types/data-structures/graph/directed-graph.d.ts +1 -0
  59. package/dist/{data-structures → types/types/data-structures}/graph/index.d.ts +1 -2
  60. package/dist/types/types/data-structures/graph/map-graph.d.ts +1 -0
  61. package/dist/types/types/data-structures/graph/undirected-graph.d.ts +1 -0
  62. package/dist/types/types/data-structures/hash/hash-map.d.ts +19 -0
  63. package/dist/types/types/data-structures/hash/index.d.ts +2 -0
  64. package/dist/types/types/data-structures/heap/heap.d.ts +5 -0
  65. package/dist/types/types/data-structures/heap/index.d.ts +1 -0
  66. package/dist/types/types/data-structures/heap/max-heap.d.ts +1 -0
  67. package/dist/types/types/data-structures/heap/min-heap.d.ts +1 -0
  68. package/dist/types/types/data-structures/linked-list/doubly-linked-list.d.ts +2 -0
  69. package/dist/types/types/data-structures/linked-list/singly-linked-list.d.ts +2 -0
  70. package/dist/types/types/data-structures/linked-list/skip-linked-list.d.ts +4 -0
  71. package/dist/types/types/data-structures/matrix/matrix.d.ts +7 -0
  72. package/dist/types/types/data-structures/matrix/navigator.d.ts +14 -0
  73. package/dist/types/types/data-structures/priority-queue/max-priority-queue.d.ts +1 -0
  74. package/dist/types/types/data-structures/priority-queue/min-priority-queue.d.ts +1 -0
  75. package/dist/types/types/data-structures/priority-queue/priority-queue.d.ts +2 -0
  76. package/dist/types/types/data-structures/queue/deque.d.ts +4 -0
  77. package/dist/types/types/data-structures/queue/queue.d.ts +4 -0
  78. package/dist/types/types/data-structures/stack/stack.d.ts +2 -0
  79. package/dist/types/types/data-structures/tree/tree.d.ts +1 -0
  80. package/dist/types/types/data-structures/trie/trie.d.ts +4 -0
  81. package/dist/types/types/index.d.ts +3 -0
  82. package/dist/types/types/utils/index.d.ts +2 -0
  83. package/dist/types/types/utils/utils.d.ts +22 -0
  84. package/dist/types/utils/index.d.ts +1 -1
  85. package/dist/types/utils/utils.d.ts +209 -22
  86. package/dist/umd/doubly-linked-list-typed.js +1302 -0
  87. package/dist/umd/doubly-linked-list-typed.js.map +1 -0
  88. package/dist/umd/doubly-linked-list-typed.min.js +9 -0
  89. package/dist/umd/doubly-linked-list-typed.min.js.map +1 -0
  90. package/package.json +25 -5
  91. package/src/data-structures/binary-tree/avl-tree-counter.ts +4 -4
  92. package/src/data-structures/binary-tree/avl-tree-multi-map.ts +1 -1
  93. package/src/data-structures/binary-tree/avl-tree.ts +2 -2
  94. package/src/data-structures/binary-tree/binary-tree.ts +4 -4
  95. package/src/data-structures/binary-tree/bst.ts +1 -1
  96. package/src/data-structures/binary-tree/red-black-tree.ts +2 -2
  97. package/src/data-structures/binary-tree/tree-counter.ts +4 -4
  98. package/src/data-structures/binary-tree/tree-multi-map.ts +1 -1
  99. package/src/data-structures/heap/heap.ts +5 -5
  100. package/src/data-structures/linked-list/singly-linked-list.ts +2 -2
  101. package/src/interfaces/binary-tree.ts +1 -1
  102. package/tsconfig.base.json +23 -0
  103. package/tsconfig.json +8 -34
  104. package/tsconfig.test.json +8 -0
  105. package/tsconfig.types.json +15 -0
  106. package/tsup.config.js +28 -0
  107. package/tsup.node.config.js +37 -0
  108. package/dist/common/index.js +0 -28
  109. package/dist/constants/index.js +0 -8
  110. package/dist/data-structures/base/index.d.ts +0 -2
  111. package/dist/data-structures/base/index.js +0 -18
  112. package/dist/data-structures/base/iterable-element-base.js +0 -243
  113. package/dist/data-structures/base/iterable-entry-base.js +0 -183
  114. package/dist/data-structures/base/linear-base.js +0 -415
  115. package/dist/data-structures/binary-tree/avl-tree-counter.d.ts +0 -182
  116. package/dist/data-structures/binary-tree/avl-tree-counter.js +0 -374
  117. package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +0 -135
  118. package/dist/data-structures/binary-tree/avl-tree-multi-map.js +0 -250
  119. package/dist/data-structures/binary-tree/avl-tree.d.ts +0 -291
  120. package/dist/data-structures/binary-tree/avl-tree.js +0 -611
  121. package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +0 -174
  122. package/dist/data-structures/binary-tree/binary-indexed-tree.js +0 -294
  123. package/dist/data-structures/binary-tree/binary-tree.d.ts +0 -754
  124. package/dist/data-structures/binary-tree/binary-tree.js +0 -1925
  125. package/dist/data-structures/binary-tree/bst.d.ts +0 -413
  126. package/dist/data-structures/binary-tree/bst.js +0 -903
  127. package/dist/data-structures/binary-tree/index.js +0 -26
  128. package/dist/data-structures/binary-tree/red-black-tree.d.ts +0 -208
  129. package/dist/data-structures/binary-tree/red-black-tree.js +0 -546
  130. package/dist/data-structures/binary-tree/segment-tree.d.ts +0 -160
  131. package/dist/data-structures/binary-tree/segment-tree.js +0 -297
  132. package/dist/data-structures/binary-tree/tree-counter.d.ts +0 -190
  133. package/dist/data-structures/binary-tree/tree-counter.js +0 -413
  134. package/dist/data-structures/binary-tree/tree-multi-map.d.ts +0 -270
  135. package/dist/data-structures/binary-tree/tree-multi-map.js +0 -384
  136. package/dist/data-structures/graph/abstract-graph.d.ts +0 -340
  137. package/dist/data-structures/graph/abstract-graph.js +0 -896
  138. package/dist/data-structures/graph/directed-graph.d.ts +0 -207
  139. package/dist/data-structures/graph/directed-graph.js +0 -525
  140. package/dist/data-structures/graph/index.js +0 -20
  141. package/dist/data-structures/graph/map-graph.d.ts +0 -78
  142. package/dist/data-structures/graph/map-graph.js +0 -107
  143. package/dist/data-structures/graph/undirected-graph.d.ts +0 -188
  144. package/dist/data-structures/graph/undirected-graph.js +0 -424
  145. package/dist/data-structures/hash/hash-map.d.ts +0 -345
  146. package/dist/data-structures/hash/hash-map.js +0 -692
  147. package/dist/data-structures/hash/index.d.ts +0 -1
  148. package/dist/data-structures/hash/index.js +0 -17
  149. package/dist/data-structures/heap/heap.d.ts +0 -503
  150. package/dist/data-structures/heap/heap.js +0 -901
  151. package/dist/data-structures/heap/index.d.ts +0 -3
  152. package/dist/data-structures/heap/index.js +0 -19
  153. package/dist/data-structures/heap/max-heap.d.ts +0 -32
  154. package/dist/data-structures/heap/max-heap.js +0 -40
  155. package/dist/data-structures/heap/min-heap.d.ts +0 -33
  156. package/dist/data-structures/heap/min-heap.js +0 -31
  157. package/dist/data-structures/index.js +0 -28
  158. package/dist/data-structures/linked-list/doubly-linked-list.d.ts +0 -769
  159. package/dist/data-structures/linked-list/doubly-linked-list.js +0 -1111
  160. package/dist/data-structures/linked-list/index.js +0 -19
  161. package/dist/data-structures/linked-list/singly-linked-list.d.ts +0 -451
  162. package/dist/data-structures/linked-list/singly-linked-list.js +0 -850
  163. package/dist/data-structures/linked-list/skip-linked-list.d.ts +0 -27
  164. package/dist/data-structures/linked-list/skip-linked-list.js +0 -144
  165. package/dist/data-structures/matrix/index.js +0 -18
  166. package/dist/data-structures/matrix/matrix.d.ts +0 -168
  167. package/dist/data-structures/matrix/matrix.js +0 -448
  168. package/dist/data-structures/matrix/navigator.d.ts +0 -55
  169. package/dist/data-structures/matrix/navigator.js +0 -111
  170. package/dist/data-structures/priority-queue/index.js +0 -19
  171. package/dist/data-structures/priority-queue/max-priority-queue.d.ts +0 -27
  172. package/dist/data-structures/priority-queue/max-priority-queue.js +0 -34
  173. package/dist/data-structures/priority-queue/min-priority-queue.d.ts +0 -26
  174. package/dist/data-structures/priority-queue/min-priority-queue.js +0 -24
  175. package/dist/data-structures/priority-queue/priority-queue.d.ts +0 -15
  176. package/dist/data-structures/priority-queue/priority-queue.js +0 -20
  177. package/dist/data-structures/queue/deque.d.ts +0 -431
  178. package/dist/data-structures/queue/deque.js +0 -879
  179. package/dist/data-structures/queue/index.js +0 -18
  180. package/dist/data-structures/queue/queue.d.ts +0 -308
  181. package/dist/data-structures/queue/queue.js +0 -473
  182. package/dist/data-structures/stack/index.js +0 -17
  183. package/dist/data-structures/stack/stack.d.ts +0 -306
  184. package/dist/data-structures/stack/stack.js +0 -401
  185. package/dist/data-structures/tree/index.js +0 -17
  186. package/dist/data-structures/tree/tree.d.ts +0 -62
  187. package/dist/data-structures/tree/tree.js +0 -107
  188. package/dist/data-structures/trie/index.js +0 -17
  189. package/dist/data-structures/trie/trie.d.ts +0 -350
  190. package/dist/data-structures/trie/trie.js +0 -610
  191. package/dist/index.d.ts +0 -12
  192. package/dist/index.js +0 -28
  193. package/dist/interfaces/binary-tree.js +0 -2
  194. package/dist/interfaces/doubly-linked-list.js +0 -2
  195. package/dist/interfaces/graph.js +0 -2
  196. package/dist/interfaces/heap.js +0 -2
  197. package/dist/interfaces/index.js +0 -24
  198. package/dist/interfaces/navigator.js +0 -2
  199. package/dist/interfaces/priority-queue.js +0 -2
  200. package/dist/interfaces/segment-tree.js +0 -2
  201. package/dist/interfaces/singly-linked-list.js +0 -2
  202. package/dist/types/common.js +0 -2
  203. package/dist/types/data-structures/base/base.js +0 -2
  204. package/dist/types/data-structures/base/index.js +0 -17
  205. package/dist/types/data-structures/binary-tree/avl-tree-counter.js +0 -2
  206. package/dist/types/data-structures/binary-tree/avl-tree-multi-map.js +0 -2
  207. package/dist/types/data-structures/binary-tree/avl-tree.js +0 -2
  208. package/dist/types/data-structures/binary-tree/binary-indexed-tree.js +0 -2
  209. package/dist/types/data-structures/binary-tree/binary-tree.js +0 -2
  210. package/dist/types/data-structures/binary-tree/bst.js +0 -2
  211. package/dist/types/data-structures/binary-tree/index.js +0 -25
  212. package/dist/types/data-structures/binary-tree/red-black-tree.js +0 -2
  213. package/dist/types/data-structures/binary-tree/segment-tree.js +0 -2
  214. package/dist/types/data-structures/binary-tree/tree-counter.js +0 -2
  215. package/dist/types/data-structures/binary-tree/tree-multi-map.js +0 -2
  216. package/dist/types/data-structures/graph/abstract-graph.js +0 -2
  217. package/dist/types/data-structures/graph/directed-graph.js +0 -2
  218. package/dist/types/data-structures/graph/index.js +0 -19
  219. package/dist/types/data-structures/graph/map-graph.js +0 -2
  220. package/dist/types/data-structures/graph/undirected-graph.js +0 -2
  221. package/dist/types/data-structures/hash/hash-map.js +0 -2
  222. package/dist/types/data-structures/hash/index.js +0 -17
  223. package/dist/types/data-structures/heap/heap.js +0 -2
  224. package/dist/types/data-structures/heap/index.js +0 -17
  225. package/dist/types/data-structures/heap/max-heap.js +0 -2
  226. package/dist/types/data-structures/heap/min-heap.js +0 -2
  227. package/dist/types/data-structures/index.js +0 -28
  228. package/dist/types/data-structures/linked-list/doubly-linked-list.js +0 -2
  229. package/dist/types/data-structures/linked-list/index.js +0 -19
  230. package/dist/types/data-structures/linked-list/singly-linked-list.js +0 -2
  231. package/dist/types/data-structures/linked-list/skip-linked-list.js +0 -2
  232. package/dist/types/data-structures/matrix/index.js +0 -18
  233. package/dist/types/data-structures/matrix/matrix.js +0 -2
  234. package/dist/types/data-structures/matrix/navigator.js +0 -2
  235. package/dist/types/data-structures/priority-queue/index.js +0 -19
  236. package/dist/types/data-structures/priority-queue/max-priority-queue.js +0 -2
  237. package/dist/types/data-structures/priority-queue/min-priority-queue.js +0 -2
  238. package/dist/types/data-structures/priority-queue/priority-queue.js +0 -2
  239. package/dist/types/data-structures/queue/deque.js +0 -2
  240. package/dist/types/data-structures/queue/index.js +0 -18
  241. package/dist/types/data-structures/queue/queue.js +0 -2
  242. package/dist/types/data-structures/stack/index.js +0 -17
  243. package/dist/types/data-structures/stack/stack.js +0 -2
  244. package/dist/types/data-structures/tree/index.js +0 -17
  245. package/dist/types/data-structures/tree/tree.js +0 -2
  246. package/dist/types/data-structures/trie/index.js +0 -17
  247. package/dist/types/data-structures/trie/trie.js +0 -2
  248. package/dist/types/index.js +0 -19
  249. package/dist/types/utils/index.js +0 -18
  250. package/dist/types/utils/utils.js +0 -2
  251. package/dist/types/utils/validate-type.js +0 -2
  252. package/dist/utils/index.d.ts +0 -2
  253. package/dist/utils/index.js +0 -18
  254. package/dist/utils/number.js +0 -24
  255. package/dist/utils/utils.d.ts +0 -209
  256. package/dist/utils/utils.js +0 -353
  257. package/dist/{common → types/common}/index.d.ts +0 -0
  258. package/dist/{constants → types/constants}/index.d.ts +0 -0
  259. package/dist/{data-structures → types/data-structures}/base/iterable-element-base.d.ts +0 -0
  260. package/dist/{data-structures → types/data-structures}/base/iterable-entry-base.d.ts +0 -0
  261. package/dist/{data-structures → types/data-structures}/base/linear-base.d.ts +0 -0
  262. package/dist/{interfaces → types/interfaces}/doubly-linked-list.d.ts +0 -0
  263. package/dist/{interfaces → types/interfaces}/graph.d.ts +0 -0
  264. package/dist/{interfaces → types/interfaces}/heap.d.ts +0 -0
  265. package/dist/{interfaces → types/interfaces}/index.d.ts +0 -0
  266. package/dist/{interfaces → types/interfaces}/navigator.d.ts +0 -0
  267. package/dist/{interfaces → types/interfaces}/priority-queue.d.ts +0 -0
  268. package/dist/{interfaces → types/interfaces}/segment-tree.d.ts +0 -0
  269. package/dist/{interfaces → types/interfaces}/singly-linked-list.d.ts +0 -0
  270. package/dist/types/{common.d.ts → types/common.d.ts} +0 -0
  271. package/dist/types/{data-structures → types/data-structures}/base/base.d.ts +0 -0
  272. package/dist/{data-structures → types/types/data-structures}/index.d.ts +7 -7
  273. package/dist/{data-structures → types/types/data-structures}/linked-list/index.d.ts +0 -0
  274. package/dist/{data-structures → types/types/data-structures}/matrix/index.d.ts +1 -1
  275. /package/dist/{data-structures → types/types/data-structures}/priority-queue/index.d.ts +0 -0
  276. /package/dist/{data-structures → types/types/data-structures}/queue/index.d.ts +0 -0
  277. /package/dist/{data-structures → types/types/data-structures}/stack/index.d.ts +0 -0
  278. /package/dist/{data-structures → types/types/data-structures}/tree/index.d.ts +0 -0
  279. /package/dist/{data-structures → types/types/data-structures}/trie/index.d.ts +0 -0
  280. /package/dist/types/{utils → types/utils}/validate-type.d.ts +0 -0
  281. /package/dist/{utils → types/utils}/number.d.ts +0 -0
@@ -1,209 +0,0 @@
1
- /**
2
- * data-structure-typed
3
- *
4
- * @author Pablo Zeng
5
- * @copyright Copyright (c) 2022 Pablo Zeng <zrwusa@gmail.com>
6
- * @license MIT License
7
- */
8
- import type { Comparable, Trampoline, TrampolineThunk } from '../types';
9
- /**
10
- * The function generates a random UUID (Universally Unique Identifier) in TypeScript.
11
- * @returns A randomly generated UUID (Universally Unique Identifier) in the format
12
- * 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' where each 'x' is replaced with a random hexadecimal
13
- * character.
14
- */
15
- export declare const uuidV4: () => string;
16
- /**
17
- * The `arrayRemove` function removes elements from an array based on a specified predicate function
18
- * and returns the removed elements.
19
- * @param {T[]} array - An array of elements that you want to filter based on the provided predicate
20
- * function.
21
- * @param predicate - The `predicate` parameter is a function that takes three arguments:
22
- * @returns The `arrayRemove` function returns an array containing the elements that satisfy the given
23
- * `predicate` function.
24
- */
25
- export declare const arrayRemove: <T>(array: T[], predicate: (item: T, index: number, array: T[]) => boolean) => T[];
26
- /**
27
- * The function `getMSB` returns the most significant bit of a given number.
28
- * @param {number} value - The `value` parameter is a number for which we want to find the position of
29
- * the Most Significant Bit (MSB). The function `getMSB` takes this number as input and calculates the
30
- * position of the MSB in its binary representation.
31
- * @returns The function `getMSB` returns the most significant bit (MSB) of the input `value`. If the
32
- * input value is less than or equal to 0, it returns 0. Otherwise, it calculates the position of the
33
- * MSB using the `Math.clz32` function and bitwise left shifts 1 to that position.
34
- */
35
- export declare const getMSB: (value: number) => number;
36
- /**
37
- * The `rangeCheck` function in TypeScript is used to validate if an index is within a specified range
38
- * and throws a `RangeError` with a custom message if it is out of bounds.
39
- * @param {number} index - The `index` parameter represents the value that you want to check if it
40
- * falls within a specified range.
41
- * @param {number} min - The `min` parameter represents the minimum value that the `index` should be
42
- * compared against in the `rangeCheck` function.
43
- * @param {number} max - The `max` parameter in the `rangeCheck` function represents the maximum value
44
- * that the `index` parameter is allowed to have. If the `index` is greater than this `max` value, a
45
- * `RangeError` will be thrown.
46
- * @param [message=Index out of bounds.] - The `message` parameter is a string that represents the
47
- * error message to be thrown if the index is out of bounds. By default, if no message is provided when
48
- * calling the `rangeCheck` function, the message "Index out of bounds." will be used.
49
- */
50
- export declare const rangeCheck: (index: number, min: number, max: number, message?: string) => void;
51
- /**
52
- * The function `throwRangeError` throws a RangeError with a custom message if called.
53
- * @param [message=The value is off-limits.] - The `message` parameter is a string that represents the
54
- * error message to be displayed when a `RangeError` is thrown. If no message is provided, the default
55
- * message is 'The value is off-limits.'.
56
- */
57
- export declare const throwRangeError: (message?: string) => void;
58
- /**
59
- * The function `isWeakKey` checks if the input is an object or a function in TypeScript.
60
- * @param {unknown} input - The `input` parameter in the `isWeakKey` function is of type `unknown`,
61
- * which means it can be any type. The function checks if the `input` is an object (excluding `null`)
62
- * or a function, and returns a boolean indicating whether the `input` is a weak
63
- * @returns The function `isWeakKey` returns a boolean value indicating whether the input is an object
64
- * or a function.
65
- */
66
- export declare const isWeakKey: (input: unknown) => input is object;
67
- /**
68
- * The function `calcMinUnitsRequired` calculates the minimum number of units required to accommodate a
69
- * given total quantity based on a specified unit size.
70
- * @param {number} totalQuantity - The `totalQuantity` parameter represents the total quantity of items
71
- * that need to be processed or handled.
72
- * @param {number} unitSize - The `unitSize` parameter represents the size of each unit or package. It
73
- * is used in the `calcMinUnitsRequired` function to calculate the minimum number of units required to
74
- * accommodate a total quantity of items.
75
- */
76
- export declare const calcMinUnitsRequired: (totalQuantity: number, unitSize: number) => number;
77
- /**
78
- * The `roundFixed` function in TypeScript rounds a number to a specified number of decimal places.
79
- * @param {number} num - The `num` parameter is a number that you want to round to a certain number of
80
- * decimal places.
81
- * @param {number} [digit=10] - The `digit` parameter in the `roundFixed` function specifies the number
82
- * of decimal places to round the number to. By default, it is set to 10 if not provided explicitly.
83
- * @returns The function `roundFixed` returns a number that is rounded to the specified number of
84
- * decimal places (default is 10 decimal places).
85
- */
86
- export declare const roundFixed: (num: number, digit?: number) => number;
87
- /**
88
- * The function `isComparable` in TypeScript checks if a value is comparable, handling primitive values
89
- * and objects with optional force comparison.
90
- * @param {unknown} value - The `value` parameter in the `isComparable` function represents the value
91
- * that you want to check if it is comparable. It can be of any type (`unknown`), and the function will
92
- * determine if it is comparable based on certain conditions.
93
- * @param [isForceObjectComparable=false] - The `isForceObjectComparable` parameter in the
94
- * `isComparable` function is a boolean flag that determines whether to treat non-primitive values as
95
- * comparable objects. When set to `true`, it forces the function to consider non-primitive values as
96
- * comparable objects, regardless of their type.
97
- * @returns The function `isComparable` returns a boolean value indicating whether the `value` is
98
- * considered comparable or not.
99
- */
100
- export declare function isComparable(value: unknown, isForceObjectComparable?: boolean): value is Comparable;
101
- /**
102
- * Creates a trampoline thunk object.
103
- *
104
- * A "thunk" is a deferred computation — instead of performing a recursive call immediately,
105
- * it wraps the next step of the computation in a function. This allows recursive processes
106
- * to be executed iteratively, preventing stack overflows.
107
- *
108
- * @template T - The type of the final computation result.
109
- * @param computation - A function that, when executed, returns the next trampoline step.
110
- * @returns A TrampolineThunk object containing the deferred computation.
111
- */
112
- export declare const makeTrampolineThunk: <T>(computation: () => Trampoline<T>) => TrampolineThunk<T>;
113
- /**
114
- * Type guard to check whether a given value is a TrampolineThunk.
115
- *
116
- * This function is used to distinguish between a final computation result (value)
117
- * and a deferred computation (thunk).
118
- *
119
- * @template T - The type of the value being checked.
120
- * @param value - The value to test.
121
- * @returns True if the value is a valid TrampolineThunk, false otherwise.
122
- */
123
- export declare const isTrampolineThunk: <T>(value: Trampoline<T>) => value is TrampolineThunk<T>;
124
- /**
125
- * Executes a trampoline computation until a final (non-thunk) result is obtained.
126
- *
127
- * The trampoline function repeatedly invokes the deferred computations (thunks)
128
- * in an iterative loop. This avoids deep recursive calls and prevents stack overflow,
129
- * which is particularly useful for implementing recursion in a stack-safe manner.
130
- *
131
- * @template T - The type of the final result.
132
- * @param initial - The initial Trampoline value or thunk to start execution from.
133
- * @returns The final result of the computation (a non-thunk value).
134
- */
135
- export declare function trampoline<T>(initial: Trampoline<T>): T;
136
- /**
137
- * Wraps a recursive function inside a trampoline executor.
138
- *
139
- * This function transforms a potentially recursive function (that returns a Trampoline<Result>)
140
- * into a *stack-safe* function that executes iteratively using the `trampoline` runner.
141
- *
142
- * In other words, it allows you to write functions that look recursive,
143
- * but actually run in constant stack space.
144
- *
145
- * @template Args - The tuple type representing the argument list of the original function.
146
- * @template Result - The final return type after all trampoline steps are resolved.
147
- *
148
- * @param fn - A function that performs a single step of computation
149
- * and returns a Trampoline (either a final value or a deferred thunk).
150
- *
151
- * @returns A new function with the same arguments, but which automatically
152
- * runs the trampoline process and returns the *final result* instead
153
- * of a Trampoline.
154
- *
155
- * @example
156
- * // Example: Computing factorial in a stack-safe way
157
- * const factorial = makeTrampoline(function fact(n: number, acc: number = 1): Trampoline<number> {
158
- * return n === 0
159
- * ? acc
160
- * : makeTrampolineThunk(() => fact(n - 1, acc * n));
161
- * });
162
- *
163
- * console.log(factorial(100000)); // Works without stack overflow
164
- */
165
- export declare function makeTrampoline<Args extends any[], Result>(fn: (...args: Args) => Trampoline<Result>): (...args: Args) => Result;
166
- /**
167
- * Executes an asynchronous trampoline computation until a final (non-thunk) result is obtained.
168
- *
169
- * This function repeatedly invokes asynchronous deferred computations (thunks)
170
- * in an iterative loop. Each thunk may return either a Trampoline<T> or a Promise<Trampoline<T>>.
171
- *
172
- * It ensures that asynchronous recursive functions can run without growing the call stack,
173
- * making it suitable for stack-safe async recursion.
174
- *
175
- * @template T - The type of the final result.
176
- * @param initial - The initial Trampoline or Promise of Trampoline to start execution from.
177
- * @returns A Promise that resolves to the final result (a non-thunk value).
178
- */
179
- export declare function asyncTrampoline<T>(initial: Trampoline<T> | Promise<Trampoline<T>>): Promise<T>;
180
- /**
181
- * Wraps an asynchronous recursive function inside an async trampoline executor.
182
- *
183
- * This helper transforms a recursive async function that returns a Trampoline<Result>
184
- * (or Promise<Trampoline<Result>>) into a *stack-safe* async function that executes
185
- * iteratively via the `asyncTrampoline` runner.
186
- *
187
- * @template Args - The tuple type representing the argument list of the original function.
188
- * @template Result - The final return type after all async trampoline steps are resolved.
189
- *
190
- * @param fn - An async or sync function that performs a single step of computation
191
- * and returns a Trampoline (either a final value or a deferred thunk).
192
- *
193
- * @returns An async function with the same arguments, but which automatically
194
- * runs the trampoline process and resolves to the *final result*.
195
- *
196
- * @example
197
- * // Example: Async factorial using trampoline
198
- * const asyncFactorial = makeAsyncTrampoline(async function fact(
199
- * n: number,
200
- * acc: number = 1
201
- * ): Promise<Trampoline<number>> {
202
- * return n === 0
203
- * ? acc
204
- * : makeTrampolineThunk(() => fact(n - 1, acc * n));
205
- * });
206
- *
207
- * asyncFactorial(100000).then(console.log); // Works without stack overflow
208
- */
209
- export declare function makeAsyncTrampoline<Args extends any[], Result>(fn: (...args: Args) => Trampoline<Result> | Promise<Trampoline<Result>>): (...args: Args) => Promise<Result>;
@@ -1,353 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.makeAsyncTrampoline = exports.asyncTrampoline = exports.makeTrampoline = exports.trampoline = exports.isTrampolineThunk = exports.makeTrampolineThunk = exports.isComparable = exports.roundFixed = exports.calcMinUnitsRequired = exports.isWeakKey = exports.throwRangeError = exports.rangeCheck = exports.getMSB = exports.arrayRemove = exports.uuidV4 = void 0;
13
- /**
14
- * The function generates a random UUID (Universally Unique Identifier) in TypeScript.
15
- * @returns A randomly generated UUID (Universally Unique Identifier) in the format
16
- * 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' where each 'x' is replaced with a random hexadecimal
17
- * character.
18
- */
19
- const uuidV4 = function () {
20
- return 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function (c) {
21
- const r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8;
22
- return v.toString(16);
23
- });
24
- };
25
- exports.uuidV4 = uuidV4;
26
- /**
27
- * The `arrayRemove` function removes elements from an array based on a specified predicate function
28
- * and returns the removed elements.
29
- * @param {T[]} array - An array of elements that you want to filter based on the provided predicate
30
- * function.
31
- * @param predicate - The `predicate` parameter is a function that takes three arguments:
32
- * @returns The `arrayRemove` function returns an array containing the elements that satisfy the given
33
- * `predicate` function.
34
- */
35
- const arrayRemove = function (array, predicate) {
36
- let i = -1, len = array ? array.length : 0;
37
- const result = [];
38
- while (++i < len) {
39
- const value = array[i];
40
- if (predicate(value, i, array)) {
41
- result.push(value);
42
- Array.prototype.splice.call(array, i--, 1);
43
- len--;
44
- }
45
- }
46
- return result;
47
- };
48
- exports.arrayRemove = arrayRemove;
49
- /**
50
- * The function `getMSB` returns the most significant bit of a given number.
51
- * @param {number} value - The `value` parameter is a number for which we want to find the position of
52
- * the Most Significant Bit (MSB). The function `getMSB` takes this number as input and calculates the
53
- * position of the MSB in its binary representation.
54
- * @returns The function `getMSB` returns the most significant bit (MSB) of the input `value`. If the
55
- * input value is less than or equal to 0, it returns 0. Otherwise, it calculates the position of the
56
- * MSB using the `Math.clz32` function and bitwise left shifts 1 to that position.
57
- */
58
- const getMSB = (value) => {
59
- if (value <= 0) {
60
- return 0;
61
- }
62
- return 1 << (31 - Math.clz32(value));
63
- };
64
- exports.getMSB = getMSB;
65
- /**
66
- * The `rangeCheck` function in TypeScript is used to validate if an index is within a specified range
67
- * and throws a `RangeError` with a custom message if it is out of bounds.
68
- * @param {number} index - The `index` parameter represents the value that you want to check if it
69
- * falls within a specified range.
70
- * @param {number} min - The `min` parameter represents the minimum value that the `index` should be
71
- * compared against in the `rangeCheck` function.
72
- * @param {number} max - The `max` parameter in the `rangeCheck` function represents the maximum value
73
- * that the `index` parameter is allowed to have. If the `index` is greater than this `max` value, a
74
- * `RangeError` will be thrown.
75
- * @param [message=Index out of bounds.] - The `message` parameter is a string that represents the
76
- * error message to be thrown if the index is out of bounds. By default, if no message is provided when
77
- * calling the `rangeCheck` function, the message "Index out of bounds." will be used.
78
- */
79
- const rangeCheck = (index, min, max, message = 'Index out of bounds.') => {
80
- if (index < min || index > max)
81
- throw new RangeError(message);
82
- };
83
- exports.rangeCheck = rangeCheck;
84
- /**
85
- * The function `throwRangeError` throws a RangeError with a custom message if called.
86
- * @param [message=The value is off-limits.] - The `message` parameter is a string that represents the
87
- * error message to be displayed when a `RangeError` is thrown. If no message is provided, the default
88
- * message is 'The value is off-limits.'.
89
- */
90
- const throwRangeError = (message = 'The value is off-limits.') => {
91
- throw new RangeError(message);
92
- };
93
- exports.throwRangeError = throwRangeError;
94
- /**
95
- * The function `isWeakKey` checks if the input is an object or a function in TypeScript.
96
- * @param {unknown} input - The `input` parameter in the `isWeakKey` function is of type `unknown`,
97
- * which means it can be any type. The function checks if the `input` is an object (excluding `null`)
98
- * or a function, and returns a boolean indicating whether the `input` is a weak
99
- * @returns The function `isWeakKey` returns a boolean value indicating whether the input is an object
100
- * or a function.
101
- */
102
- const isWeakKey = (input) => {
103
- const inputType = typeof input;
104
- return (inputType === 'object' && input !== null) || inputType === 'function';
105
- };
106
- exports.isWeakKey = isWeakKey;
107
- /**
108
- * The function `calcMinUnitsRequired` calculates the minimum number of units required to accommodate a
109
- * given total quantity based on a specified unit size.
110
- * @param {number} totalQuantity - The `totalQuantity` parameter represents the total quantity of items
111
- * that need to be processed or handled.
112
- * @param {number} unitSize - The `unitSize` parameter represents the size of each unit or package. It
113
- * is used in the `calcMinUnitsRequired` function to calculate the minimum number of units required to
114
- * accommodate a total quantity of items.
115
- */
116
- const calcMinUnitsRequired = (totalQuantity, unitSize) => Math.floor((totalQuantity + unitSize - 1) / unitSize);
117
- exports.calcMinUnitsRequired = calcMinUnitsRequired;
118
- /**
119
- * The `roundFixed` function in TypeScript rounds a number to a specified number of decimal places.
120
- * @param {number} num - The `num` parameter is a number that you want to round to a certain number of
121
- * decimal places.
122
- * @param {number} [digit=10] - The `digit` parameter in the `roundFixed` function specifies the number
123
- * of decimal places to round the number to. By default, it is set to 10 if not provided explicitly.
124
- * @returns The function `roundFixed` returns a number that is rounded to the specified number of
125
- * decimal places (default is 10 decimal places).
126
- */
127
- const roundFixed = (num, digit = 10) => {
128
- const multiplier = Math.pow(10, digit);
129
- return Math.round(num * multiplier) / multiplier;
130
- };
131
- exports.roundFixed = roundFixed;
132
- /**
133
- * The function `isPrimitiveComparable` checks if a value is a primitive type that can be compared.
134
- * @param {unknown} value - The `value` parameter in the `isPrimitiveComparable` function is of type
135
- * `unknown`, which means it can be any type. The function checks if the `value` is a primitive type
136
- * that can be compared, such as number, bigint, string, or boolean.
137
- * @returns The function `isPrimitiveComparable` returns a boolean value indicating whether the input
138
- * `value` is a primitive value that can be compared using standard comparison operators (<, >, <=,
139
- * >=).
140
- */
141
- function isPrimitiveComparable(value) {
142
- const valueType = typeof value;
143
- if (valueType === 'number')
144
- return true;
145
- // if (valueType === 'number') return !Number.isNaN(value);
146
- return valueType === 'bigint' || valueType === 'string' || valueType === 'boolean';
147
- }
148
- /**
149
- * The function `tryObjectToPrimitive` attempts to convert an object to a comparable primitive value by
150
- * first checking the `valueOf` method and then the `toString` method.
151
- * @param {object} obj - The `obj` parameter in the `tryObjectToPrimitive` function is an object that
152
- * you want to convert to a primitive value. The function attempts to convert the object to a primitive
153
- * value by first checking if the object has a `valueOf` method. If the `valueOf` method exists, it
154
- * @returns The function `tryObjectToPrimitive` returns a value of type `ComparablePrimitive` if a
155
- * primitive comparable value is found within the object, or a string value if the object has a custom
156
- * `toString` method that does not return `'[object Object]'`. If neither condition is met, the
157
- * function returns `null`.
158
- */
159
- function tryObjectToPrimitive(obj) {
160
- if (typeof obj.valueOf === 'function') {
161
- const valueOfResult = obj.valueOf();
162
- if (valueOfResult !== obj) {
163
- if (isPrimitiveComparable(valueOfResult))
164
- return valueOfResult;
165
- if (typeof valueOfResult === 'object' && valueOfResult !== null)
166
- return tryObjectToPrimitive(valueOfResult);
167
- }
168
- }
169
- if (typeof obj.toString === 'function') {
170
- const stringResult = obj.toString();
171
- if (stringResult !== '[object Object]')
172
- return stringResult;
173
- }
174
- return null;
175
- }
176
- /**
177
- * The function `isComparable` in TypeScript checks if a value is comparable, handling primitive values
178
- * and objects with optional force comparison.
179
- * @param {unknown} value - The `value` parameter in the `isComparable` function represents the value
180
- * that you want to check if it is comparable. It can be of any type (`unknown`), and the function will
181
- * determine if it is comparable based on certain conditions.
182
- * @param [isForceObjectComparable=false] - The `isForceObjectComparable` parameter in the
183
- * `isComparable` function is a boolean flag that determines whether to treat non-primitive values as
184
- * comparable objects. When set to `true`, it forces the function to consider non-primitive values as
185
- * comparable objects, regardless of their type.
186
- * @returns The function `isComparable` returns a boolean value indicating whether the `value` is
187
- * considered comparable or not.
188
- */
189
- function isComparable(value, isForceObjectComparable = false) {
190
- if (value === null || value === undefined)
191
- return false;
192
- if (isPrimitiveComparable(value))
193
- return true;
194
- if (typeof value !== 'object')
195
- return false;
196
- if (value instanceof Date)
197
- return true;
198
- // if (value instanceof Date) return !Number.isNaN(value.getTime());
199
- if (isForceObjectComparable)
200
- return true;
201
- const comparableValue = tryObjectToPrimitive(value);
202
- if (comparableValue === null || comparableValue === undefined)
203
- return false;
204
- return isPrimitiveComparable(comparableValue);
205
- }
206
- exports.isComparable = isComparable;
207
- /**
208
- * Creates a trampoline thunk object.
209
- *
210
- * A "thunk" is a deferred computation — instead of performing a recursive call immediately,
211
- * it wraps the next step of the computation in a function. This allows recursive processes
212
- * to be executed iteratively, preventing stack overflows.
213
- *
214
- * @template T - The type of the final computation result.
215
- * @param computation - A function that, when executed, returns the next trampoline step.
216
- * @returns A TrampolineThunk object containing the deferred computation.
217
- */
218
- const makeTrampolineThunk = (computation) => ({
219
- isThunk: true,
220
- fn: computation // The deferred computation function
221
- });
222
- exports.makeTrampolineThunk = makeTrampolineThunk;
223
- /**
224
- * Type guard to check whether a given value is a TrampolineThunk.
225
- *
226
- * This function is used to distinguish between a final computation result (value)
227
- * and a deferred computation (thunk).
228
- *
229
- * @template T - The type of the value being checked.
230
- * @param value - The value to test.
231
- * @returns True if the value is a valid TrampolineThunk, false otherwise.
232
- */
233
- const isTrampolineThunk = (value) => typeof value === 'object' && // Must be an object
234
- value !== null && // Must not be null
235
- 'isThunk' in value && // Must have the 'isThunk' property
236
- value.isThunk; // The flag must be true
237
- exports.isTrampolineThunk = isTrampolineThunk;
238
- /**
239
- * Executes a trampoline computation until a final (non-thunk) result is obtained.
240
- *
241
- * The trampoline function repeatedly invokes the deferred computations (thunks)
242
- * in an iterative loop. This avoids deep recursive calls and prevents stack overflow,
243
- * which is particularly useful for implementing recursion in a stack-safe manner.
244
- *
245
- * @template T - The type of the final result.
246
- * @param initial - The initial Trampoline value or thunk to start execution from.
247
- * @returns The final result of the computation (a non-thunk value).
248
- */
249
- function trampoline(initial) {
250
- let current = initial; // Start with the initial trampoline value
251
- while ((0, exports.isTrampolineThunk)(current)) {
252
- // Keep unwrapping while we have thunks
253
- current = current.fn(); // Execute the deferred function to get the next step
254
- }
255
- return current; // Once no thunks remain, return the final result
256
- }
257
- exports.trampoline = trampoline;
258
- /**
259
- * Wraps a recursive function inside a trampoline executor.
260
- *
261
- * This function transforms a potentially recursive function (that returns a Trampoline<Result>)
262
- * into a *stack-safe* function that executes iteratively using the `trampoline` runner.
263
- *
264
- * In other words, it allows you to write functions that look recursive,
265
- * but actually run in constant stack space.
266
- *
267
- * @template Args - The tuple type representing the argument list of the original function.
268
- * @template Result - The final return type after all trampoline steps are resolved.
269
- *
270
- * @param fn - A function that performs a single step of computation
271
- * and returns a Trampoline (either a final value or a deferred thunk).
272
- *
273
- * @returns A new function with the same arguments, but which automatically
274
- * runs the trampoline process and returns the *final result* instead
275
- * of a Trampoline.
276
- *
277
- * @example
278
- * // Example: Computing factorial in a stack-safe way
279
- * const factorial = makeTrampoline(function fact(n: number, acc: number = 1): Trampoline<number> {
280
- * return n === 0
281
- * ? acc
282
- * : makeTrampolineThunk(() => fact(n - 1, acc * n));
283
- * });
284
- *
285
- * console.log(factorial(100000)); // Works without stack overflow
286
- */
287
- function makeTrampoline(fn // A function that returns a trampoline step
288
- ) {
289
- // Return a wrapped function that automatically runs the trampoline execution loop
290
- return (...args) => trampoline(fn(...args));
291
- }
292
- exports.makeTrampoline = makeTrampoline;
293
- /**
294
- * Executes an asynchronous trampoline computation until a final (non-thunk) result is obtained.
295
- *
296
- * This function repeatedly invokes asynchronous deferred computations (thunks)
297
- * in an iterative loop. Each thunk may return either a Trampoline<T> or a Promise<Trampoline<T>>.
298
- *
299
- * It ensures that asynchronous recursive functions can run without growing the call stack,
300
- * making it suitable for stack-safe async recursion.
301
- *
302
- * @template T - The type of the final result.
303
- * @param initial - The initial Trampoline or Promise of Trampoline to start execution from.
304
- * @returns A Promise that resolves to the final result (a non-thunk value).
305
- */
306
- function asyncTrampoline(initial) {
307
- return __awaiter(this, void 0, void 0, function* () {
308
- let current = yield initial; // Wait for the initial step to resolve if it's a Promise
309
- // Keep executing thunks until we reach a non-thunk (final) value
310
- while ((0, exports.isTrampolineThunk)(current)) {
311
- current = yield current.fn(); // Execute the thunk function (may be async)
312
- }
313
- // Once the final value is reached, return it
314
- return current;
315
- });
316
- }
317
- exports.asyncTrampoline = asyncTrampoline;
318
- /**
319
- * Wraps an asynchronous recursive function inside an async trampoline executor.
320
- *
321
- * This helper transforms a recursive async function that returns a Trampoline<Result>
322
- * (or Promise<Trampoline<Result>>) into a *stack-safe* async function that executes
323
- * iteratively via the `asyncTrampoline` runner.
324
- *
325
- * @template Args - The tuple type representing the argument list of the original function.
326
- * @template Result - The final return type after all async trampoline steps are resolved.
327
- *
328
- * @param fn - An async or sync function that performs a single step of computation
329
- * and returns a Trampoline (either a final value or a deferred thunk).
330
- *
331
- * @returns An async function with the same arguments, but which automatically
332
- * runs the trampoline process and resolves to the *final result*.
333
- *
334
- * @example
335
- * // Example: Async factorial using trampoline
336
- * const asyncFactorial = makeAsyncTrampoline(async function fact(
337
- * n: number,
338
- * acc: number = 1
339
- * ): Promise<Trampoline<number>> {
340
- * return n === 0
341
- * ? acc
342
- * : makeTrampolineThunk(() => fact(n - 1, acc * n));
343
- * });
344
- *
345
- * asyncFactorial(100000).then(console.log); // Works without stack overflow
346
- */
347
- function makeAsyncTrampoline(fn) {
348
- // Return a wrapped async function that runs through the async trampoline loop
349
- return (...args) => __awaiter(this, void 0, void 0, function* () {
350
- return asyncTrampoline(fn(...args));
351
- });
352
- }
353
- exports.makeAsyncTrampoline = makeAsyncTrampoline;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,12 +1,12 @@
1
- export * from './hash';
2
- export * from './linked-list';
3
- export * from './stack';
4
- export * from './queue';
5
- export * from './graph';
6
1
  export * from './binary-tree';
2
+ export * from './graph';
3
+ export * from './linked-list';
7
4
  export * from './heap';
8
- export * from './priority-queue';
9
5
  export * from './matrix';
6
+ export * from './hash';
7
+ export * from './priority-queue';
8
+ export * from './queue';
9
+ export * from './stack';
10
+ export * from './tree';
10
11
  export * from './trie';
11
12
  export * from './base';
12
- export * from './tree';
@@ -1,2 +1,2 @@
1
- export * from './matrix';
2
1
  export * from './navigator';
2
+ export * from './matrix';
File without changes