@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,355 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SetPrototypeExtensions = exports.SetExtensions = void 0;
4
- const extension_1 = require("@nejs/extension");
5
- /**
6
- * `SetExtensions` is a constant that applies a patch to the global
7
- * `Set` constructor. This patch extends the `Set` with additional
8
- * methods and properties, enhancing its functionality.
9
- *
10
- * The `Patch` function takes two arguments: the target object to be patched
11
- * (in this case, `Set`), and an object containing the methods and
12
- * properties to be added to the target object.
13
- *
14
- * @example
15
- * // Using a method added by SetExtensions
16
- * const set = new Set();
17
- * console.log(Set.isSet(set)); // Output: true
18
- *
19
- * @const
20
- * @type {Patch}
21
- * @memberof module:set.extensions
22
- */
23
- exports.SetExtensions = new extension_1.Patch(Set, {
24
- [extension_1.Patch.kMutablyHidden]: {
25
- /**
26
- * Determines if the supplied `value` is a `Set` object. This check
27
- * is performed by first looking for the `Symbol.toStringTag` on the
28
- * `value` and checking to see if it is equal to the string "Set".
29
- * If that check fails, `instanceof` is used as a fallback to check
30
- * the prototype chain.
31
- *
32
- * @param {any} value the value that needs to be checked to determine
33
- * if it is a `Set` object or not
34
- * @returns {boolean} `true` if the supplied `value` is a `Set`
35
- * object, `false` otherwise
36
- *
37
- * @example
38
- * const set = new Set()
39
- * isSet(set) // true
40
- * isSet(new Map()) // false
41
- * isSet([]) // false
42
- * isSet({}) // false
43
- */
44
- isSet(value) {
45
- return value?.[Symbol.toStringTag] === Set.name || value instanceof Set;
46
- },
47
- /**
48
- * Conditionally returns a value based on whether the supplied
49
- * `value` is a `Set` object or not. If the `value` is a `Set`
50
- * object, the `thenValue` will be returned. If it is not a `Set`
51
- * object, the `elseValue` will be returned instead.
52
- *
53
- * @param {any} value the value to check to determine if it is a
54
- * `Set` object
55
- * @param {any} thenValue the value to return if the supplied
56
- * `value` is a `Set` object
57
- * @param {any} elseValue the value to return if the supplied
58
- * `value` is not a `Set` object
59
- * @returns {any} either the `thenValue` or `elseValue` depending
60
- * on if the supplied `value` is a `Set` object
61
- *
62
- * @example
63
- * const set = new Set()
64
- * const map = new Map()
65
- * ifSet(set, 'is a set', 'not a set') // 'is a set'
66
- * ifSet(map, 'is a set', 'not a set') // 'not a set'
67
- */
68
- ifSet(value, thenValue, elseValue) {
69
- return isThenElse(this.isSet(value), thenValue, elseValue);
70
- },
71
- }
72
- });
73
- const { isSet: pIsSet } = exports.SetExtensions.patches;
74
- /**
75
- * `SetPrototypeExtensions` is a constant that applies a patch to the
76
- * prototype of the built-in JavaScript `Set` object. This patch extends the
77
- * `Set` prototype with additional methods and properties, enhancing its
78
- * functionality.
79
- *
80
- * The `Patch` function takes two arguments: the target object to be patched
81
- * (in this case, `Set.prototype`), and an object containing the methods and
82
- * properties to be added to the target object.
83
- *
84
- * @example
85
- * // Using a method added by SetPrototypeExtensions
86
- * const mySet = new Set();
87
- * mySet.myNewMethod(); // Calls the new method added by the patch
88
- *
89
- * @const
90
- * @type {Patch}
91
- * @memberof module:set.extensions
92
- */
93
- exports.SetPrototypeExtensions = new extension_1.Patch(Set.prototype, {
94
- [extension_1.Patch.kMutablyHidden]: {
95
- /**
96
- * Merges multiple iterables into the set. Each element from the iterables
97
- * is added to the set, ensuring uniqueness of all elements. This method
98
- * mutates the original set.
99
- *
100
- * @param {...Iterable} iterables - One or more iterable objects (like Set
101
- * or Array) whose elements will be added to the set.
102
- */
103
- concat(...iterables) {
104
- for (const iterable of iterables) {
105
- if (typeof iterable === 'string' ||
106
- !Reflect.has(iterable, Symbol.iterator)) {
107
- this.add(iterable);
108
- continue;
109
- }
110
- for (const element of iterable) {
111
- this.add(element);
112
- }
113
- }
114
- },
115
- /**
116
- * Checks to see if any value within the `Set` loosely equals the supplied
117
- * value.
118
- *
119
- * @param {*} value any value that might be loosely equal to an item in the
120
- * set, as opposed to {@link Set.has} which is the equivalent of a strict or
121
- * triple equals (`===`) check
122
- * @returns {boolean} `true` if any value within the set is loosely equal to
123
- * the supplied value, `false` otherwise
124
- */
125
- contains(value) {
126
- for (const element of this) {
127
- if (value == element) {
128
- return true;
129
- }
130
- }
131
- return false;
132
- },
133
- /**
134
- * Checks if every element in the set passes the test implemented by the
135
- * provided function. The function is called with each element of the set.
136
- * Note: Since sets do not have indices, the index parameter is always NaN.
137
- *
138
- * @param {Function} everyFn - The function to test each element. Receives
139
- * the element, index (always NaN), and the set itself.
140
- * @param {Object} [thisArg] - Optional. Value to use as `this` when executing
141
- * `everyFn`.
142
- * @throws {TypeError} If `everyFn` is not a function.
143
- * @returns {boolean} True if every element passes the test, false otherwise.
144
- */
145
- every(everyFn, thisArg) {
146
- if (typeof everyFn !== 'function') {
147
- throw new TypeError(`everyFn must be a function! Received ${String(everyFn)}`);
148
- }
149
- let found = 0;
150
- for (const element of this) {
151
- if (everyFn.call(thisArg, element, NaN, this)) {
152
- found++;
153
- }
154
- }
155
- return (found === this.size);
156
- },
157
- /**
158
- * Finds the first element in the set satisfying the provided testing
159
- * function. If no elements satisfy the testing function, undefined is
160
- * returned. The function is called with each element of the set.
161
- * Note: Since sets do not have indices, the index parameter is always NaN.
162
- *
163
- * @param {Function} findFn - The function to execute on each element. It
164
- * receives the element, index (always NaN), and the set itself.
165
- * @param {Object} [thisArg] - Optional. Value to use as `this` when executing
166
- * `findFn`.
167
- * @throws {TypeError} If `findFn` is not a function.
168
- * @returns {*} The first element that satisfies `findFn`, or undefined.
169
- */
170
- find(findFn, thisArg) {
171
- if (typeof findFn !== 'function') {
172
- throw new TypeError(`findFn must be a function! Received ${String(findFn)}`);
173
- }
174
- for (const element of this) {
175
- const match = findFn.call(thisArg, element, NaN, this);
176
- if (match) {
177
- return element;
178
- }
179
- }
180
- return undefined;
181
- },
182
- /**
183
- * Finds the last element in the set satisfying the provided testing function.
184
- * If no elements satisfy the testing function, undefined is returned. The
185
- * function is called with each element of the set in reverse order.
186
- * Note: Since sets do not have indices, the index parameter is always NaN.
187
- *
188
- * @param {Function} findFn - The function to execute on each element. It
189
- * receives the element, index (always NaN), and the set itself.
190
- * @param {Object} [thisArg] - Optional. Value to use as `this` when executing
191
- * `findFn`.
192
- * @throws {TypeError} If `findFn` is not a function.
193
- * @returns {*} The last element that satisfies `findFn`, or undefined.
194
- */
195
- findLast(findFn, thisArg) {
196
- if (typeof findFn !== 'function') {
197
- throw new TypeError(`findFn must be a function! Received ${String(findFn)}`);
198
- }
199
- const found = [];
200
- for (const element of this) {
201
- const match = findFn.call(thisArg, element, NaN, this);
202
- if (match) {
203
- found.push(element);
204
- }
205
- }
206
- if (found.length) {
207
- return found[found.length - 1];
208
- }
209
- return undefined;
210
- },
211
- /**
212
- * Determines if the current object is a `Set` object.
213
- *
214
- * This is a getter that uses the `isSet` function from the
215
- * `SetExtensions` patch to check if the current object (`this`) is
216
- * a `Set` object.
217
- *
218
- * @type {boolean}
219
- * @readonly
220
- *
221
- * @example
222
- * const set = new Set()
223
- * console.log(set.isSet) // Output: true
224
- *
225
- * const notSet = {}
226
- * console.log(notSet.isSet) // Output: false
227
- */
228
- get isSet() {
229
- return pIsSet(this);
230
- },
231
- /**
232
- * Checks if the current object is a Set and returns the
233
- * corresponding value based on the result.
234
- *
235
- * This method uses the `isThenElse` function from the
236
- * `SetExtensions` patch to determine if the current object
237
- * (`this`) is a Set. If it is a Set, the `thenValue` is returned.
238
- * Otherwise, the `elseValue` is returned.
239
- *
240
- * @param {any} thenValue - The value to return if the current object
241
- * is a Set.
242
- * @param {any} elseValue - The value to return if the current object
243
- * is not a Set.
244
- * @returns {any} The `thenValue` if the current object is a Set, or
245
- * the `elseValue` if it is not a Set.
246
- *
247
- * @example
248
- * const set = new Set([1, 2, 3])
249
- * console.log(set.ifSet('Is a Set', 'Not a Set')) // 'Is a Set'
250
- *
251
- * const notSet = {}
252
- * console.log(notSet.ifSet('Is a Set', 'Not a Set')) // 'Not a Set'
253
- */
254
- ifSet(thenValue, elseValue) {
255
- return isThenElse(pIsSet(this), thenValue, elseValue);
256
- },
257
- /**
258
- * A getter property that returns the number of elements in the set.
259
- * This is an alias for the `size` property of the set.
260
- *
261
- * @returns {number} The number of elements in the set.
262
- */
263
- get length() {
264
- return this.size;
265
- },
266
- /**
267
- * Creates a new array populated with the results of calling the provided
268
- * function on every element in the set. The function is called with each
269
- * element of the set. Note: Since sets do not have indices, the index
270
- * parameter is always NaN.
271
- *
272
- * @param {Function} mapFn - The function to execute on each element. It
273
- * receives the element, index (always NaN), and the set itself.
274
- * @param {Object} [thisArg] - Optional. Value to use as `this` when executing
275
- * `mapFn`.
276
- * @throws {TypeError} If `mapFn` is not a function.
277
- * @returns {Array} A new array with each element being the result of the
278
- * `mapFn`.
279
- */
280
- map(mapFn, thisArg) {
281
- if (typeof mapFn !== 'function') {
282
- throw new TypeError(`mapFn must be a function! Received ${String(mapFn)}`);
283
- }
284
- const transformed = [];
285
- for (const element of this) {
286
- transformed.push(mapFn.call(thisArg, element, NaN, this));
287
- }
288
- return transformed;
289
- },
290
- /**
291
- * Applies a function against an accumulator and each element in the set to
292
- * reduce it to a single value. The function is called with each element of
293
- * the set. Note: Since sets do not have indices, the index parameter is
294
- * always NaN.
295
- *
296
- * @param {Function} reduceFn - The function to execute on each element. It
297
- * receives the accumulator, element, index (always NaN), and the set itself.
298
- * @param {*} initialValue - The initial value to start reducing from.
299
- * @param {Object} [thisArg] - Optional. Value to use as `this` when executing
300
- * `reduceFn`.
301
- * @throws {TypeError} If `reduceFn` is not a function.
302
- * @returns {*} The reduced value.
303
- */
304
- reduce(reduceFn, initialValue, thisArg) {
305
- if (typeof reduceFn !== 'function') {
306
- throw new TypeError(`reduceFn must be a Function! Received ${String(reduceFn)}`);
307
- }
308
- let accumulator = initialValue;
309
- for (const element of this) {
310
- accumulator = reduceFn.call(thisArg, accumulator, element, NaN, this);
311
- }
312
- return accumulator;
313
- },
314
- /**
315
- * Tests whether at least one element in the set passes the test implemented
316
- * by the provided function. The function is called with each element of the
317
- * set. Note: Since sets do not have indices, the index parameter is always NaN.
318
- *
319
- * @param {Function} someFn - The function to test each element. It receives
320
- * the element, index (always NaN), and the set itself.
321
- * @param {Object} [thisArg] - Optional. Value to use as `this` when executing
322
- * `someFn`.
323
- * @throws {TypeError} If `someFn` is not a function.
324
- * @returns {boolean} True if at least one element passes the test, false
325
- * otherwise.
326
- */
327
- some(someFn, thisArg) {
328
- if (typeof someFn !== 'function') {
329
- throw new TypeError(`someFn must be a function! Received ${String(someFn)}`);
330
- }
331
- for (const element of this) {
332
- if (someFn.call(thisArg, element, NaN, this)) {
333
- return true;
334
- }
335
- }
336
- return false;
337
- },
338
- },
339
- });
340
- // NOTE to self; this is repeated here otherwise a circular reference from
341
- // Object<->Function<->Global occurs. See original source in global.this.js
342
- // {@see globalThis.isThenElse}
343
- function isThenElse(bv, tv, ev) {
344
- function isFunction(value) { typeof value === 'function'; }
345
- if (arguments.length > 1) {
346
- var _then = isFunction(tv) ? tv(bv) : tv;
347
- if (arguments.length > 2) {
348
- var _else = isFunction(ev) ? tv(bv) : ev;
349
- return bv ? _then : _else;
350
- }
351
- return bv || _then;
352
- }
353
- return bv;
354
- }
355
- //# sourceMappingURL=set.extensions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"set.extensions.js","sourceRoot":"","sources":["../../src/set.extensions.js"],"names":[],"mappings":";;;AAAA,+CAAwC;AAExC;;;;;;;;;;;;;;;;;GAiBG;AACU,QAAA,aAAa,GAAG,IAAI,iBAAK,CAAC,GAAG,EAAE;IAC1C,CAAC,iBAAK,CAAC,cAAc,CAAC,EAAE;QACtB;;;;;;;;;;;;;;;;;;WAkBG;QACH,KAAK,CAAC,KAAK;YACT,OAAO,KAAK,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,GAAG,CAAC,IAAI,IAAI,KAAK,YAAY,GAAG,CAAA;QACzE,CAAC;QAED;;;;;;;;;;;;;;;;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,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,23 +0,0 @@
1
- /**
2
- * `StringExtensions` is a patch for the JavaScript built-in `String` class. It
3
- * adds utility methods to the `String` class without modifying the global namespace
4
- * directly. This patch includes methods for key validation, object type checking,
5
- * and retrieving the string tag of an object. These methods are useful for
6
- * enhancing the capabilities of the standard `String` class with additional
7
- * utility functions.
8
- */
9
- export const StringExtensions: Patch;
10
- /**
11
- * `StringPrototypeExtensions` provides a set of utility methods that are
12
- * added to the `String` prototype. This allows all string instances to
13
- * access new functionality directly, enhancing their capabilities beyond
14
- * the standard `String` class methods. These extensions are applied using
15
- * the `Patch` class from '@nejs/extension', ensuring that they do not
16
- * interfere with the global namespace or existing properties.
17
- *
18
- * The extensions include methods for extracting substrings based on
19
- * specific tokens, checking the presence of certain patterns, and more,
20
- * making string manipulation tasks more convenient and expressive.
21
- */
22
- export const StringPrototypeExtensions: Patch;
23
- import { Patch } from '@nejs/extension';