@nejs/basic-extensions 2.21.0 → 2.22.6

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 (270) hide show
  1. package/.idea/markdown.xml +8 -0
  2. package/.idea/modules.xml +8 -0
  3. package/.idea/ne-basic-extensions.iml +8 -0
  4. package/.idea/vcs.xml +6 -0
  5. package/CODE_STYLE.md +393 -0
  6. package/CODING_PHILOSOPHY.md +36 -0
  7. package/DOCUMENTATION_GUIDELINES.md +221 -0
  8. package/README.md +78 -4
  9. package/dist/@nejs/basic-extensions.bundle.2.22.6.js +25 -0
  10. package/dist/@nejs/basic-extensions.bundle.2.22.6.js.map +7 -0
  11. package/dist/cjs/classes/index.cjs +11129 -0
  12. package/dist/cjs/classes/index.cjs.map +7 -0
  13. package/dist/cjs/index.cjs +15191 -0
  14. package/dist/cjs/index.cjs.map +7 -0
  15. package/dist/cjs/utils/index.cjs +3954 -0
  16. package/dist/cjs/utils/index.cjs.map +7 -0
  17. package/dist/esm/basic-extensions.mjs +25 -0
  18. package/dist/esm/basic-extensions.mjs.map +7 -0
  19. package/package.json +16 -22
  20. package/repl.bootstrap.js +4 -7
  21. package/repl.history +30 -30
  22. package/src/big.int.extension.js +171 -45
  23. package/src/classes/enumeration.js +466 -0
  24. package/src/classes/index.js +5 -1
  25. package/src/index.js +5 -1
  26. package/src/math.extension.js +73 -0
  27. package/src/number.extension.js +18 -0
  28. package/src/regular.expression.extensions.js +0 -35
  29. package/src/utils/toolkit.js +699 -516
  30. package/tests/arrayextensions.test.js +3 -3
  31. package/tests/index.test.js +3 -1
  32. package/tests/newClasses/asyncIterable.test.js +3 -3
  33. package/tests/newClasses/deferred.test.js +3 -3
  34. package/tests/newClasses/descriptor.test.js +3 -3
  35. package/tests/newClasses/iterable.test.js +3 -3
  36. package/tests/newClasses/refmap.test.js +3 -3
  37. package/tests/newClasses/refset.test.js +3 -3
  38. package/tests/objectextensions.test.js +3 -3
  39. package/tests/setextensions.test.js +3 -3
  40. package/tests/stringextensions.test.js +3 -2
  41. package/tests/utils/descriptor.utils.test.js +1 -1
  42. package/tests/utils/toolkit.test.js +429 -163
  43. package/.esdoc.json +0 -9
  44. package/.vscode/settings.json +0 -5
  45. package/bin/build +0 -27
  46. package/bin/clean +0 -14
  47. package/bin/esbuild +0 -91
  48. package/bin/fixup +0 -13
  49. package/bin/repl.basics.js +0 -584
  50. package/bin/repl.signature.js +0 -63
  51. package/bin/version +0 -100
  52. package/dist/@nejs/basic-extensions.bundle.2.21.0.js +0 -25
  53. package/dist/@nejs/basic-extensions.bundle.2.21.0.js.map +0 -7
  54. package/dist/cjs/array.extensions.d.ts +0 -39
  55. package/dist/cjs/array.extensions.js +0 -477
  56. package/dist/cjs/array.extensions.js.map +0 -1
  57. package/dist/cjs/big.int.extension.d.ts +0 -31
  58. package/dist/cjs/big.int.extension.js +0 -165
  59. package/dist/cjs/big.int.extension.js.map +0 -1
  60. package/dist/cjs/classes/asyncIterable.d.ts +0 -126
  61. package/dist/cjs/classes/asyncIterable.js +0 -209
  62. package/dist/cjs/classes/asyncIterable.js.map +0 -1
  63. package/dist/cjs/classes/deferred.d.ts +0 -146
  64. package/dist/cjs/classes/deferred.js +0 -291
  65. package/dist/cjs/classes/deferred.js.map +0 -1
  66. package/dist/cjs/classes/descriptor.d.ts +0 -334
  67. package/dist/cjs/classes/descriptor.js +0 -537
  68. package/dist/cjs/classes/descriptor.js.map +0 -1
  69. package/dist/cjs/classes/enum.d.ts +0 -50
  70. package/dist/cjs/classes/enum.js +0 -405
  71. package/dist/cjs/classes/enum.js.map +0 -1
  72. package/dist/cjs/classes/index.d.ts +0 -15
  73. package/dist/cjs/classes/index.js +0 -63
  74. package/dist/cjs/classes/index.js.map +0 -1
  75. package/dist/cjs/classes/introspector.d.ts +0 -20
  76. package/dist/cjs/classes/introspector.js +0 -130
  77. package/dist/cjs/classes/introspector.js.map +0 -1
  78. package/dist/cjs/classes/iterable.d.ts +0 -169
  79. package/dist/cjs/classes/iterable.js +0 -268
  80. package/dist/cjs/classes/iterable.js.map +0 -1
  81. package/dist/cjs/classes/param.parser.d.ts +0 -221
  82. package/dist/cjs/classes/param.parser.js +0 -242
  83. package/dist/cjs/classes/param.parser.js.map +0 -1
  84. package/dist/cjs/classes/pluggable.proxy.d.ts +0 -153
  85. package/dist/cjs/classes/pluggable.proxy.js +0 -444
  86. package/dist/cjs/classes/pluggable.proxy.js.map +0 -1
  87. package/dist/cjs/classes/property.d.ts +0 -79
  88. package/dist/cjs/classes/property.js +0 -284
  89. package/dist/cjs/classes/property.js.map +0 -1
  90. package/dist/cjs/classes/refmap.d.ts +0 -238
  91. package/dist/cjs/classes/refmap.js +0 -421
  92. package/dist/cjs/classes/refmap.js.map +0 -1
  93. package/dist/cjs/classes/refset.d.ts +0 -186
  94. package/dist/cjs/classes/refset.js +0 -370
  95. package/dist/cjs/classes/refset.js.map +0 -1
  96. package/dist/cjs/classes/symkeys.d.ts +0 -349
  97. package/dist/cjs/classes/symkeys.js +0 -510
  98. package/dist/cjs/classes/symkeys.js.map +0 -1
  99. package/dist/cjs/classes/type.d.ts +0 -56
  100. package/dist/cjs/classes/type.js +0 -405
  101. package/dist/cjs/classes/type.js.map +0 -1
  102. package/dist/cjs/function.extensions.d.ts +0 -12
  103. package/dist/cjs/function.extensions.js +0 -758
  104. package/dist/cjs/function.extensions.js.map +0 -1
  105. package/dist/cjs/global.this.d.ts +0 -2
  106. package/dist/cjs/global.this.js +0 -300
  107. package/dist/cjs/global.this.js.map +0 -1
  108. package/dist/cjs/index.d.ts +0 -31
  109. package/dist/cjs/index.js +0 -226
  110. package/dist/cjs/index.js.map +0 -1
  111. package/dist/cjs/json.extensions.d.ts +0 -2
  112. package/dist/cjs/json.extensions.js +0 -109
  113. package/dist/cjs/json.extensions.js.map +0 -1
  114. package/dist/cjs/map.extensions.d.ts +0 -3
  115. package/dist/cjs/map.extensions.js +0 -143
  116. package/dist/cjs/map.extensions.js.map +0 -1
  117. package/dist/cjs/number.extension.d.ts +0 -44
  118. package/dist/cjs/number.extension.js +0 -261
  119. package/dist/cjs/number.extension.js.map +0 -1
  120. package/dist/cjs/object.extensions.d.ts +0 -33
  121. package/dist/cjs/object.extensions.js +0 -1091
  122. package/dist/cjs/object.extensions.js.map +0 -1
  123. package/dist/cjs/package.json +0 -3
  124. package/dist/cjs/proxy.extensions.d.ts +0 -2
  125. package/dist/cjs/proxy.extensions.js +0 -207
  126. package/dist/cjs/proxy.extensions.js.map +0 -1
  127. package/dist/cjs/reflect.extensions.d.ts +0 -14
  128. package/dist/cjs/reflect.extensions.js +0 -316
  129. package/dist/cjs/reflect.extensions.js.map +0 -1
  130. package/dist/cjs/regular.expression.extensions.d.ts +0 -2
  131. package/dist/cjs/regular.expression.extensions.js +0 -423
  132. package/dist/cjs/regular.expression.extensions.js.map +0 -1
  133. package/dist/cjs/set.extensions.d.ts +0 -40
  134. package/dist/cjs/set.extensions.js +0 -355
  135. package/dist/cjs/set.extensions.js.map +0 -1
  136. package/dist/cjs/string.extensions.d.ts +0 -23
  137. package/dist/cjs/string.extensions.js +0 -704
  138. package/dist/cjs/string.extensions.js.map +0 -1
  139. package/dist/cjs/symbol.extensions.d.ts +0 -11
  140. package/dist/cjs/symbol.extensions.js +0 -735
  141. package/dist/cjs/symbol.extensions.js.map +0 -1
  142. package/dist/cjs/utils/copy.object.d.ts +0 -408
  143. package/dist/cjs/utils/copy.object.js +0 -720
  144. package/dist/cjs/utils/copy.object.js.map +0 -1
  145. package/dist/cjs/utils/descriptor.utils.d.ts +0 -298
  146. package/dist/cjs/utils/descriptor.utils.js +0 -889
  147. package/dist/cjs/utils/descriptor.utils.js.map +0 -1
  148. package/dist/cjs/utils/index.d.ts +0 -75
  149. package/dist/cjs/utils/index.js +0 -61
  150. package/dist/cjs/utils/index.js.map +0 -1
  151. package/dist/cjs/utils/stdout.d.ts +0 -742
  152. package/dist/cjs/utils/stdout.js +0 -1042
  153. package/dist/cjs/utils/stdout.js.map +0 -1
  154. package/dist/cjs/utils/toolkit.d.ts +0 -1898
  155. package/dist/cjs/utils/toolkit.js +0 -1378
  156. package/dist/cjs/utils/toolkit.js.map +0 -1
  157. package/dist/cjs/weakref.extensions.d.ts +0 -2
  158. package/dist/cjs/weakref.extensions.js +0 -19
  159. package/dist/cjs/weakref.extensions.js.map +0 -1
  160. package/dist/mjs/array.extensions.d.ts +0 -39
  161. package/dist/mjs/array.extensions.js +0 -474
  162. package/dist/mjs/array.extensions.js.map +0 -1
  163. package/dist/mjs/big.int.extension.d.ts +0 -31
  164. package/dist/mjs/big.int.extension.js +0 -162
  165. package/dist/mjs/big.int.extension.js.map +0 -1
  166. package/dist/mjs/classes/asyncIterable.d.ts +0 -126
  167. package/dist/mjs/classes/asyncIterable.js +0 -204
  168. package/dist/mjs/classes/asyncIterable.js.map +0 -1
  169. package/dist/mjs/classes/deferred.d.ts +0 -146
  170. package/dist/mjs/classes/deferred.js +0 -287
  171. package/dist/mjs/classes/deferred.js.map +0 -1
  172. package/dist/mjs/classes/descriptor.d.ts +0 -334
  173. package/dist/mjs/classes/descriptor.js +0 -533
  174. package/dist/mjs/classes/descriptor.js.map +0 -1
  175. package/dist/mjs/classes/enum.d.ts +0 -50
  176. package/dist/mjs/classes/enum.js +0 -400
  177. package/dist/mjs/classes/enum.js.map +0 -1
  178. package/dist/mjs/classes/index.d.ts +0 -15
  179. package/dist/mjs/classes/index.js +0 -46
  180. package/dist/mjs/classes/index.js.map +0 -1
  181. package/dist/mjs/classes/introspector.d.ts +0 -20
  182. package/dist/mjs/classes/introspector.js +0 -126
  183. package/dist/mjs/classes/introspector.js.map +0 -1
  184. package/dist/mjs/classes/iterable.d.ts +0 -169
  185. package/dist/mjs/classes/iterable.js +0 -263
  186. package/dist/mjs/classes/iterable.js.map +0 -1
  187. package/dist/mjs/classes/param.parser.d.ts +0 -221
  188. package/dist/mjs/classes/param.parser.js +0 -238
  189. package/dist/mjs/classes/param.parser.js.map +0 -1
  190. package/dist/mjs/classes/pluggable.proxy.d.ts +0 -153
  191. package/dist/mjs/classes/pluggable.proxy.js +0 -438
  192. package/dist/mjs/classes/pluggable.proxy.js.map +0 -1
  193. package/dist/mjs/classes/property.d.ts +0 -79
  194. package/dist/mjs/classes/property.js +0 -280
  195. package/dist/mjs/classes/property.js.map +0 -1
  196. package/dist/mjs/classes/refmap.d.ts +0 -238
  197. package/dist/mjs/classes/refmap.js +0 -417
  198. package/dist/mjs/classes/refmap.js.map +0 -1
  199. package/dist/mjs/classes/refset.d.ts +0 -186
  200. package/dist/mjs/classes/refset.js +0 -366
  201. package/dist/mjs/classes/refset.js.map +0 -1
  202. package/dist/mjs/classes/symkeys.d.ts +0 -349
  203. package/dist/mjs/classes/symkeys.js +0 -506
  204. package/dist/mjs/classes/symkeys.js.map +0 -1
  205. package/dist/mjs/classes/type.d.ts +0 -56
  206. package/dist/mjs/classes/type.js +0 -401
  207. package/dist/mjs/classes/type.js.map +0 -1
  208. package/dist/mjs/function.extensions.d.ts +0 -12
  209. package/dist/mjs/function.extensions.js +0 -755
  210. package/dist/mjs/function.extensions.js.map +0 -1
  211. package/dist/mjs/global.this.d.ts +0 -2
  212. package/dist/mjs/global.this.js +0 -264
  213. package/dist/mjs/global.this.js.map +0 -1
  214. package/dist/mjs/index.d.ts +0 -31
  215. package/dist/mjs/index.js +0 -204
  216. package/dist/mjs/index.js.map +0 -1
  217. package/dist/mjs/json.extensions.d.ts +0 -2
  218. package/dist/mjs/json.extensions.js +0 -106
  219. package/dist/mjs/json.extensions.js.map +0 -1
  220. package/dist/mjs/map.extensions.d.ts +0 -3
  221. package/dist/mjs/map.extensions.js +0 -140
  222. package/dist/mjs/map.extensions.js.map +0 -1
  223. package/dist/mjs/number.extension.d.ts +0 -44
  224. package/dist/mjs/number.extension.js +0 -258
  225. package/dist/mjs/number.extension.js.map +0 -1
  226. package/dist/mjs/object.extensions.d.ts +0 -33
  227. package/dist/mjs/object.extensions.js +0 -1088
  228. package/dist/mjs/object.extensions.js.map +0 -1
  229. package/dist/mjs/package.json +0 -3
  230. package/dist/mjs/proxy.extensions.d.ts +0 -2
  231. package/dist/mjs/proxy.extensions.js +0 -204
  232. package/dist/mjs/proxy.extensions.js.map +0 -1
  233. package/dist/mjs/reflect.extensions.d.ts +0 -14
  234. package/dist/mjs/reflect.extensions.js +0 -313
  235. package/dist/mjs/reflect.extensions.js.map +0 -1
  236. package/dist/mjs/regular.expression.extensions.d.ts +0 -2
  237. package/dist/mjs/regular.expression.extensions.js +0 -420
  238. package/dist/mjs/regular.expression.extensions.js.map +0 -1
  239. package/dist/mjs/set.extensions.d.ts +0 -40
  240. package/dist/mjs/set.extensions.js +0 -352
  241. package/dist/mjs/set.extensions.js.map +0 -1
  242. package/dist/mjs/string.extensions.d.ts +0 -23
  243. package/dist/mjs/string.extensions.js +0 -701
  244. package/dist/mjs/string.extensions.js.map +0 -1
  245. package/dist/mjs/symbol.extensions.d.ts +0 -11
  246. package/dist/mjs/symbol.extensions.js +0 -732
  247. package/dist/mjs/symbol.extensions.js.map +0 -1
  248. package/dist/mjs/utils/copy.object.d.ts +0 -408
  249. package/dist/mjs/utils/copy.object.js +0 -702
  250. package/dist/mjs/utils/copy.object.js.map +0 -1
  251. package/dist/mjs/utils/descriptor.utils.d.ts +0 -298
  252. package/dist/mjs/utils/descriptor.utils.js +0 -875
  253. package/dist/mjs/utils/descriptor.utils.js.map +0 -1
  254. package/dist/mjs/utils/index.d.ts +0 -75
  255. package/dist/mjs/utils/index.js +0 -45
  256. package/dist/mjs/utils/index.js.map +0 -1
  257. package/dist/mjs/utils/stdout.d.ts +0 -742
  258. package/dist/mjs/utils/stdout.js +0 -1037
  259. package/dist/mjs/utils/stdout.js.map +0 -1
  260. package/dist/mjs/utils/toolkit.d.ts +0 -1898
  261. package/dist/mjs/utils/toolkit.js +0 -1373
  262. package/dist/mjs/utils/toolkit.js.map +0 -1
  263. package/dist/mjs/weakref.extensions.d.ts +0 -2
  264. package/dist/mjs/weakref.extensions.js +0 -16
  265. package/dist/mjs/weakref.extensions.js.map +0 -1
  266. package/jsdoc-config.json +0 -31
  267. package/tsconfig.base.json +0 -28
  268. package/tsconfig.cjs.json +0 -8
  269. package/tsconfig.esm.json +0 -8
  270. package/vitest.config.js +0 -7
@@ -1,162 +0,0 @@
1
- import { Patch } from '@nejs/extension';
2
- /**
3
- * `BigIntExtensions` is a patch for the JavaScript built-in `BigInt` class.
4
- * It adds utility methods to the `BigInt` class without modifying the global
5
- * namespace directly. This patch includes methods for checking if a value is
6
- * a `BigInt` and conditionally returning a value based on whether the supplied
7
- * value is a `BigInt` or not.
8
- *
9
- * @type {Patch}
10
- * @example
11
- * import { BigIntExtensions } from 'big.int.extension.js'
12
- *
13
- * BigIntExtensions.apply()
14
- * // Now the `BigInt` class has additional methods available
15
- */
16
- export const BigIntExtensions = new Patch(BigInt, {
17
- /**
18
- * Determines if the supplied `value` is a `BigInt`. This check is
19
- * performed by first checking the `typeof` the `value` and then
20
- * checking to see if the `value` is an `instanceof` `BigInt`
21
- *
22
- * @param {*} value The value that needs to be checked to determine
23
- * if it is a `BigInt` or not
24
- * @returns {boolean} `true` if the supplied `value` is a `BigInt`,
25
- * `false` otherwise
26
- *
27
- * @example
28
- * const bigInt = 1234567890123456789012345678901234567890n
29
- * isBigInt(bigInt) // true
30
- * isBigInt(1234567890123456789012345678901234567890) // false
31
- * isBigInt('1234567890123456789012345678901234567890') // false
32
- * isBigInt(BigInt('1234567890123456789012345678901234567890')) // true
33
- */
34
- isBigInt(value) {
35
- return typeof value === 'bigint' || value instanceof BigInt;
36
- },
37
- /**
38
- * Conditionally returns a value based on whether the supplied
39
- * `value` is a `BigInt` or not. If the `value` is a `BigInt`,
40
- * the `thenValue` will be returned. If it is not a `BigInt`,
41
- * the `elseValue` will be returned instead.
42
- *
43
- * @param {any} value The value to check to determine if it is a
44
- * `BigInt`
45
- * @param {any} thenValue The value to return if the supplied
46
- * `value` is a `BigInt`
47
- * @param {any} elseValue The value to return if the supplied
48
- * `value` is not a `BigInt`
49
- * @returns {any} Either the `thenValue` or `elseValue` depending
50
- * on if the supplied `value` is a `BigInt`
51
- *
52
- * @example
53
- * const bigInt = 1234567890123456789012345678901234567890n
54
- * const num = 42
55
- * ifBigInt(bigInt, 'is a BigInt', 'not a BigInt')
56
- * // 'is a BigInt'
57
- * ifBigInt(num, 'is a BigInt', 'not a BigInt')
58
- * // 'not a BigInt'
59
- */
60
- ifBigInt(value, thenValue, elseValue) {
61
- return isThenElse(this.isBigInt(value), thenValue, elseValue);
62
- },
63
- });
64
- const { isBigInt: pIsBigInt, ifBigInt: pIfBigInt } = BigIntExtensions.patches;
65
- /**
66
- * `BigIntPrototypeExtensions` is a patch for the JavaScript built-in
67
- * `BigInt.prototype`. It adds utility methods to the `BigInt` prototype
68
- * without modifying the global namespace directly. This patch includes
69
- * methods for checking if a value is a BigInt and conditionally returning
70
- * a value based on whether the supplied value is a BigInt or not.
71
- *
72
- * @type {Patch}
73
- * @example
74
- * import { BigIntPrototypeExtensions } from 'big.int.extension.js'
75
- *
76
- * BigIntPrototypeExtensions.apply()
77
- * // Now the `BigInt` prototype has additional methods available
78
- */
79
- export const BigIntPrototypeExtensions = new Patch(BigInt.prototype, {
80
- /**
81
- * A getter method that returns an object representation of the BigInt
82
- * instance.
83
- *
84
- * This method wraps the BigInt instance in an object, allowing it to be
85
- * treated as an object. The returned object is created using the `Object()`
86
- * constructor, which takes the BigInt instance as its argument.
87
- *
88
- * @type {Object}
89
- * @readonly
90
- *
91
- * @example
92
- * const bigInt = 1234567890123456789012345678901234567890n
93
- * console.log(typeof bigInt) // 'bigint'
94
- * console.log(typeof bigInt.instance) // 'object'
95
- */
96
- get instance() {
97
- return Object(this);
98
- },
99
- /**
100
- * A getter method that checks if the current instance is a BigInt.
101
- *
102
- * This method uses the `pIsBigInt` function from the `BigIntExtensions`
103
- * patch to determine if the current instance (`this`) is a BigInt.
104
- *
105
- * @type {boolean}
106
- * @readonly
107
- *
108
- * @example
109
- * const bigInt = 1234567890123456789012345678901234567890n
110
- * console.log(bigInt.isBigInt) // Output: true
111
- *
112
- * const notBigInt = 42
113
- * console.log(notBigInt.isBigInt) // Output: false
114
- */
115
- get isBigInt() {
116
- return pIsBigInt(this);
117
- },
118
- /**
119
- * Checks if the current object is a BigInt and returns the corresponding
120
- * value based on the result.
121
- *
122
- * This method uses the `pIfBigInt` function from the `BigIntExtensions`
123
- * patch to determine if the current object (`this`) is a BigInt. If it is
124
- * a BigInt, the `thenValue` is returned. Otherwise, the `elseValue` is
125
- * returned.
126
- *
127
- * @param {any} thenValue - The value to return if the current object
128
- * is a BigInt.
129
- * @param {any} elseValue - The value to return if the current object
130
- * is not a BigInt.
131
- * @returns {any} The `thenValue` if the current object is a BigInt, or
132
- * the `elseValue` if it is not a BigInt.
133
- *
134
- * @example
135
- * const bigInt = 1234567890123456789012345678901234567890n
136
- * // 'Is a BigInt'
137
- * console.log(bigInt.ifBigInt('Is a BigInt', 'Not a BigInt'))
138
- *
139
- * const notBigInt = 42
140
- * // 'Not a BigInt'
141
- * console.log(notBigInt.ifBigInt('Is a BigInt', 'Not a BigInt'))
142
- */
143
- ifBigInt(thenValue, elseValue) {
144
- return pIfBigInt(this, thenValue, elseValue);
145
- },
146
- });
147
- // NOTE to self; this is repeated here otherwise a circular reference from
148
- // Object<->Function<->Global occurs. See original source in global.this.js
149
- // {@see globalThis.isThenElse}
150
- function isThenElse(bv, tv, ev) {
151
- function isFunction(value) { typeof value === 'function'; }
152
- if (arguments.length > 1) {
153
- var _then = isFunction(tv) ? tv(bv) : tv;
154
- if (arguments.length > 2) {
155
- var _else = isFunction(ev) ? tv(bv) : ev;
156
- return bv ? _then : _else;
157
- }
158
- return bv || _then;
159
- }
160
- return bv;
161
- }
162
- //# sourceMappingURL=big.int.extension.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"big.int.extension.js","sourceRoot":"","sources":["../../src/big.int.extension.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;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AM,GAAG,CAAC,EAAE,CAAC;QACzB,IAAI,KAAK,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAAC,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnE,IAAI,KAAK,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAAC,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAA;QACrE,CAAC;QAAC,OAAO,EAAE,IAAI,KAAK,CAAC;IACvB,CAAC;IAAC,OAAO,EAAE,CAAA;AACb,CAAC"}
@@ -1,126 +0,0 @@
1
- /**
2
- * The AsyncIterable class extends the concept of Iterable to asynchronous
3
- * operations. It allows creating iterable objects where each element can be
4
- * an asynchronous entity, like a Promise. This class is particularly useful
5
- * when dealing with asynchronous data sources, such as API responses, file
6
- * reading in chunks, or any other data that is not immediately available but
7
- * arrives over time.
8
- */
9
- export class AsyncIterable {
10
- /**
11
- * Checks if a given value is an async iterable. This method determines if
12
- * the provided value has a `Symbol.asyncIterator` property that is an async
13
- * generator function. It's a precise way to identify if the value conforms
14
- * to the async iterable protocol using an async generator function.
15
- *
16
- * Note: This method specifically checks for async generator functions. Some
17
- * async iterables might use regular async functions that return an async
18
- * iterator, which this method won't identify.
19
- *
20
- * @param {*} value - The value to be checked for async iterability.
21
- * @returns {boolean} - Returns true if the value is an async iterable
22
- * implemented using an async generator function, false otherwise.
23
- */
24
- static isAsyncIterable(value: any): boolean;
25
- /**
26
- * Constructs an instance of AsyncIterable. Similar to Iterable, it can be
27
- * initialized with either an iterable object, an async generator function,
28
- * or individual elements. The elements can be promises, direct values, or a
29
- * mix of both. If the first argument is an iterable or an async generator
30
- * function, the instance is initialized with the elements from the iterable
31
- * or the generated elements from the async generator function, followed by
32
- * any additional arguments. If the first argument is not an iterable or an
33
- * async generator function, all arguments are treated as individual elements.
34
- *
35
- * @param {Iterable|AsyncGeneratorFunction|Promise|*} elementsOrFirstElement -
36
- * An iterable object, an async generator function, a Promise, or the first
37
- * element.
38
- * @param {...Promise|*} moreElements - Additional elements if the first
39
- * argument is not an iterable or an async generator function.
40
- */
41
- constructor(elementsOrFirstElement: Iterable<any> | AsyncGeneratorFunction | Promise<any> | any, ...moreElements: (Promise<any> | any)[]);
42
- /**
43
- * Implements the async iterable protocol. When an instance of AsyncIterable
44
- * is used in a `for await...of` loop, this async generator function is
45
- * invoked. It yields each element as a Promise, allowing asynchronous
46
- * iteration. Elements that are not Promises are automatically wrapped in
47
- * a resolved Promise to ensure consistency.
48
- *
49
- * @returns {AsyncGenerator} An async generator that yields each element as
50
- * a Promise.
51
- */
52
- [Symbol.asyncIterator](): AsyncGenerator;
53
- /**
54
- * Ensures that the constructor of this object instance's name
55
- * is returned if the string tag for this instance is queried
56
- *
57
- * @returns {string} the name of the class
58
- */
59
- get [Symbol.toStringTag](): string;
60
- #private;
61
- }
62
- /**
63
- * Being able to create a compliant `AsyncIterator` around any type of
64
- * iterable object. This can be wrapped around any type of object that
65
- * has a `[Symbol.asyncIterator]` property assigned to a generator
66
- * function.
67
- */
68
- export class AsyncIterator {
69
- /**
70
- * Creates a new `AsyncIterator` object instance.
71
- *
72
- * @param {object|AsyncGeneratorFunction} asyncIterable any object that has a
73
- * `[Symbol.asyncIterable]` property assigned to a generator function or an
74
- * async generator function itself.
75
- */
76
- constructor(asyncIterable: object | AsyncGeneratorFunction);
77
- /**
78
- * Returns a new `Array` derived from the iterable this object
79
- * wraps.
80
- *
81
- * @returns {array} a new `Array` generated from the wrapped
82
- * iterable. The method is generated from using an async for of
83
- * loop.
84
- */
85
- asArray(): any[];
86
- /**
87
- * Returns the actual iterable object passed to the constructor that
88
- * created this instance.
89
- *
90
- * @returns {object} the object containing the `[Symbol.iterator]`
91
- */
92
- get asyncIterable(): object;
93
- /**
94
- * The function retrieves the next value in the iterator. If the
95
- * the iterator has run its course, `reset()` can be invoked to
96
- * reset the pointer to the beginning of the iteration.
97
- *
98
- * @returns {any} the next value
99
- */
100
- next(): any;
101
- /**
102
- * Resets the async iterator to the beginning allowing it to be
103
- * iterated over again.
104
- */
105
- reset(): Promise<void>;
106
- /**
107
- * The existence of this symbol on the object instances, indicates that
108
- * it can be used in `for(.. of ..)` loops and its values can be
109
- * extracted from calls to `Array.from()`
110
- *
111
- * @returns {AsyncIterable} this is returned since this object is already
112
- * conforming to the expected JavaScript AsyncIterator interface
113
- */
114
- [Symbol.asyncIterator](): AsyncIterable;
115
- /**
116
- * Ensures that the constructor of this object instance's name
117
- * is returned if the string tag for this instance is queried
118
- *
119
- * @returns {string} the name of the class
120
- */
121
- get [Symbol.toStringTag](): string;
122
- #private;
123
- }
124
- export const AsyncIterableExtensions: Extension;
125
- export const AsyncIteratorExtensions: Extension;
126
- import { Extension } from '@nejs/extension';
@@ -1,204 +0,0 @@
1
- import { Extension } from '@nejs/extension';
2
- /**
3
- * The AsyncIterable class extends the concept of Iterable to asynchronous
4
- * operations. It allows creating iterable objects where each element can be
5
- * an asynchronous entity, like a Promise. This class is particularly useful
6
- * when dealing with asynchronous data sources, such as API responses, file
7
- * reading in chunks, or any other data that is not immediately available but
8
- * arrives over time.
9
- */
10
- export class AsyncIterable {
11
- /**
12
- * Private field to store the elements of the async iterable.
13
- * @private
14
- */
15
- #elements = [];
16
- /**
17
- * Constructs an instance of AsyncIterable. Similar to Iterable, it can be
18
- * initialized with either an iterable object, an async generator function,
19
- * or individual elements. The elements can be promises, direct values, or a
20
- * mix of both. If the first argument is an iterable or an async generator
21
- * function, the instance is initialized with the elements from the iterable
22
- * or the generated elements from the async generator function, followed by
23
- * any additional arguments. If the first argument is not an iterable or an
24
- * async generator function, all arguments are treated as individual elements.
25
- *
26
- * @param {Iterable|AsyncGeneratorFunction|Promise|*} elementsOrFirstElement -
27
- * An iterable object, an async generator function, a Promise, or the first
28
- * element.
29
- * @param {...Promise|*} moreElements - Additional elements if the first
30
- * argument is not an iterable or an async generator function.
31
- */
32
- constructor(elementsOrFirstElement, ...moreElements) {
33
- if (elementsOrFirstElement != null &&
34
- (typeof elementsOrFirstElement[Symbol.iterator] === 'function' ||
35
- typeof elementsOrFirstElement[Symbol.asyncIterator] === 'function')) {
36
- this.#elements = [...elementsOrFirstElement, ...moreElements];
37
- }
38
- else if (typeof elementsOrFirstElement === 'function' &&
39
- elementsOrFirstElement.constructor.name === 'AsyncGeneratorFunction') {
40
- this.#elements = elementsOrFirstElement();
41
- }
42
- else {
43
- this.#elements = [elementsOrFirstElement, ...moreElements];
44
- }
45
- }
46
- /**
47
- * Implements the async iterable protocol. When an instance of AsyncIterable
48
- * is used in a `for await...of` loop, this async generator function is
49
- * invoked. It yields each element as a Promise, allowing asynchronous
50
- * iteration. Elements that are not Promises are automatically wrapped in
51
- * a resolved Promise to ensure consistency.
52
- *
53
- * @returns {AsyncGenerator} An async generator that yields each element as
54
- * a Promise.
55
- */
56
- async *[Symbol.asyncIterator]() {
57
- for await (const element of this.#elements) {
58
- // No need to wrap as a promise here since `for await...of` can handle
59
- // both Promises and non-Promise values.
60
- yield element;
61
- }
62
- }
63
- /**
64
- * Ensures that the constructor of this object instance's name
65
- * is returned if the string tag for this instance is queried
66
- *
67
- * @returns {string} the name of the class
68
- */
69
- get [Symbol.toStringTag]() {
70
- return this.constructor.name;
71
- }
72
- /**
73
- * Checks if a given value is an async iterable. This method determines if
74
- * the provided value has a `Symbol.asyncIterator` property that is an async
75
- * generator function. It's a precise way to identify if the value conforms
76
- * to the async iterable protocol using an async generator function.
77
- *
78
- * Note: This method specifically checks for async generator functions. Some
79
- * async iterables might use regular async functions that return an async
80
- * iterator, which this method won't identify.
81
- *
82
- * @param {*} value - The value to be checked for async iterability.
83
- * @returns {boolean} - Returns true if the value is an async iterable
84
- * implemented using an async generator function, false otherwise.
85
- */
86
- static isAsyncIterable(value) {
87
- const type = Object.prototype.toString.call(value?.[Symbol.asyncIterator]);
88
- return type === '[object AsyncGeneratorFunction]';
89
- }
90
- }
91
- /**
92
- * Being able to create a compliant `AsyncIterator` around any type of
93
- * iterable object. This can be wrapped around any type of object that
94
- * has a `[Symbol.asyncIterator]` property assigned to a generator
95
- * function.
96
- */
97
- export class AsyncIterator {
98
- /**
99
- * Creates a new `AsyncIterator` object instance.
100
- *
101
- * @param {object|AsyncGeneratorFunction} asyncIterable any object that has a
102
- * `[Symbol.asyncIterable]` property assigned to a generator function or an
103
- * async generator function itself.
104
- */
105
- constructor(asyncIterable) {
106
- if (typeof asyncIterable === 'function' &&
107
- asyncIterable.constructor.name === 'AsyncGeneratorFunction') {
108
- this.#asyncIterable = asyncIterable();
109
- }
110
- else if (!asyncIterable ||
111
- !Reflect.has(asyncIterable, Symbol.asyncIterator)) {
112
- throw new TypeError('Value used to instantiate AsyncIterator is not an async iterable');
113
- }
114
- else {
115
- this.#asyncIterable = asyncIterable;
116
- }
117
- this.#asyncIterator = this.#asyncIterable[Symbol.asyncIterator]();
118
- }
119
- /**
120
- * Returns a new `Array` derived from the iterable this object
121
- * wraps.
122
- *
123
- * @returns {array} a new `Array` generated from the wrapped
124
- * iterable. The method is generated from using an async for of
125
- * loop.
126
- */
127
- async asArray() {
128
- const array = [];
129
- for await (const value of this) {
130
- array.push(value);
131
- }
132
- return array;
133
- }
134
- /**
135
- * Returns the actual iterable object passed to the constructor that
136
- * created this instance.
137
- *
138
- * @returns {object} the object containing the `[Symbol.iterator]`
139
- */
140
- get asyncIterable() {
141
- return this.#asyncIterable;
142
- }
143
- /**
144
- * The function retrieves the next value in the iterator. If the
145
- * the iterator has run its course, `reset()` can be invoked to
146
- * reset the pointer to the beginning of the iteration.
147
- *
148
- * @returns {any} the next value
149
- */
150
- async next() {
151
- const result = await this.#asyncIterator.next();
152
- if (result.done) {
153
- return { value: undefined, done: true };
154
- }
155
- else {
156
- return { value: result.value, done: false };
157
- }
158
- }
159
- /**
160
- * Resets the async iterator to the beginning allowing it to be
161
- * iterated over again.
162
- */
163
- async reset() {
164
- this.#asyncIterator = this.#asyncIterable[Symbol.asyncIterator]();
165
- }
166
- /**
167
- * The existence of this symbol on the object instances, indicates that
168
- * it can be used in `for(.. of ..)` loops and its values can be
169
- * extracted from calls to `Array.from()`
170
- *
171
- * @returns {AsyncIterable} this is returned since this object is already
172
- * conforming to the expected JavaScript AsyncIterator interface
173
- */
174
- [Symbol.asyncIterator]() {
175
- return this;
176
- }
177
- /**
178
- * Ensures that the constructor of this object instance's name
179
- * is returned if the string tag for this instance is queried
180
- *
181
- * @returns {string} the name of the class
182
- */
183
- get [Symbol.toStringTag]() {
184
- return this.constructor.name;
185
- }
186
- /**
187
- * The object from which its iterator functionality is derived.
188
- *
189
- * @type {object}
190
- * @private
191
- */
192
- #asyncIterable = null;
193
- /**
194
- * The results of a call to the iterable's `[Symbol.asyncIterator]`
195
- * generator function.
196
- *
197
- * @type {object}
198
- * @private
199
- */
200
- #asyncIterator = null;
201
- }
202
- export const AsyncIterableExtensions = new Extension(AsyncIterable);
203
- export const AsyncIteratorExtensions = new Extension(AsyncIterator);
204
- //# sourceMappingURL=asyncIterable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"asyncIterable.js","sourceRoot":"","sources":["../../../src/classes/asyncIterable.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C;;;;;;;GAOG;AACH,MAAM,OAAO,aAAa;IACxB;;;OAGG;IACH,SAAS,GAAG,EAAE,CAAC;IAEf;;;;;;;;;;;;;;;OAeG;IACH,YAAY,sBAAsB,EAAE,GAAG,YAAY;QACjD,IACE,sBAAsB,IAAI,IAAI;YAC9B,CAAC,OAAO,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,UAAU;gBAC7D,OAAO,sBAAsB,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,UAAU,CAAC,EACpE,CAAC;YACD,IAAI,CAAC,SA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AAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACH,cAAc,GAAG,IAAI,CAAC;IAEtB;;;;;;OAMG;IACH,cAAc,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,SAAS,CAAC,aAAa,CAAC,CAAA;AACnE,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,SAAS,CAAC,aAAa,CAAC,CAAA"}
@@ -1,146 +0,0 @@
1
- /**
2
- * Deferreds, which were first introduced by jQuery for browsers in the early
3
- * 2000s, are a way to manage asynchronous operations. They have been widely
4
- * used and replicated by engineers since then. Although the Promise class in
5
- * modern JavaScript provides a static method called `withResolvers` that
6
- * returns an object with similar properties to a Deferred, it is not directly
7
- * supported by Node.js.
8
- *
9
- * ```
10
- * const withResolvers = Promise.withResolvers()
11
- * Reflect.has(withResolvers, 'promise') // true
12
- * Reflect.has(withResolvers, 'resolve') // true
13
- * Reflect.has(withResolvers, 'reject') // true
14
- * ```
15
- *
16
- * This Deferred class extends the Promise class, allowing it to capture the
17
- * value or reason for easy access after resolution, akin to
18
- * {@link Promise.withResolvers}. As it extends {@link Promise}, it is
19
- * 'thenable' and works with `await` as if it were a native Promise. This
20
- * allows seamless integration with code expecting Promise-like objects.
21
- */
22
- export class Deferred extends Promise<any> {
23
- /**
24
- * A getter for the species symbol which returns a custom DeferredPromise
25
- * class. This class extends from Deferred and is used to ensure that the
26
- * constructor signature matches that of a Promise. The executor function
27
- * passed to the constructor of this class is used to initialize the Deferred
28
- * object with resolve and reject functions, similar to how a Promise would
29
- * be initialized.
30
- *
31
- * @returns {DeferredPromise} A DeferredPromise class that extends Deferred.
32
- */
33
- static get [Symbol.species](): DeferredPromise;
34
- /**
35
- * The constructor for Deferred instances. By default, a new Deferred will
36
- * have three important properties: `promise`, `resolve`, and `reject`.
37
- *
38
- * The constructor takes an object called `options`. It can have the
39
- * following properties:
40
- *
41
- * ```
42
- * interface BaseDeferredOptions {
43
- * // Deferreds store the value or reason. To turn this off, pass true
44
- * // to this option.
45
- * doNotTrackAnswers?: boolean;
46
- * }
47
- *
48
- * interface ResolveDeferredOptions {
49
- * // Passing in an option object with a resolve value will auto resolve
50
- * // the Deferred with your value. An error will be raised if both
51
- * // resolve and reject are supplied at the same time.
52
- * resolve?: (value: any) => void;
53
- * }
54
- *
55
- * interface RejectDeferredOptions {
56
- * // Passing in an option object with a reject reason will auto reject
57
- * // the Deferred with your reason. An error will be raised if both
58
- * // resolve and reject are supplied at the same time.
59
- * reject?: (reason: any) => void;
60
- * }
61
- *
62
- * type DeferredOptions = BaseDeferredOptions &
63
- * (ResolveDeferredOptions | RejectDeferredOptions)
64
- * ```
65
- *
66
- * @param {object} options see above for examples on supported options, but
67
- * when supplied, the constructor can take instructions on how to auto
68
- * resolve or reject the deferred created here.
69
- */
70
- constructor(options: object);
71
- /**
72
- * When the Deferred is settled with {@link Deferred.resolve}, the `value`
73
- * passed to that function will be set here as well.
74
- *
75
- * @type {*}
76
- */
77
- value: any;
78
- /**
79
- * When the Deferred is settled with {@link Deferred.reject}, the `reason`
80
- * passed to that rejection will also be stored here.
81
- *
82
- * @type {*}
83
- */
84
- reason: any;
85
- /**
86
- * Returns a boolean value that indicates whether or not this Deferred
87
- * has been settled (either resolve or reject have been invoked).
88
- *
89
- * @returns {boolean} `true` if either {@link Deferred.resolve} or
90
- * {@link Deferred.reject} have been invoked; `false` otherwise
91
- */
92
- get settled(): boolean;
93
- /**
94
- * A getter that returns a boolean indicating whether the Deferred instance
95
- * was rejected. This property can be used to check if the Deferred has been
96
- * settled with a rejection. It is particularly useful in scenarios where
97
- * the resolution status of the Deferred needs to be checked without
98
- * accessing the rejection reason or invoking any additional logic.
99
- *
100
- * @returns {boolean} `true` if the Deferred was rejected, otherwise `false`.
101
- */
102
- get wasRejected(): boolean;
103
- /**
104
- * A getter that returns a boolean indicating whether the Deferred instance
105
- * was resolved. This property is useful for checking if the Deferred has been
106
- * settled with a resolution, allowing for checks on the Deferred's status
107
- * without needing to access the resolved value or trigger any additional
108
- * logic.
109
- *
110
- * @returns {boolean} `true` if the Deferred was resolved, otherwise `false`.
111
- */
112
- get wasResolved(): boolean;
113
- /**
114
- * Accessor for the promise managed by this Deferred instance.
115
- *
116
- * This getter provides access to the internal promise which is controlled
117
- * by the Deferred's resolve and reject methods. It allows external code to
118
- * attach callbacks for the resolution or rejection of the Deferred without
119
- * the ability to directly resolve or reject it.
120
- *
121
- * @returns {Promise} The promise controlled by this Deferred instance.
122
- */
123
- get promise(): Promise<any>;
124
- /**
125
- * Resolves the Deferred with the given value. If the value is a thenable
126
- * (i.e., has a "then" method), the Deferred will "follow" that thenable,
127
- * adopting its eventual state; otherwise, the Deferred will be fulfilled
128
- * with the value. This function behaves the same as Promise.resolve.
129
- *
130
- * @param {*} value - The value to resolve the Deferred with.
131
- * @returns {Promise} A Promise that is resolved with the given value.
132
- */
133
- resolve(value: any): Promise<any>;
134
- /**
135
- * Rejects the Deferred with the given reason. This function behaves the
136
- * same as Promise.reject. The Deferred will be rejected with the provided
137
- * reason.
138
- *
139
- * @param {*} reason - The reason to reject the Deferred with.
140
- * @returns {Promise} A Promise that is rejected with the given reason.
141
- */
142
- reject(reason: any): Promise<any>;
143
- #private;
144
- }
145
- export const DeferredExtension: Extension;
146
- import { Extension } from '@nejs/extension';