@nejs/basic-extensions 2.7.0 → 2.8.0

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/.vscode/settings.json +5 -0
  2. package/README.md +6129 -1574
  3. package/dist/@nejs/basic-extensions.bundle.2.7.0.js +19 -0
  4. package/dist/@nejs/basic-extensions.bundle.2.7.0.js.map +7 -0
  5. package/dist/cjs/array.extensions.d.ts +39 -0
  6. package/dist/cjs/array.extensions.js +303 -0
  7. package/dist/cjs/array.extensions.js.map +1 -0
  8. package/dist/cjs/big.int.extension.d.ts +31 -0
  9. package/dist/cjs/big.int.extension.js +164 -0
  10. package/dist/cjs/big.int.extension.js.map +1 -0
  11. package/dist/cjs/{newClasses → classes}/asyncIterable.js +32 -44
  12. package/dist/cjs/classes/asyncIterable.js.map +1 -0
  13. package/dist/cjs/{newClasses → classes}/deferred.js +66 -138
  14. package/dist/cjs/classes/deferred.js.map +1 -0
  15. package/dist/cjs/{newClasses → classes}/descriptor.js +56 -90
  16. package/dist/cjs/classes/descriptor.js.map +1 -0
  17. package/dist/cjs/classes/index.d.ts +13 -0
  18. package/dist/cjs/classes/index.js +57 -0
  19. package/dist/cjs/classes/index.js.map +1 -0
  20. package/dist/cjs/classes/introspector.d.ts +20 -0
  21. package/dist/cjs/classes/introspector.js +130 -0
  22. package/dist/cjs/classes/introspector.js.map +1 -0
  23. package/dist/cjs/{newClasses → classes}/iterable.js +42 -63
  24. package/dist/cjs/classes/iterable.js.map +1 -0
  25. package/dist/cjs/classes/param.parser.d.ts +227 -0
  26. package/dist/cjs/classes/param.parser.js +242 -0
  27. package/dist/cjs/classes/param.parser.js.map +1 -0
  28. package/dist/cjs/classes/pluggable.proxy.d.ts +152 -0
  29. package/dist/cjs/classes/pluggable.proxy.js +444 -0
  30. package/dist/cjs/classes/pluggable.proxy.js.map +1 -0
  31. package/dist/cjs/{newClasses → classes}/refmap.js +18 -30
  32. package/dist/cjs/classes/refmap.js.map +1 -0
  33. package/dist/cjs/{newClasses → classes}/refset.js +28 -47
  34. package/dist/cjs/classes/refset.js.map +1 -0
  35. package/dist/cjs/classes/symkeys.d.ts +292 -0
  36. package/dist/cjs/classes/symkeys.js +424 -0
  37. package/dist/cjs/classes/symkeys.js.map +1 -0
  38. package/dist/cjs/classes/type.d.ts +56 -0
  39. package/dist/cjs/classes/type.js +405 -0
  40. package/dist/cjs/classes/type.js.map +1 -0
  41. package/dist/cjs/function.extensions.js +757 -0
  42. package/dist/cjs/function.extensions.js.map +1 -0
  43. package/dist/cjs/global.this.js +261 -0
  44. package/dist/cjs/global.this.js.map +1 -0
  45. package/dist/cjs/index.d.ts +4 -3
  46. package/dist/cjs/index.js +62 -32
  47. package/dist/cjs/index.js.map +1 -1
  48. package/dist/cjs/json.extensions.d.ts +2 -0
  49. package/dist/cjs/json.extensions.js +107 -0
  50. package/dist/cjs/json.extensions.js.map +1 -0
  51. package/dist/{mjs/mapextensions.d.ts → cjs/map.extensions.d.ts} +1 -0
  52. package/dist/cjs/map.extensions.js +142 -0
  53. package/dist/cjs/map.extensions.js.map +1 -0
  54. package/dist/cjs/number.extension.d.ts +44 -0
  55. package/dist/cjs/number.extension.js +260 -0
  56. package/dist/cjs/number.extension.js.map +1 -0
  57. package/dist/cjs/object.extensions.d.ts +62 -0
  58. package/dist/cjs/object.extensions.js +1116 -0
  59. package/dist/cjs/object.extensions.js.map +1 -0
  60. package/dist/cjs/proxy.extensions.d.ts +2 -0
  61. package/dist/cjs/proxy.extensions.js +207 -0
  62. package/dist/cjs/proxy.extensions.js.map +1 -0
  63. package/dist/cjs/reflect.extensions.js +316 -0
  64. package/dist/cjs/reflect.extensions.js.map +1 -0
  65. package/dist/cjs/regular.expression.extensions.d.ts +2 -0
  66. package/dist/cjs/regular.expression.extensions.js +423 -0
  67. package/dist/cjs/regular.expression.extensions.js.map +1 -0
  68. package/dist/cjs/set.extensions.d.ts +40 -0
  69. package/dist/cjs/{setextensions.js → set.extensions.js} +150 -2
  70. package/dist/cjs/set.extensions.js.map +1 -0
  71. package/dist/cjs/string.extensions.js +471 -0
  72. package/dist/cjs/string.extensions.js.map +1 -0
  73. package/dist/{mjs/symbolextensions.d.ts → cjs/symbol.extensions.d.ts} +1 -0
  74. package/dist/cjs/symbol.extensions.js +259 -0
  75. package/dist/cjs/symbol.extensions.js.map +1 -0
  76. package/dist/cjs/{weakrefextensions.js → weakref.extensions.js} +1 -1
  77. package/dist/cjs/weakref.extensions.js.map +1 -0
  78. package/dist/mjs/array.extensions.d.ts +39 -0
  79. package/dist/mjs/array.extensions.js +300 -0
  80. package/dist/mjs/array.extensions.js.map +1 -0
  81. package/dist/mjs/big.int.extension.d.ts +31 -0
  82. package/dist/mjs/big.int.extension.js +161 -0
  83. package/dist/mjs/big.int.extension.js.map +1 -0
  84. package/dist/mjs/classes/asyncIterable.js.map +1 -0
  85. package/dist/mjs/classes/deferred.js.map +1 -0
  86. package/dist/mjs/{newClasses → classes}/descriptor.js +7 -4
  87. package/dist/mjs/classes/descriptor.js.map +1 -0
  88. package/dist/mjs/classes/index.d.ts +13 -0
  89. package/dist/mjs/classes/index.js +40 -0
  90. package/dist/mjs/classes/index.js.map +1 -0
  91. package/dist/mjs/classes/introspector.d.ts +20 -0
  92. package/dist/mjs/classes/introspector.js +126 -0
  93. package/dist/mjs/classes/introspector.js.map +1 -0
  94. package/dist/mjs/classes/iterable.js.map +1 -0
  95. package/dist/mjs/classes/param.parser.d.ts +227 -0
  96. package/dist/mjs/classes/param.parser.js +238 -0
  97. package/dist/mjs/classes/param.parser.js.map +1 -0
  98. package/dist/mjs/classes/pluggable.proxy.d.ts +152 -0
  99. package/dist/mjs/classes/pluggable.proxy.js +438 -0
  100. package/dist/mjs/classes/pluggable.proxy.js.map +1 -0
  101. package/dist/mjs/{newClasses → classes}/refmap.js +3 -3
  102. package/dist/mjs/classes/refmap.js.map +1 -0
  103. package/dist/mjs/classes/refset.js.map +1 -0
  104. package/dist/mjs/classes/symkeys.d.ts +292 -0
  105. package/dist/mjs/classes/symkeys.js +420 -0
  106. package/dist/mjs/classes/symkeys.js.map +1 -0
  107. package/dist/mjs/classes/type.d.ts +56 -0
  108. package/dist/mjs/classes/type.js +401 -0
  109. package/dist/mjs/classes/type.js.map +1 -0
  110. package/dist/mjs/function.extensions.js +754 -0
  111. package/dist/mjs/function.extensions.js.map +1 -0
  112. package/dist/mjs/global.this.js +258 -0
  113. package/dist/mjs/global.this.js.map +1 -0
  114. package/dist/mjs/index.d.ts +4 -3
  115. package/dist/mjs/index.js +49 -19
  116. package/dist/mjs/index.js.map +1 -1
  117. package/dist/mjs/json.extensions.d.ts +2 -0
  118. package/dist/mjs/json.extensions.js +104 -0
  119. package/dist/mjs/json.extensions.js.map +1 -0
  120. package/dist/{cjs/mapextensions.d.ts → mjs/map.extensions.d.ts} +1 -0
  121. package/dist/mjs/map.extensions.js +139 -0
  122. package/dist/mjs/map.extensions.js.map +1 -0
  123. package/dist/mjs/number.extension.d.ts +44 -0
  124. package/dist/mjs/number.extension.js +257 -0
  125. package/dist/mjs/number.extension.js.map +1 -0
  126. package/dist/mjs/object.extensions.d.ts +62 -0
  127. package/dist/mjs/object.extensions.js +1112 -0
  128. package/dist/mjs/object.extensions.js.map +1 -0
  129. package/dist/mjs/proxy.extensions.d.ts +2 -0
  130. package/dist/mjs/proxy.extensions.js +204 -0
  131. package/dist/mjs/proxy.extensions.js.map +1 -0
  132. package/dist/mjs/reflect.extensions.js +313 -0
  133. package/dist/mjs/reflect.extensions.js.map +1 -0
  134. package/dist/mjs/regular.expression.extensions.d.ts +2 -0
  135. package/dist/mjs/regular.expression.extensions.js +420 -0
  136. package/dist/mjs/regular.expression.extensions.js.map +1 -0
  137. package/dist/mjs/set.extensions.d.ts +40 -0
  138. package/dist/mjs/{setextensions.js → set.extensions.js} +149 -1
  139. package/dist/mjs/set.extensions.js.map +1 -0
  140. package/dist/mjs/string.extensions.js +468 -0
  141. package/dist/mjs/string.extensions.js.map +1 -0
  142. package/dist/{cjs/symbolextensions.d.ts → mjs/symbol.extensions.d.ts} +1 -0
  143. package/dist/mjs/symbol.extensions.js +256 -0
  144. package/dist/mjs/symbol.extensions.js.map +1 -0
  145. package/dist/mjs/{weakrefextensions.js → weakref.extensions.js} +1 -1
  146. package/dist/mjs/weakref.extensions.js.map +1 -0
  147. package/docs/index.html +24045 -5805
  148. package/package.json +6 -4
  149. package/src/array.extensions.js +322 -0
  150. package/src/big.int.extension.js +163 -0
  151. package/src/{newClasses → classes}/descriptor.js +16 -12
  152. package/src/classes/index.js +51 -0
  153. package/src/classes/introspector.js +167 -0
  154. package/src/classes/param.parser.js +253 -0
  155. package/src/classes/pluggable.proxy.js +485 -0
  156. package/src/{newClasses → classes}/refmap.js +5 -3
  157. package/src/classes/symkeys.js +464 -0
  158. package/src/classes/type.js +427 -0
  159. package/src/function.extensions.js +818 -0
  160. package/src/global.this.js +304 -0
  161. package/src/index.js +56 -23
  162. package/src/json.extensions.js +108 -0
  163. package/src/map.extensions.js +144 -0
  164. package/src/number.extension.js +273 -0
  165. package/src/object.extensions.js +1222 -0
  166. package/src/proxy.extensions.js +229 -0
  167. package/src/reflect.extensions.js +346 -0
  168. package/src/regular.expression.extensions.js +451 -0
  169. package/src/{setextensions.js → set.extensions.js} +151 -2
  170. package/src/string.extensions.js +515 -0
  171. package/src/symbol.extensions.js +268 -0
  172. package/tests/newClasses/refmap.test.js +3 -2
  173. package/tsconfig.base.json +5 -3
  174. package/tsconfig.cjs.json +2 -2
  175. package/tsconfig.esm.json +2 -2
  176. package/dist/@nejs/basic-extensions.bundle.2.6.0.js +0 -17
  177. package/dist/@nejs/basic-extensions.bundle.2.6.0.js.map +0 -7
  178. package/dist/cjs/arrayextensions.d.ts +0 -10
  179. package/dist/cjs/arrayextensions.js +0 -73
  180. package/dist/cjs/arrayextensions.js.map +0 -1
  181. package/dist/cjs/functionextensions.js +0 -202
  182. package/dist/cjs/functionextensions.js.map +0 -1
  183. package/dist/cjs/globals.js +0 -166
  184. package/dist/cjs/globals.js.map +0 -1
  185. package/dist/cjs/mapextensions.js +0 -32
  186. package/dist/cjs/mapextensions.js.map +0 -1
  187. package/dist/cjs/newClasses/asyncIterable.js.map +0 -1
  188. package/dist/cjs/newClasses/deferred.js.map +0 -1
  189. package/dist/cjs/newClasses/descriptor.js.map +0 -1
  190. package/dist/cjs/newClasses/iterable.js.map +0 -1
  191. package/dist/cjs/newClasses/refmap.js.map +0 -1
  192. package/dist/cjs/newClasses/refset.js.map +0 -1
  193. package/dist/cjs/objectextensions.d.ts +0 -11
  194. package/dist/cjs/objectextensions.js +0 -232
  195. package/dist/cjs/objectextensions.js.map +0 -1
  196. package/dist/cjs/reflectextensions.js +0 -111
  197. package/dist/cjs/reflectextensions.js.map +0 -1
  198. package/dist/cjs/setextensions.d.ts +0 -2
  199. package/dist/cjs/setextensions.js.map +0 -1
  200. package/dist/cjs/stringextensions.js +0 -158
  201. package/dist/cjs/stringextensions.js.map +0 -1
  202. package/dist/cjs/symbolextensions.js +0 -69
  203. package/dist/cjs/symbolextensions.js.map +0 -1
  204. package/dist/cjs/weakrefextensions.js.map +0 -1
  205. package/dist/mjs/arrayextensions.d.ts +0 -10
  206. package/dist/mjs/arrayextensions.js +0 -70
  207. package/dist/mjs/arrayextensions.js.map +0 -1
  208. package/dist/mjs/functionextensions.js +0 -199
  209. package/dist/mjs/functionextensions.js.map +0 -1
  210. package/dist/mjs/globals.js +0 -163
  211. package/dist/mjs/globals.js.map +0 -1
  212. package/dist/mjs/mapextensions.js +0 -29
  213. package/dist/mjs/mapextensions.js.map +0 -1
  214. package/dist/mjs/newClasses/asyncIterable.js.map +0 -1
  215. package/dist/mjs/newClasses/deferred.js.map +0 -1
  216. package/dist/mjs/newClasses/descriptor.js.map +0 -1
  217. package/dist/mjs/newClasses/iterable.js.map +0 -1
  218. package/dist/mjs/newClasses/refmap.js.map +0 -1
  219. package/dist/mjs/newClasses/refset.js.map +0 -1
  220. package/dist/mjs/objectextensions.d.ts +0 -11
  221. package/dist/mjs/objectextensions.js +0 -229
  222. package/dist/mjs/objectextensions.js.map +0 -1
  223. package/dist/mjs/reflectextensions.js +0 -108
  224. package/dist/mjs/reflectextensions.js.map +0 -1
  225. package/dist/mjs/setextensions.d.ts +0 -2
  226. package/dist/mjs/setextensions.js.map +0 -1
  227. package/dist/mjs/stringextensions.js +0 -155
  228. package/dist/mjs/stringextensions.js.map +0 -1
  229. package/dist/mjs/symbolextensions.js +0 -66
  230. package/dist/mjs/symbolextensions.js.map +0 -1
  231. package/dist/mjs/weakrefextensions.js.map +0 -1
  232. package/src/arrayextensions.js +0 -75
  233. package/src/functionextensions.js +0 -225
  234. package/src/globals.js +0 -196
  235. package/src/mapextensions.js +0 -32
  236. package/src/objectextensions.js +0 -256
  237. package/src/reflectextensions.js +0 -118
  238. package/src/stringextensions.js +0 -166
  239. package/src/symbolextensions.js +0 -69
  240. /package/dist/cjs/{newClasses → classes}/asyncIterable.d.ts +0 -0
  241. /package/dist/cjs/{newClasses → classes}/deferred.d.ts +0 -0
  242. /package/dist/cjs/{newClasses → classes}/descriptor.d.ts +0 -0
  243. /package/dist/cjs/{newClasses → classes}/iterable.d.ts +0 -0
  244. /package/dist/cjs/{newClasses → classes}/refmap.d.ts +0 -0
  245. /package/dist/cjs/{newClasses → classes}/refset.d.ts +0 -0
  246. /package/dist/cjs/{functionextensions.d.ts → function.extensions.d.ts} +0 -0
  247. /package/dist/cjs/{globals.d.ts → global.this.d.ts} +0 -0
  248. /package/dist/cjs/{reflectextensions.d.ts → reflect.extensions.d.ts} +0 -0
  249. /package/dist/cjs/{stringextensions.d.ts → string.extensions.d.ts} +0 -0
  250. /package/dist/cjs/{weakrefextensions.d.ts → weakref.extensions.d.ts} +0 -0
  251. /package/dist/mjs/{newClasses → classes}/asyncIterable.d.ts +0 -0
  252. /package/dist/mjs/{newClasses → classes}/asyncIterable.js +0 -0
  253. /package/dist/mjs/{newClasses → classes}/deferred.d.ts +0 -0
  254. /package/dist/mjs/{newClasses → classes}/deferred.js +0 -0
  255. /package/dist/mjs/{newClasses → classes}/descriptor.d.ts +0 -0
  256. /package/dist/mjs/{newClasses → classes}/iterable.d.ts +0 -0
  257. /package/dist/mjs/{newClasses → classes}/iterable.js +0 -0
  258. /package/dist/mjs/{newClasses → classes}/refmap.d.ts +0 -0
  259. /package/dist/mjs/{newClasses → classes}/refset.d.ts +0 -0
  260. /package/dist/mjs/{newClasses → classes}/refset.js +0 -0
  261. /package/dist/mjs/{functionextensions.d.ts → function.extensions.d.ts} +0 -0
  262. /package/dist/mjs/{globals.d.ts → global.this.d.ts} +0 -0
  263. /package/dist/mjs/{reflectextensions.d.ts → reflect.extensions.d.ts} +0 -0
  264. /package/dist/mjs/{stringextensions.d.ts → string.extensions.d.ts} +0 -0
  265. /package/dist/mjs/{weakrefextensions.d.ts → weakref.extensions.d.ts} +0 -0
  266. /package/src/{newClasses → classes}/asyncIterable.js +0 -0
  267. /package/src/{newClasses → classes}/deferred.js +0 -0
  268. /package/src/{newClasses → classes}/iterable.js +0 -0
  269. /package/src/{newClasses → classes}/refset.js +0 -0
  270. /package/src/{weakrefextensions.js → weakref.extensions.js} +0 -0
@@ -0,0 +1,39 @@
1
+ /**
2
+ * `ArrayExtensions` is a constant that applies a patch to the global
3
+ * `Array` constructor. This patch extends the `Array` with additional
4
+ * methods and properties, enhancing its functionality.
5
+ *
6
+ * The `Patch` function takes two arguments: the target object to be patched
7
+ * (in this case, `Array`), and an object containing the methods and
8
+ * properties to be added to the target object.
9
+ *
10
+ * @example
11
+ * // Using a method added by ArrayExtensions
12
+ * const arr = [1, 2, 3];
13
+ * console.log(Array.ifArray(arr, 'Array', 'Not Array')); // Output: 'Array'
14
+ *
15
+ * @const
16
+ * @type {Patch}
17
+ * @memberof module:array.extensions
18
+ */
19
+ export const ArrayExtensions: Patch;
20
+ /**
21
+ * `ArrayPrototypeExtensions` is a constant that applies a patch to the
22
+ * Array prototype. This patch extends the Array prototype with additional
23
+ * methods and properties, enhancing its functionality.
24
+ *
25
+ * The `Patch` function takes two arguments: the target object to be patched
26
+ * (in this case, `Array.prototype`), and an object containing the methods
27
+ * and properties to be added to the target object.
28
+ *
29
+ * @example
30
+ * // Using a method added by ArrayPrototypeExtensions
31
+ * const arr = [1, 2, 3];
32
+ * console.log(arr.ifArray('Array', 'Not Array')); // Output: 'Array'
33
+ *
34
+ * @const
35
+ * @type {Patch}
36
+ * @memberof module:array.extensions
37
+ */
38
+ export const ArrayPrototypeExtensions: Patch;
39
+ import { Patch } from '@nejs/extension';
@@ -0,0 +1,303 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ArrayPrototypeExtensions = exports.ArrayExtensions = void 0;
4
+ const extension_1 = require("@nejs/extension");
5
+ /**
6
+ * `ArrayExtensions` is a constant that applies a patch to the global
7
+ * `Array` constructor. This patch extends the `Array` 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, `Array`), 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 ArrayExtensions
16
+ * const arr = [1, 2, 3];
17
+ * console.log(Array.ifArray(arr, 'Array', 'Not Array')); // Output: 'Array'
18
+ *
19
+ * @const
20
+ * @type {Patch}
21
+ * @memberof module:array.extensions
22
+ */
23
+ exports.ArrayExtensions = new extension_1.Patch(Array, {
24
+ /**
25
+ * Checks if the provided value is an array and returns one of two
26
+ * provided values based on the result. This function is a convenience
27
+ * method for performing conditional operations based on the type of
28
+ * the provided value.
29
+ *
30
+ * @name ifArray
31
+ * @type {function}
32
+ * @memberof ArrayExtensions
33
+ * @param {any} value - The value to be checked.
34
+ * @param {function | any} thenValue - The value to be returned if the
35
+ * provided value is an array.
36
+ * @param {function | any} elseValue - The value to be returned if the
37
+ * provided value is not an array.
38
+ * @returns {any} Returns `thenValue` if the provided value is an array,
39
+ * otherwise returns `elseValue`.
40
+ *
41
+ * @example
42
+ * const arr = [1, 2, 3];
43
+ * console.log(ArrayExtensions.ifArray(arr, 'Array', 'Not Array'));
44
+ * // Output: 'Array'
45
+ *
46
+ * const notArr = "I'm not an array";
47
+ * console.log(ArrayExtensions.ifArray(notArr, 'Array', 'Not Array'));
48
+ * // Output: 'Not Array'
49
+ */
50
+ ifArray(value, thenValue, elseValue) {
51
+ return isThenElse(Array.isArray(value), thenValue, elseValue);
52
+ },
53
+ });
54
+ const { ifArray: pIfArray } = exports.ArrayExtensions.patches;
55
+ /**
56
+ * `ArrayPrototypeExtensions` is a constant that applies a patch to the
57
+ * Array prototype. This patch extends the Array prototype with additional
58
+ * methods and properties, enhancing its functionality.
59
+ *
60
+ * The `Patch` function takes two arguments: the target object to be patched
61
+ * (in this case, `Array.prototype`), and an object containing the methods
62
+ * and properties to be added to the target object.
63
+ *
64
+ * @example
65
+ * // Using a method added by ArrayPrototypeExtensions
66
+ * const arr = [1, 2, 3];
67
+ * console.log(arr.ifArray('Array', 'Not Array')); // Output: 'Array'
68
+ *
69
+ * @const
70
+ * @type {Patch}
71
+ * @memberof module:array.extensions
72
+ */
73
+ exports.ArrayPrototypeExtensions = new extension_1.Patch(Array.prototype, {
74
+ [extension_1.Patch.kMutablyHidden]: {
75
+ /**
76
+ * Sometimes defining even a short function for the invocation of `find`
77
+ * can be troublesome. This helper function performs that job for you. If
78
+ * the specified element is in the array, `true` will be returned.
79
+ *
80
+ * @param {*} value the value to search for. This value must triple equals
81
+ * the array element in order to return true.
82
+ * @returns true if the exact element exists in the array, false otherwise
83
+ */
84
+ contains(value) {
85
+ return !!this.find(entry => entry === value);
86
+ },
87
+ /**
88
+ * The `findEntry` function searches the entries of the object and returns
89
+ * the `[index, value]` entry array for the first matching value found.
90
+ *
91
+ * @param {function} findFn a function that takes the element to be checked
92
+ * and returns a boolean value
93
+ * @returns if `findFn` returns `true`, an array with two elements, the first
94
+ * being the index, the second being the value, is returned.
95
+ */
96
+ findEntry(findFn) {
97
+ const entries = this.entries();
98
+ const VALUE = 1;
99
+ for (let entry of entries) {
100
+ if (findFn(entry[VALUE])) {
101
+ return entry;
102
+ }
103
+ }
104
+ return undefined;
105
+ },
106
+ /**
107
+ * A getter property that returns the first element of the array. If the
108
+ * array is empty, it returns `undefined`. This property is useful for
109
+ * scenarios where you need to quickly access the first item of an array
110
+ * without the need for additional checks or method calls.
111
+ *
112
+ * @returns {*} The first element of the array or `undefined` if the array
113
+ * is empty.
114
+ */
115
+ get first() {
116
+ return this[0];
117
+ },
118
+ /**
119
+ * A getter property that checks if the current context (`this`) is an
120
+ * array. This is a convenience method that wraps the native
121
+ * `Array.isArray` function.
122
+ *
123
+ * @name isArray
124
+ * @type {function}
125
+ * @memberof Array.prototype
126
+ * @returns {boolean} `true` if the current context is an array,
127
+ * `false` otherwise.
128
+ *
129
+ * @example
130
+ * const arr = [1, 2, 3];
131
+ * console.log(arr.isArray); // Output: true
132
+ *
133
+ * const notArr = "I'm not an array";
134
+ * console.log(notArr.isArray); // Output: false
135
+ */
136
+ get isArray() {
137
+ return Array.isArray(this);
138
+ },
139
+ /**
140
+ * Checks if the current context (`this`) is an array and returns one of
141
+ * two provided values based on the result. This function is a convenience
142
+ * method for performing conditional operations based on the type of
143
+ * the current context.
144
+ *
145
+ * @name ifArray
146
+ * @type {function}
147
+ * @memberof Array.prototype
148
+ * @param {function | any} thenValue - The value to be returned if the
149
+ * current context is an array.
150
+ * @param {function | any} elseValue - The value to be returned if the
151
+ * current context is not an array.
152
+ * @returns {*} Returns `thenValue` if the current context is an array,
153
+ * otherwise returns `elseValue`.
154
+ *
155
+ * @example
156
+ * const arr = [1, 2, 3];
157
+ * console.log(arr.ifArray('Array', 'Not Array')); // Output: 'Array'
158
+ *
159
+ * const notArr = "I'm not an array";
160
+ * console.log(notArr.ifArray('Array', 'Not Array')); // Output: 'Not Array'
161
+ */
162
+ ifArray(thenValue, elseValue) {
163
+ return pIfArray(this, thenValue, elseValue);
164
+ },
165
+ /**
166
+ * Checks if at least one element in the array is equal to the provided
167
+ * value. This method uses the `Array.prototype.some` function to iterate
168
+ * over the array and compare each element with the provided value.
169
+ *
170
+ * @name oneIs
171
+ * @type {function}
172
+ * @memberof Array.prototype
173
+ * @param {*} value - The value to be compared with the array elements.
174
+ * @param {boolean} [doubleEqualsOkay=true] - A flag indicating whether to
175
+ * use loose equality (`==`) or strict equality (`===`) for the comparison.
176
+ * If `true`, loose equality is used. If `false`, strict equality is used.
177
+ * @returns {boolean} Returns `true` if at least one element in the array
178
+ * is equal to the provided value, otherwise `false`.
179
+ *
180
+ * @example
181
+ * const arr = [1, 2, 3];
182
+ * console.log(arr.oneIs(2)); // Output: true
183
+ *
184
+ * const arr2 = ['1', '2', '3'];
185
+ * console.log(arr2.oneIs(2, false)); // Output: false
186
+ */
187
+ oneIs(value, doubleEqualsOkay = true) {
188
+ return this.some(element => (doubleEqualsOkay ? element == value : element === value));
189
+ },
190
+ /**
191
+ * Checks if some elements in the array are included in the provided values.
192
+ * This method uses the `Array.prototype.some` function to iterate over the
193
+ * array and checks if any of the elements are included in the provided values.
194
+ *
195
+ * @name someAre
196
+ * @type {function}
197
+ * @memberof Array.prototype
198
+ * @param {...*} values - The values to be checked against the array elements.
199
+ * @returns {boolean} Returns `true` if at least one element in the array
200
+ * is included in the provided values, otherwise `false`.
201
+ *
202
+ * @example
203
+ * const arr = [1, 2, 3];
204
+ * console.log(arr.someAre(2, 4)); // Output: true
205
+ *
206
+ * const arr2 = ['1', '2', '3'];
207
+ * console.log(arr2.someAre(4, 5)); // Output: false
208
+ */
209
+ someAre(...values) {
210
+ return this.some(element => !!~values.indexOf(element));
211
+ },
212
+ /**
213
+ * Checks if all elements in the array are equal to the provided value.
214
+ * This method uses the `Array.prototype.every` function to iterate over
215
+ * the array and compare each element with the provided value.
216
+ *
217
+ * @name allAre
218
+ * @type {function}
219
+ * @memberof Array.prototype
220
+ * @param {*} value - The value to be compared with the array elements.
221
+ * @param {boolean} [doubleEqualsOkay=true] - A flag indicating whether to
222
+ * use loose equality (`==`) or strict equality (`===`) for the comparison.
223
+ * If `true`, loose equality is used. If `false`, strict equality is used.
224
+ * @returns {boolean} Returns `true` if all elements in the array are equal
225
+ * to the provided value, otherwise `false`.
226
+ *
227
+ * @example
228
+ * const arr = [2, 2, 2];
229
+ * console.log(arr.allAre(2)); // Output: true
230
+ *
231
+ * const arr2 = ['2', '2', '2'];
232
+ * console.log(arr2.allAre(2, false)); // Output: false
233
+ */
234
+ allAre(value, doubleEqualsOkay = true) {
235
+ return this.every(element => (doubleEqualsOkay ? element == value : element === value));
236
+ },
237
+ /**
238
+ * A getter property that returns the last element of the array. It
239
+ * calculates the last index based on the array's length. If the array is
240
+ * empty, it returns `undefined`. This property is beneficial when you need
241
+ * to access the last item in an array, improving code readability and
242
+ * avoiding manual index calculation.
243
+ *
244
+ * @returns {*} The last element of the array or `undefined` if the
245
+ * array is empty.
246
+ */
247
+ get last() {
248
+ return this[this.length - 1];
249
+ },
250
+ // expected usage:
251
+ // function example(name, age) {
252
+ // const variants = [{name}, {age}].variants()
253
+ // if (typeof name === 'object')
254
+ // }
255
+ variants() {
256
+ const keys = this.map(o => Object.keys(o)?.[0]);
257
+ const entries = this.map(o => Object.entries(o)?.[0]);
258
+ const object = entries.reduce((acc, [key, value]) => {
259
+ acc[key] = value;
260
+ return acc;
261
+ }, {});
262
+ const result = {
263
+ order: keys,
264
+ entries: entries,
265
+ object: object,
266
+ };
267
+ Object.defineProperty(result, 'check', {
268
+ value(position) {
269
+ if (typeof position !== 'number' &&
270
+ position >= 0 &&
271
+ position < this.order.length) {
272
+ return false;
273
+ }
274
+ const value = this.entries[position][1];
275
+ if (typeof value === 'object' && value) {
276
+ if (Object.keys(value).every(key => ~this.order.indexOf(key))) {
277
+ return true;
278
+ }
279
+ }
280
+ return false;
281
+ },
282
+ enumerable: false,
283
+ configurable: true
284
+ });
285
+ return result;
286
+ },
287
+ },
288
+ });
289
+ // NOTE to self; this is repeated here otherwise a circular reference from
290
+ // Object<->Function<->Global occurs. See original source in global.this.js
291
+ // {@see globalThis.isThenElse}
292
+ function isThenElse(bv, tv, ev) {
293
+ if (arguments.length > 1) {
294
+ var _then = isFunction(tv) ? tv(bv) : tv;
295
+ if (arguments.length > 2) {
296
+ var _else = isFunction(ev) ? tv(bv) : ev;
297
+ return bv ? _then : _else;
298
+ }
299
+ return bv || _then;
300
+ }
301
+ return bv;
302
+ }
303
+ //# sourceMappingURL=array.extensions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array.extensions.js","sourceRoot":"","sources":["../../src/array.extensions.js"],"names":[],"mappings":";;;AAAA,+CAAuC;AAEvC;;;;;;;;;;;;;;;;;GAiBG;AACU,QAAA,eAAe,GAAG,IAAI,iBAAK,CAAC,KAAK,EAAE;IAC9C;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS;QACjC,OAAO,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,CAAA;IAC/D,CAAC;CACF,CAAC,CAAA;AAEF,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,uBAAe,CAAC,OAAO,CAAA;AAErD;;;;;;;;;;;;;;;;;GAiBG;AACU,QAAA,wBAAwB,GAAG,IAAI,iBAAK,CAAC,KAAK,CAAC,SAAS,EAAE;IACjE,CAAC,iBAAK,CAAC,cAAc,CAAC,EAAE;QACtB;;;;;;;;WAQG;QACH,QAAQ,CAAC,KAAK;YACZ,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,CAAA;QAC9C,CAAC;QAED;;;;;;;;WAQG;QACH,SAAS,CAAC,MAAM;YACd,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAA;YAC9B,MAAM,KAAK,GAAG,CAAC,CAAA;YAEf,KAAK,IAAI,KAAK,IAAI,OAAO,EAAE,CAAC;gBA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AI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;4BAC9D,OAAO,IAAI,CAAA;wBACb,CAAC;oBACH,CAAC;oBAED,OAAO,KAAK,CAAA;gBACd,CAAC;gBACD,UAAU,EAAE,KAAK;gBACjB,YAAY,EAAE,IAAI;aACnB,CAAC,CAAA;YAEF,OAAO,MAAM,CAAA;QACf,CAAC;KACF;CACF,CAAC,CAAA;AAEF,0EAA0E;AAC1E,2EAA2E;AAC3E,+BAA+B;AAC/B,SAAS,UAAU,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;IAC5B,IAAI,SAAS,CAAC,MAAM,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"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * `BigIntExtensions` is a patch for the JavaScript built-in `BigInt` class.
3
+ * It adds utility methods to the `BigInt` class without modifying the global
4
+ * namespace directly. This patch includes methods for checking if a value is
5
+ * a `BigInt` and conditionally returning a value based on whether the supplied
6
+ * value is a `BigInt` or not.
7
+ *
8
+ * @type {Patch}
9
+ * @example
10
+ * import { BigIntExtensions } from 'big.int.extension.js'
11
+ *
12
+ * BigIntExtensions.apply()
13
+ * // Now the `BigInt` class has additional methods available
14
+ */
15
+ export const BigIntExtensions: Patch;
16
+ /**
17
+ * `BigIntPrototypeExtensions` is a patch for the JavaScript built-in
18
+ * `BigInt.prototype`. It adds utility methods to the `BigInt` prototype
19
+ * without modifying the global namespace directly. This patch includes
20
+ * methods for checking if a value is a BigInt and conditionally returning
21
+ * a value based on whether the supplied value is a BigInt or not.
22
+ *
23
+ * @type {Patch}
24
+ * @example
25
+ * import { BigIntPrototypeExtensions } from 'big.int.extension.js'
26
+ *
27
+ * BigIntPrototypeExtensions.apply()
28
+ * // Now the `BigInt` prototype has additional methods available
29
+ */
30
+ export const BigIntPrototypeExtensions: Patch;
31
+ import { Patch } from '@nejs/extension';
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BigIntPrototypeExtensions = exports.BigIntExtensions = void 0;
4
+ const extension_1 = require("@nejs/extension");
5
+ /**
6
+ * `BigIntExtensions` is a patch for the JavaScript built-in `BigInt` class.
7
+ * It adds utility methods to the `BigInt` class without modifying the global
8
+ * namespace directly. This patch includes methods for checking if a value is
9
+ * a `BigInt` and conditionally returning a value based on whether the supplied
10
+ * value is a `BigInt` or not.
11
+ *
12
+ * @type {Patch}
13
+ * @example
14
+ * import { BigIntExtensions } from 'big.int.extension.js'
15
+ *
16
+ * BigIntExtensions.apply()
17
+ * // Now the `BigInt` class has additional methods available
18
+ */
19
+ exports.BigIntExtensions = new extension_1.Patch(BigInt, {
20
+ /**
21
+ * Determines if the supplied `value` is a `BigInt`. This check is
22
+ * performed by first checking the `typeof` the `value` and then
23
+ * checking to see if the `value` is an `instanceof` `BigInt`
24
+ *
25
+ * @param {*} value The value that needs to be checked to determine
26
+ * if it is a `BigInt` or not
27
+ * @returns {boolean} `true` if the supplied `value` is a `BigInt`,
28
+ * `false` otherwise
29
+ *
30
+ * @example
31
+ * const bigInt = 1234567890123456789012345678901234567890n
32
+ * isBigInt(bigInt) // true
33
+ * isBigInt(1234567890123456789012345678901234567890) // false
34
+ * isBigInt('1234567890123456789012345678901234567890') // false
35
+ * isBigInt(BigInt('1234567890123456789012345678901234567890')) // true
36
+ */
37
+ isBigInt(value) {
38
+ return typeof value === 'bigint' || value instanceof BigInt;
39
+ },
40
+ /**
41
+ * Conditionally returns a value based on whether the supplied
42
+ * `value` is a `BigInt` or not. If the `value` is a `BigInt`,
43
+ * the `thenValue` will be returned. If it is not a `BigInt`,
44
+ * the `elseValue` will be returned instead.
45
+ *
46
+ * @param {any} value The value to check to determine if it is a
47
+ * `BigInt`
48
+ * @param {any} thenValue The value to return if the supplied
49
+ * `value` is a `BigInt`
50
+ * @param {any} elseValue The value to return if the supplied
51
+ * `value` is not a `BigInt`
52
+ * @returns {any} Either the `thenValue` or `elseValue` depending
53
+ * on if the supplied `value` is a `BigInt`
54
+ *
55
+ * @example
56
+ * const bigInt = 1234567890123456789012345678901234567890n
57
+ * const num = 42
58
+ * ifBigInt(bigInt, 'is a BigInt', 'not a BigInt')
59
+ * // 'is a BigInt'
60
+ * ifBigInt(num, 'is a BigInt', 'not a BigInt')
61
+ * // 'not a BigInt'
62
+ */
63
+ ifBigInt(value, thenValue, elseValue) {
64
+ return isThenElse(this.isBigInt(value), thenValue, elseValue);
65
+ },
66
+ });
67
+ const { isBigInt: pIsBigInt, ifBigInt: pIfBigInt } = exports.BigIntExtensions.patches;
68
+ /**
69
+ * `BigIntPrototypeExtensions` is a patch for the JavaScript built-in
70
+ * `BigInt.prototype`. It adds utility methods to the `BigInt` prototype
71
+ * without modifying the global namespace directly. This patch includes
72
+ * methods for checking if a value is a BigInt and conditionally returning
73
+ * a value based on whether the supplied value is a BigInt or not.
74
+ *
75
+ * @type {Patch}
76
+ * @example
77
+ * import { BigIntPrototypeExtensions } from 'big.int.extension.js'
78
+ *
79
+ * BigIntPrototypeExtensions.apply()
80
+ * // Now the `BigInt` prototype has additional methods available
81
+ */
82
+ exports.BigIntPrototypeExtensions = new extension_1.Patch(BigInt.prototype, {
83
+ /**
84
+ * A getter method that returns an object representation of the BigInt
85
+ * instance.
86
+ *
87
+ * This method wraps the BigInt instance in an object, allowing it to be
88
+ * treated as an object. The returned object is created using the `Object()`
89
+ * constructor, which takes the BigInt instance as its argument.
90
+ *
91
+ * @type {Object}
92
+ * @readonly
93
+ *
94
+ * @example
95
+ * const bigInt = 1234567890123456789012345678901234567890n
96
+ * console.log(typeof bigInt) // 'bigint'
97
+ * console.log(typeof bigInt.instance) // 'object'
98
+ */
99
+ get instance() {
100
+ return Object(this);
101
+ },
102
+ /**
103
+ * A getter method that checks if the current instance is a BigInt.
104
+ *
105
+ * This method uses the `pIsBigInt` function from the `BigIntExtensions`
106
+ * patch to determine if the current instance (`this`) is a BigInt.
107
+ *
108
+ * @type {boolean}
109
+ * @readonly
110
+ *
111
+ * @example
112
+ * const bigInt = 1234567890123456789012345678901234567890n
113
+ * console.log(bigInt.isBigInt) // Output: true
114
+ *
115
+ * const notBigInt = 42
116
+ * console.log(notBigInt.isBigInt) // Output: false
117
+ */
118
+ get isBigInt() {
119
+ return pIsBigInt(this);
120
+ },
121
+ /**
122
+ * Checks if the current object is a BigInt and returns the corresponding
123
+ * value based on the result.
124
+ *
125
+ * This method uses the `pIfBigInt` function from the `BigIntExtensions`
126
+ * patch to determine if the current object (`this`) is a BigInt. If it is
127
+ * a BigInt, the `thenValue` is returned. Otherwise, the `elseValue` is
128
+ * returned.
129
+ *
130
+ * @param {any} thenValue - The value to return if the current object
131
+ * is a BigInt.
132
+ * @param {any} elseValue - The value to return if the current object
133
+ * is not a BigInt.
134
+ * @returns {any} The `thenValue` if the current object is a BigInt, or
135
+ * the `elseValue` if it is not a BigInt.
136
+ *
137
+ * @example
138
+ * const bigInt = 1234567890123456789012345678901234567890n
139
+ * // 'Is a BigInt'
140
+ * console.log(bigInt.ifBigInt('Is a BigInt', 'Not a BigInt'))
141
+ *
142
+ * const notBigInt = 42
143
+ * // 'Not a BigInt'
144
+ * console.log(notBigInt.ifBigInt('Is a BigInt', 'Not a BigInt'))
145
+ */
146
+ ifBigInt(thenValue, elseValue) {
147
+ return pIfBigInt(this, thenValue, elseValue);
148
+ },
149
+ });
150
+ // NOTE to self; this is repeated here otherwise a circular reference from
151
+ // Object<->Function<->Global occurs. See original source in global.this.js
152
+ // {@see globalThis.isThenElse}
153
+ function isThenElse(bv, tv, ev) {
154
+ if (arguments.length > 1) {
155
+ var _then = isFunction(tv) ? tv(bv) : tv;
156
+ if (arguments.length > 2) {
157
+ var _else = isFunction(ev) ? tv(bv) : ev;
158
+ return bv ? _then : _else;
159
+ }
160
+ return bv || _then;
161
+ }
162
+ return bv;
163
+ }
164
+ //# sourceMappingURL=big.int.extension.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"big.int.extension.js","sourceRoot":"","sources":["../../src/big.int.extension.js"],"names":[],"mappings":";;;AAAA,+CAAuC;AAEvC;;;;;;;;;;;;;GAaG;AACU,QAAA,gBAAgB,GAAG,IAAI,iBAAK,CAAC,MAAM,EAAE;IAChD;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,KAAK;QACZ,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,YAAY,MAAM,CAAA;IAC7D,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,QAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS;QAClC,OAAO,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,CAAA;IAC/D,CAAC;CACF,CAAC,CAAA;AAEF,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,wBAAgB,CAAC,OAAO,CAAA;AAE7E;;;;;;;;;;;;;GAaG;AACU,QAAA,yBAAyB,GAAG,IAAI,iBAAK,CAAC,MAAM,CAAC,SAAS,EAAE;IACnE;;;;;;;;;;;;;;;OAeG;IACH,IA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