@nejs/basic-extensions 2.21.5 → 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 (266) hide show
  1. package/README.md +78 -4
  2. package/dist/@nejs/basic-extensions.bundle.2.22.6.js +25 -0
  3. package/dist/@nejs/basic-extensions.bundle.2.22.6.js.map +7 -0
  4. package/dist/cjs/classes/index.cjs +11129 -0
  5. package/dist/cjs/classes/index.cjs.map +7 -0
  6. package/dist/cjs/index.cjs +15191 -0
  7. package/dist/cjs/index.cjs.map +7 -0
  8. package/dist/cjs/utils/index.cjs +3954 -0
  9. package/dist/cjs/utils/index.cjs.map +7 -0
  10. package/dist/esm/basic-extensions.mjs +25 -0
  11. package/dist/esm/basic-extensions.mjs.map +7 -0
  12. package/package.json +16 -22
  13. package/repl.bootstrap.js +4 -7
  14. package/repl.history +26 -26
  15. package/src/classes/enumeration.js +466 -0
  16. package/src/classes/index.js +5 -1
  17. package/src/index.js +3 -1
  18. package/src/regular.expression.extensions.js +0 -35
  19. package/src/utils/toolkit.js +699 -516
  20. package/tests/arrayextensions.test.js +3 -3
  21. package/tests/index.test.js +3 -1
  22. package/tests/newClasses/asyncIterable.test.js +3 -3
  23. package/tests/newClasses/deferred.test.js +3 -3
  24. package/tests/newClasses/descriptor.test.js +3 -3
  25. package/tests/newClasses/iterable.test.js +3 -3
  26. package/tests/newClasses/refmap.test.js +3 -3
  27. package/tests/newClasses/refset.test.js +3 -3
  28. package/tests/objectextensions.test.js +3 -3
  29. package/tests/setextensions.test.js +3 -3
  30. package/tests/stringextensions.test.js +3 -2
  31. package/tests/utils/descriptor.utils.test.js +1 -1
  32. package/tests/utils/toolkit.test.js +429 -163
  33. package/.esdoc.json +0 -9
  34. package/.vscode/settings.json +0 -5
  35. package/bin/build +0 -27
  36. package/bin/clean +0 -14
  37. package/bin/esbuild +0 -91
  38. package/bin/fixup +0 -13
  39. package/bin/repl.basics.js +0 -584
  40. package/bin/repl.signature.js +0 -63
  41. package/bin/version +0 -100
  42. package/dist/@nejs/basic-extensions.bundle.2.21.5.js +0 -25
  43. package/dist/@nejs/basic-extensions.bundle.2.21.5.js.map +0 -7
  44. package/dist/cjs/array.extensions.d.ts +0 -39
  45. package/dist/cjs/array.extensions.js +0 -477
  46. package/dist/cjs/array.extensions.js.map +0 -1
  47. package/dist/cjs/big.int.extension.d.ts +0 -31
  48. package/dist/cjs/big.int.extension.js +0 -273
  49. package/dist/cjs/big.int.extension.js.map +0 -1
  50. package/dist/cjs/classes/asyncIterable.d.ts +0 -126
  51. package/dist/cjs/classes/asyncIterable.js +0 -209
  52. package/dist/cjs/classes/asyncIterable.js.map +0 -1
  53. package/dist/cjs/classes/deferred.d.ts +0 -146
  54. package/dist/cjs/classes/deferred.js +0 -291
  55. package/dist/cjs/classes/deferred.js.map +0 -1
  56. package/dist/cjs/classes/descriptor.d.ts +0 -334
  57. package/dist/cjs/classes/descriptor.js +0 -537
  58. package/dist/cjs/classes/descriptor.js.map +0 -1
  59. package/dist/cjs/classes/enum.d.ts +0 -50
  60. package/dist/cjs/classes/enum.js +0 -405
  61. package/dist/cjs/classes/enum.js.map +0 -1
  62. package/dist/cjs/classes/index.d.ts +0 -15
  63. package/dist/cjs/classes/index.js +0 -63
  64. package/dist/cjs/classes/index.js.map +0 -1
  65. package/dist/cjs/classes/introspector.d.ts +0 -20
  66. package/dist/cjs/classes/introspector.js +0 -130
  67. package/dist/cjs/classes/introspector.js.map +0 -1
  68. package/dist/cjs/classes/iterable.d.ts +0 -169
  69. package/dist/cjs/classes/iterable.js +0 -268
  70. package/dist/cjs/classes/iterable.js.map +0 -1
  71. package/dist/cjs/classes/param.parser.d.ts +0 -221
  72. package/dist/cjs/classes/param.parser.js +0 -242
  73. package/dist/cjs/classes/param.parser.js.map +0 -1
  74. package/dist/cjs/classes/pluggable.proxy.d.ts +0 -153
  75. package/dist/cjs/classes/pluggable.proxy.js +0 -444
  76. package/dist/cjs/classes/pluggable.proxy.js.map +0 -1
  77. package/dist/cjs/classes/property.d.ts +0 -79
  78. package/dist/cjs/classes/property.js +0 -284
  79. package/dist/cjs/classes/property.js.map +0 -1
  80. package/dist/cjs/classes/refmap.d.ts +0 -238
  81. package/dist/cjs/classes/refmap.js +0 -421
  82. package/dist/cjs/classes/refmap.js.map +0 -1
  83. package/dist/cjs/classes/refset.d.ts +0 -186
  84. package/dist/cjs/classes/refset.js +0 -370
  85. package/dist/cjs/classes/refset.js.map +0 -1
  86. package/dist/cjs/classes/symkeys.d.ts +0 -349
  87. package/dist/cjs/classes/symkeys.js +0 -510
  88. package/dist/cjs/classes/symkeys.js.map +0 -1
  89. package/dist/cjs/classes/type.d.ts +0 -56
  90. package/dist/cjs/classes/type.js +0 -405
  91. package/dist/cjs/classes/type.js.map +0 -1
  92. package/dist/cjs/function.extensions.d.ts +0 -12
  93. package/dist/cjs/function.extensions.js +0 -758
  94. package/dist/cjs/function.extensions.js.map +0 -1
  95. package/dist/cjs/global.this.d.ts +0 -2
  96. package/dist/cjs/global.this.js +0 -300
  97. package/dist/cjs/global.this.js.map +0 -1
  98. package/dist/cjs/index.d.ts +0 -31
  99. package/dist/cjs/index.js +0 -228
  100. package/dist/cjs/index.js.map +0 -1
  101. package/dist/cjs/json.extensions.d.ts +0 -2
  102. package/dist/cjs/json.extensions.js +0 -109
  103. package/dist/cjs/json.extensions.js.map +0 -1
  104. package/dist/cjs/map.extensions.d.ts +0 -3
  105. package/dist/cjs/map.extensions.js +0 -143
  106. package/dist/cjs/map.extensions.js.map +0 -1
  107. package/dist/cjs/math.extension.d.ts +0 -14
  108. package/dist/cjs/math.extension.js +0 -71
  109. package/dist/cjs/math.extension.js.map +0 -1
  110. package/dist/cjs/number.extension.d.ts +0 -44
  111. package/dist/cjs/number.extension.js +0 -278
  112. package/dist/cjs/number.extension.js.map +0 -1
  113. package/dist/cjs/object.extensions.d.ts +0 -33
  114. package/dist/cjs/object.extensions.js +0 -1091
  115. package/dist/cjs/object.extensions.js.map +0 -1
  116. package/dist/cjs/package.json +0 -3
  117. package/dist/cjs/proxy.extensions.d.ts +0 -2
  118. package/dist/cjs/proxy.extensions.js +0 -207
  119. package/dist/cjs/proxy.extensions.js.map +0 -1
  120. package/dist/cjs/reflect.extensions.d.ts +0 -14
  121. package/dist/cjs/reflect.extensions.js +0 -316
  122. package/dist/cjs/reflect.extensions.js.map +0 -1
  123. package/dist/cjs/regular.expression.extensions.d.ts +0 -2
  124. package/dist/cjs/regular.expression.extensions.js +0 -423
  125. package/dist/cjs/regular.expression.extensions.js.map +0 -1
  126. package/dist/cjs/set.extensions.d.ts +0 -40
  127. package/dist/cjs/set.extensions.js +0 -355
  128. package/dist/cjs/set.extensions.js.map +0 -1
  129. package/dist/cjs/string.extensions.d.ts +0 -23
  130. package/dist/cjs/string.extensions.js +0 -704
  131. package/dist/cjs/string.extensions.js.map +0 -1
  132. package/dist/cjs/symbol.extensions.d.ts +0 -11
  133. package/dist/cjs/symbol.extensions.js +0 -735
  134. package/dist/cjs/symbol.extensions.js.map +0 -1
  135. package/dist/cjs/utils/copy.object.d.ts +0 -408
  136. package/dist/cjs/utils/copy.object.js +0 -720
  137. package/dist/cjs/utils/copy.object.js.map +0 -1
  138. package/dist/cjs/utils/descriptor.utils.d.ts +0 -298
  139. package/dist/cjs/utils/descriptor.utils.js +0 -889
  140. package/dist/cjs/utils/descriptor.utils.js.map +0 -1
  141. package/dist/cjs/utils/index.d.ts +0 -75
  142. package/dist/cjs/utils/index.js +0 -61
  143. package/dist/cjs/utils/index.js.map +0 -1
  144. package/dist/cjs/utils/stdout.d.ts +0 -742
  145. package/dist/cjs/utils/stdout.js +0 -1042
  146. package/dist/cjs/utils/stdout.js.map +0 -1
  147. package/dist/cjs/utils/toolkit.d.ts +0 -1898
  148. package/dist/cjs/utils/toolkit.js +0 -1378
  149. package/dist/cjs/utils/toolkit.js.map +0 -1
  150. package/dist/cjs/weakref.extensions.d.ts +0 -2
  151. package/dist/cjs/weakref.extensions.js +0 -19
  152. package/dist/cjs/weakref.extensions.js.map +0 -1
  153. package/dist/mjs/array.extensions.d.ts +0 -39
  154. package/dist/mjs/array.extensions.js +0 -474
  155. package/dist/mjs/array.extensions.js.map +0 -1
  156. package/dist/mjs/big.int.extension.d.ts +0 -31
  157. package/dist/mjs/big.int.extension.js +0 -270
  158. package/dist/mjs/big.int.extension.js.map +0 -1
  159. package/dist/mjs/classes/asyncIterable.d.ts +0 -126
  160. package/dist/mjs/classes/asyncIterable.js +0 -204
  161. package/dist/mjs/classes/asyncIterable.js.map +0 -1
  162. package/dist/mjs/classes/deferred.d.ts +0 -146
  163. package/dist/mjs/classes/deferred.js +0 -287
  164. package/dist/mjs/classes/deferred.js.map +0 -1
  165. package/dist/mjs/classes/descriptor.d.ts +0 -334
  166. package/dist/mjs/classes/descriptor.js +0 -533
  167. package/dist/mjs/classes/descriptor.js.map +0 -1
  168. package/dist/mjs/classes/enum.d.ts +0 -50
  169. package/dist/mjs/classes/enum.js +0 -400
  170. package/dist/mjs/classes/enum.js.map +0 -1
  171. package/dist/mjs/classes/index.d.ts +0 -15
  172. package/dist/mjs/classes/index.js +0 -46
  173. package/dist/mjs/classes/index.js.map +0 -1
  174. package/dist/mjs/classes/introspector.d.ts +0 -20
  175. package/dist/mjs/classes/introspector.js +0 -126
  176. package/dist/mjs/classes/introspector.js.map +0 -1
  177. package/dist/mjs/classes/iterable.d.ts +0 -169
  178. package/dist/mjs/classes/iterable.js +0 -263
  179. package/dist/mjs/classes/iterable.js.map +0 -1
  180. package/dist/mjs/classes/param.parser.d.ts +0 -221
  181. package/dist/mjs/classes/param.parser.js +0 -238
  182. package/dist/mjs/classes/param.parser.js.map +0 -1
  183. package/dist/mjs/classes/pluggable.proxy.d.ts +0 -153
  184. package/dist/mjs/classes/pluggable.proxy.js +0 -438
  185. package/dist/mjs/classes/pluggable.proxy.js.map +0 -1
  186. package/dist/mjs/classes/property.d.ts +0 -79
  187. package/dist/mjs/classes/property.js +0 -280
  188. package/dist/mjs/classes/property.js.map +0 -1
  189. package/dist/mjs/classes/refmap.d.ts +0 -238
  190. package/dist/mjs/classes/refmap.js +0 -417
  191. package/dist/mjs/classes/refmap.js.map +0 -1
  192. package/dist/mjs/classes/refset.d.ts +0 -186
  193. package/dist/mjs/classes/refset.js +0 -366
  194. package/dist/mjs/classes/refset.js.map +0 -1
  195. package/dist/mjs/classes/symkeys.d.ts +0 -349
  196. package/dist/mjs/classes/symkeys.js +0 -506
  197. package/dist/mjs/classes/symkeys.js.map +0 -1
  198. package/dist/mjs/classes/type.d.ts +0 -56
  199. package/dist/mjs/classes/type.js +0 -401
  200. package/dist/mjs/classes/type.js.map +0 -1
  201. package/dist/mjs/function.extensions.d.ts +0 -12
  202. package/dist/mjs/function.extensions.js +0 -755
  203. package/dist/mjs/function.extensions.js.map +0 -1
  204. package/dist/mjs/global.this.d.ts +0 -2
  205. package/dist/mjs/global.this.js +0 -264
  206. package/dist/mjs/global.this.js.map +0 -1
  207. package/dist/mjs/index.d.ts +0 -31
  208. package/dist/mjs/index.js +0 -206
  209. package/dist/mjs/index.js.map +0 -1
  210. package/dist/mjs/json.extensions.d.ts +0 -2
  211. package/dist/mjs/json.extensions.js +0 -106
  212. package/dist/mjs/json.extensions.js.map +0 -1
  213. package/dist/mjs/map.extensions.d.ts +0 -3
  214. package/dist/mjs/map.extensions.js +0 -140
  215. package/dist/mjs/map.extensions.js.map +0 -1
  216. package/dist/mjs/math.extension.d.ts +0 -14
  217. package/dist/mjs/math.extension.js +0 -68
  218. package/dist/mjs/math.extension.js.map +0 -1
  219. package/dist/mjs/number.extension.d.ts +0 -44
  220. package/dist/mjs/number.extension.js +0 -275
  221. package/dist/mjs/number.extension.js.map +0 -1
  222. package/dist/mjs/object.extensions.d.ts +0 -33
  223. package/dist/mjs/object.extensions.js +0 -1088
  224. package/dist/mjs/object.extensions.js.map +0 -1
  225. package/dist/mjs/package.json +0 -3
  226. package/dist/mjs/proxy.extensions.d.ts +0 -2
  227. package/dist/mjs/proxy.extensions.js +0 -204
  228. package/dist/mjs/proxy.extensions.js.map +0 -1
  229. package/dist/mjs/reflect.extensions.d.ts +0 -14
  230. package/dist/mjs/reflect.extensions.js +0 -313
  231. package/dist/mjs/reflect.extensions.js.map +0 -1
  232. package/dist/mjs/regular.expression.extensions.d.ts +0 -2
  233. package/dist/mjs/regular.expression.extensions.js +0 -420
  234. package/dist/mjs/regular.expression.extensions.js.map +0 -1
  235. package/dist/mjs/set.extensions.d.ts +0 -40
  236. package/dist/mjs/set.extensions.js +0 -352
  237. package/dist/mjs/set.extensions.js.map +0 -1
  238. package/dist/mjs/string.extensions.d.ts +0 -23
  239. package/dist/mjs/string.extensions.js +0 -701
  240. package/dist/mjs/string.extensions.js.map +0 -1
  241. package/dist/mjs/symbol.extensions.d.ts +0 -11
  242. package/dist/mjs/symbol.extensions.js +0 -732
  243. package/dist/mjs/symbol.extensions.js.map +0 -1
  244. package/dist/mjs/utils/copy.object.d.ts +0 -408
  245. package/dist/mjs/utils/copy.object.js +0 -702
  246. package/dist/mjs/utils/copy.object.js.map +0 -1
  247. package/dist/mjs/utils/descriptor.utils.d.ts +0 -298
  248. package/dist/mjs/utils/descriptor.utils.js +0 -875
  249. package/dist/mjs/utils/descriptor.utils.js.map +0 -1
  250. package/dist/mjs/utils/index.d.ts +0 -75
  251. package/dist/mjs/utils/index.js +0 -45
  252. package/dist/mjs/utils/index.js.map +0 -1
  253. package/dist/mjs/utils/stdout.d.ts +0 -742
  254. package/dist/mjs/utils/stdout.js +0 -1037
  255. package/dist/mjs/utils/stdout.js.map +0 -1
  256. package/dist/mjs/utils/toolkit.d.ts +0 -1898
  257. package/dist/mjs/utils/toolkit.js +0 -1373
  258. package/dist/mjs/utils/toolkit.js.map +0 -1
  259. package/dist/mjs/weakref.extensions.d.ts +0 -2
  260. package/dist/mjs/weakref.extensions.js +0 -16
  261. package/dist/mjs/weakref.extensions.js.map +0 -1
  262. package/jsdoc-config.json +0 -31
  263. package/tsconfig.base.json +0 -28
  264. package/tsconfig.cjs.json +0 -8
  265. package/tsconfig.esm.json +0 -8
  266. package/vitest.config.js +0 -7
@@ -1,423 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RegExpExtensions = void 0;
4
- const extension_1 = require("@nejs/extension");
5
- exports.RegExpExtensions = new extension_1.Patch(RegExp, {
6
- [extension_1.Patch.kMutablyHidden]: {
7
- /**
8
- * Generates a regular expression pattern that matches any character.
9
- *
10
- * This method creates a regular expression pattern that matches any
11
- * character. The pattern can be configured to be greedy or non-greedy,
12
- * and to include or exclude newline characters.
13
- *
14
- * @param {boolean} [greedy=false] - If true, the pattern will be greedy,
15
- * meaning it will match as many characters as possible. If false, the
16
- * pattern will be non-greedy, meaning it will match as few characters
17
- * as possible.
18
- * @param {boolean} [includeNewlines=false] - If true, the pattern will
19
- * include newline characters ('\n' and '\r'). If false, newline
20
- * characters will be excluded from the pattern.
21
- * @returns {string} - The generated regular expression pattern.
22
- *
23
- * @example
24
- * // Generate a non-greedy pattern that excludes newlines
25
- * console.log(anything()) // Output: '[.]*?'
26
- *
27
- * @example
28
- * // Generate a greedy pattern that includes newlines
29
- * console.log(anything(true, true)) // Output: '[.\\n\\r]*'
30
- */
31
- anything(greedy = false, includeNewlines = false) {
32
- return `[.${includeNewlines ? '\\n\\r' : ''}]*${greedy ? '' : '?'}`;
33
- },
34
- /**
35
- * Creates a non-capturing group in a regular expression.
36
- *
37
- * This method wraps the provided string in a non-capturing group,
38
- * which is denoted by the syntax `(?:...)` in a regular expression.
39
- * Non-capturing groups match the pattern inside the group but do not
40
- * capture the matched content for later use.
41
- *
42
- * @param {string} string - The string to be wrapped in a non-capturing group.
43
- * @returns {string} - The string wrapped in a non-capturing group.
44
- *
45
- * @example
46
- * // Suppose we have a string 'abc'
47
- * const str = 'abc'
48
- *
49
- * // Using `nonCaptureGroup`
50
- * console.log(nonCaptureGroup(str)) // Output: '(?:abc)'
51
- */
52
- nonCaptureGroup(string) {
53
- return `(?:${string})`;
54
- },
55
- /**
56
- * Creates a capturing group in a regular expression.
57
- *
58
- * This method wraps the provided string in a capturing group,
59
- * which is denoted by the syntax `(...)` in a regular expression.
60
- * Capturing groups match the pattern inside the group and capture
61
- * the matched content for later use.
62
- *
63
- * @param {string} string - The string to be wrapped in a capturing group.
64
- * @returns {string} - The string wrapped in a capturing group.
65
- *
66
- * @example
67
- * // Suppose we have a string 'abc'
68
- * const str = 'abc'
69
- *
70
- * // Using `captureGroup`
71
- * console.log(captureGroup(str)) // Output: '(abc)'
72
- */
73
- captureGroup(string) {
74
- return `(${string})`;
75
- },
76
- /**
77
- * Creates a regular expression pattern that matches any one of the
78
- * provided strings.
79
- *
80
- * This method takes any number of strings as arguments, and returns a
81
- * string that represents a regular expression pattern. The pattern
82
- * matches any one of the provided strings. The strings are joined
83
- * together with the '|' character, which represents the OR operator
84
- * in regular expressions.
85
- *
86
- * @param {...string} strings - The strings to be included in the pattern.
87
- * @returns {string} - A string representing a regular expression pattern
88
- * that matches any one of the provided strings.
89
- *
90
- * @example
91
- * // Suppose we have strings 'abc', 'def', and 'ghi'
92
- * const str1 = 'abc'
93
- * const str2 = 'def'
94
- * const str3 = 'ghi'
95
- *
96
- * // Using `oneOf`
97
- * console.log(oneOf(str1, str2, str3)) // Output: 'abc|def|ghi'
98
- */
99
- oneOf(...strings) {
100
- return strings.join('|');
101
- },
102
- /**
103
- * Creates a regular expression pattern that matches zero or more
104
- * occurrences of the provided string.
105
- *
106
- * This method wraps the provided string in a non-capturing group,
107
- * which is denoted by the syntax `(?:...)` in a regular expression,
108
- * and appends the `*` character, which represents zero or more
109
- * occurrences in regular expressions.
110
- *
111
- * @param {string} string - The string to be matched zero or more times.
112
- * @returns {string} - A string representing a regular expression pattern
113
- * that matches zero or more occurrences of the provided string.
114
- *
115
- * @example
116
- * // Suppose we have a string 'abc'
117
- * const str = 'abc'
118
- *
119
- * // Using `zeroOrMore`
120
- * console.log(zeroOrMore(str)) // Output: '(?:abc)*'
121
- */
122
- zeroOrMore(string) {
123
- return `(?:${string})*`;
124
- },
125
- /**
126
- * Creates a regular expression pattern that matches zero or one
127
- * occurrence of the provided string.
128
- *
129
- * This method wraps the provided string in a non-capturing group,
130
- * which is denoted by the syntax `(?:...)` in a regular expression,
131
- * and appends the `?` character, which represents zero or one
132
- * occurrence in regular expressions.
133
- *
134
- * @param {string} string - The string to be matched zero or one time.
135
- * @returns {string} - A string representing a regular expression pattern
136
- * that matches zero or one occurrence of the provided string.
137
- *
138
- * @example
139
- * // Suppose we have a string 'abc'
140
- * const str = 'abc'
141
- *
142
- * // Using `zeroOrOne`
143
- * console.log(zeroOrOne(str)) // Output: '(?:abc)?'
144
- */
145
- zeroOrOne(string) {
146
- return `(?:${string})?`;
147
- },
148
- /**
149
- * Escapes special characters in a string for use in a regular expression.
150
- *
151
- * This method checks if the `RegExp.escape` method is available. If it is,
152
- * it uses that method to escape the string. If it's not, it uses a polyfill
153
- * method to escape the string.
154
- *
155
- * The polyfill method replaces all special characters in the string with
156
- * their escaped equivalents. The special characters are defined by the
157
- * regular expression `/[-[\]{}()*+?.,\\^$|#\s]/g`.
158
- *
159
- * @param {string} string - The string to be escaped.
160
- * @returns {string} - The escaped string.
161
- *
162
- * @example
163
- * // Suppose we have a string with special characters
164
- * const str = 'Hello, [World]!'
165
- *
166
- * // Using `escape` or `escapePolyfill`
167
- * console.log(RegExp[RegExp.escape ? 'escapePolyfill' : 'escape'](str))
168
- * // Output: 'Hello\\, \\[World\\]\\!'
169
- */
170
- escape(string) {
171
- return RegExpEscape(string);
172
- },
173
- /**
174
- * Getter method that returns a string 'null'.
175
- *
176
- * This method is used when you need a string representation of null
177
- * in your regular expressions. It simply returns the string 'null'.
178
- *
179
- * @returns {string} - A string 'null'.
180
- *
181
- * @example
182
- * // Using `null`
183
- * console.log(this.null) // Output: 'null'
184
- */
185
- get null() {
186
- return 'null';
187
- },
188
- /**
189
- * Getter method that returns a regular expression string for boolean
190
- * values.
191
- *
192
- * This method uses the `oneOf` method to create a regular expression
193
- * string that matches either 'true' or 'false'. This is useful when you
194
- * need to match boolean values in a string using a regular expression.
195
- *
196
- * @returns {string} - A regular expression string that matches 'true'
197
- * or 'false'.
198
- *
199
- * @example
200
- * // Using `bool`
201
- * const boolRegex = new RegExp(this.bool)
202
- * console.log(boolRegex.test('true')) // Output: true
203
- * console.log(boolRegex.test('false')) // Output: true
204
- * console.log(boolRegex.test('maybe')) // Output: false
205
- */
206
- get bool() {
207
- return this.oneOf('true', 'false');
208
- },
209
- /**
210
- * Generates a regular expression string that matches the symbols of
211
- * specified currencies.
212
- *
213
- * This method uses the Intl API to get the symbols of the specified
214
- * currencies and constructs a regular expression string that matches
215
- * these symbols. If no specific currencies are provided, it defaults
216
- * to all known currencies. If a single currency is provided as a
217
- * string, it is converted to an array. If the symbols array is empty
218
- * after filtering out unknown currencies, it defaults back to all
219
- * known currencies.
220
- *
221
- * @param {Array|string} [symbols=[['*'], ['USD','GBP']][0]] - The
222
- * currencies to include in the regular expression. Can be an array
223
- * of currency codes or a single currency code as a string. Defaults
224
- * to all known currencies.
225
- * @param {string} [locale='en-US'] - The locale to use when getting
226
- * the currency symbols. Defaults to 'en-US'.
227
- * @returns {string} - A regular expression string that matches the
228
- * symbols of the specified currencies.
229
- *
230
- * @example
231
- * // Using `currencySymbols` with default parameters
232
- * console.log(this.currencySymbols())
233
- * // Output: A regular expression string that matches all known
234
- * // currency symbols
235
- *
236
- * @example
237
- * // Using `currencySymbols` with specific currencies
238
- * console.log(this.currencySymbols(['USD', 'EUR']))
239
- * // Output: A regular expression string that matches the symbols
240
- * // of USD and EUR
241
- */
242
- currencySymbols(symbols = [['*'], ['USD', 'GBP']][0], locale = 'en-US') {
243
- const known = Intl.supportedValuesOf('currency');
244
- const has = code => !!~known.indexOf(code);
245
- if (typeof symbols === 'string' && has(symbols)) {
246
- symbols = [symbols];
247
- }
248
- if (!Array.isArray(symbols)) {
249
- symbols = known;
250
- }
251
- symbols = symbols.filter(symbol => has(symbol));
252
- if (!symbols.length) {
253
- symbols = known;
254
- }
255
- const opts = (currency) => ({ style: 'currency', currency });
256
- const fmt = (place, currency) => Intl.NumberFormat(place, opts(currency));
257
- const codes = (((symbols.length === 1 && symbols[0] === '*') ? known : symbols)
258
- .filter(code => has(code))
259
- .map(currency => {
260
- const symbol = fmt(locale, currency).formatToParts()?.[0].value;
261
- return symbol && `(?:${RegExp.escape(symbol)})`;
262
- })
263
- .join('|'));
264
- return codes;
265
- },
266
- /**
267
- * Getter method that returns a regular expression string for numbers.
268
- *
269
- * This method returns a regular expression string that matches both
270
- * integer and floating point numbers. The returned regular expression
271
- * string is '\\d+\\.?\\d*', which matches one or more digits followed
272
- * by an optional decimal point and zero or more digits.
273
- *
274
- * @returns {string} - A regular expression string that matches numbers.
275
- *
276
- * @example
277
- * // Using `number`
278
- * const numberRegex = new RegExp(this.number)
279
- * console.log(numberRegex.test('123')) // Output: true
280
- * console.log(numberRegex.test('123.45')) // Output: true
281
- * console.log(numberRegex.test('abc')) // Output: false
282
- */
283
- get number() {
284
- const instance = Object(`\\d+\\.?\\d*`);
285
- const self = this;
286
- Object.defineProperties(instance, {
287
- // alias for .float
288
- any: { get() { return String(instance); } },
289
- /**
290
- * Getter method that returns a regular expression string for floating
291
- * point numbers.
292
- *
293
- * This method returns a regular expression string that matches floating
294
- * point numbers. It leverages the 'number' getter method which matches
295
- * both integer and floating point numbers. The returned regular expression
296
- * string is '\\d+\\.?\\d*', which matches one or more digits followed by
297
- * an optional decimal point and zero or more digits.
298
- *
299
- * @returns {string} - A regular expression string that matches floating
300
- * point numbers.
301
- *
302
- * @example
303
- * // Using `float`
304
- * const floatRegex = new RegExp(this.float)
305
- * console.log(floatRegex.test('123.45')) // Output: true
306
- * console.log(floatRegex.test('123')) // Output: false
307
- * console.log(floatRegex.test('abc')) // Output: false
308
- */
309
- float: { get() { return String(instance); } },
310
- // any known locale currency symbol + .float
311
- money: { get() { return `(?:${self.currencySymbols()})?${this.float}`; } },
312
- /**
313
- * Getter method that returns a regular expression string for integers.
314
- *
315
- * This method returns a regular expression string that matches integer
316
- * numbers. The returned regular expression string is '\\d+', which matches
317
- * one or more digits.
318
- *
319
- * @returns {string} - A regular expression string that matches integers.
320
- *
321
- * @example
322
- * // Using `integer`
323
- * const integerRegex = new RegExp(this.integer)
324
- * console.log(integerRegex.test('123')) // Output: true
325
- * console.log(integerRegex.test('123.45')) // Output: false
326
- * console.log(integerRegex.test('abc')) // Output: false
327
- */
328
- integer: { get() { return `\\d+`; } },
329
- /**
330
- * Getter method that returns a regular expression string for pretty
331
- * numbers.
332
- *
333
- * This method returns a regular expression string that matches numbers
334
- * with commas or spaces for thousands separators. The returned regular
335
- * expression string is '[\\d\\$]+\\.?[\\d,\\$]*', which matches one or
336
- * more digits or dollar signs, followed by an optional decimal point,
337
- * and zero or more digits, commas, or dollar signs.
338
- *
339
- * @returns {string} - A regular expression string that matches pretty
340
- * numbers.
341
- *
342
- * @example
343
- * // Using `pretty`
344
- * const prettyRegex = new RegExp(this.pretty)
345
- * console.log(prettyRegex.test('1,234.56')) // Output: true
346
- * console.log(prettyRegex.test('1234.56')) // Output: true
347
- * console.log(prettyRegex.test('1 234.56')) // Output: true
348
- * console.log(prettyRegex.test('abc')) // Output: false
349
- */
350
- pretty: {
351
- value(locale = 'en-US') {
352
- const symbols = self.zeroOrMore(self.currencySymbols(['*'], locale));
353
- return `${symbols}[\\d,]+\\.?[\\d]*`;
354
- }
355
- },
356
- /**
357
- * Getter method that returns a regular expression string for JavaScript
358
- * literals.
359
- *
360
- * This method returns a regular expression string that matches JavaScript
361
- * literals. The returned regular expression string is '[\\d_]+', which
362
- * matches one or more digits or underscores.
363
- *
364
- * @returns {string} - A regular expression string that matches JavaScript
365
- * literals.
366
- *
367
- * @example
368
- * // Using `jsLiteral`
369
- * const jsLiteralRegex = new RegExp(this.jsLiteral)
370
- * console.log(jsLiteralRegex.test('123_456')) // Output: true
371
- * console.log(jsLiteralRegex.test('abc')) // Output: false
372
- */
373
- jsLiteral: { get() { return `[\\d_]+`; } }
374
- });
375
- return instance;
376
- },
377
- /**
378
- * Getter method that returns a regular expression string for integers.
379
- *
380
- * This method returns a regular expression string that matches integer
381
- * numbers. The returned regular expression string is '\\d+', which matches
382
- * one or more digits.
383
- *
384
- * @returns {string} - A regular expression string that matches integers.
385
- *
386
- * @example
387
- * // Using `integer`
388
- * const integerRegex = new RegExp(this.integer)
389
- * console.log(integerRegex.test('123')) // Output: true
390
- * console.log(integerRegex.test('123.45')) // Output: false
391
- * console.log(integerRegex.test('abc')) // Output: false
392
- */
393
- get integer() {
394
- return `\\d+`;
395
- },
396
- get string() {
397
- return {
398
- get doubleQuoted() {
399
- return '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"';
400
- },
401
- get singleQuoted() {
402
- return "'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'";
403
- }
404
- };
405
- },
406
- get whitespace() {
407
- return `\\s*`;
408
- },
409
- get comma() {
410
- return `,${this.whitespace}`;
411
- },
412
- }
413
- }, {
414
- conditions: {
415
- ['escape']() { return !Reflect.has(RegExp, 'escape'); },
416
- }
417
- });
418
- // Simple variant that does not require external dependencies; may not cover
419
- // all known use cases.
420
- function RegExpEscape(string) {
421
- return string.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
422
- }
423
- //# sourceMappingURL=regular.expression.extensions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"regular.expression.extensions.js","sourceRoot":"","sources":["../../src/regular.expression.extensions.js"],"names":[],"mappings":";;;AAAA,+CAAuC;AAE1B,QAAA,gBAAgB,GAAG,IAAI,iBAAK,CAAC,MAAM,EAAE;IAChD,CAAC,iBAAK,CAAC,cAAc,CAAC,EAAE;QACtB;;;;;;;;;;;;;;;;;;;;;;;WAuBG;QACH,QAAQ,CAAC,MAAM,GAAG,KAAK,EAAE,eAAe,GAAG,KAAK;YAC9C,OAAO,KAAK,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC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QAGD;;;;;;;;;;;;;;;WAeG;QACH,IAAI,OAAO;YACT,OAAO,MAAM,CAAA;QACf,CAAC;QAED,IAAI,MAAM;YACR,OAAO;gBACL,IAAI,YAAY;oBACd,OAAO,gCAAgC,CAAA;gBACzC,CAAC;gBAED,IAAI,YAAY;oBACd,OAAO,gCAAgC,CAAA;gBACzC,CAAC;aACF,CAAA;QACH,CAAC;QAED,IAAI,UAAU;YACZ,OAAO,MAAM,CAAA;QACf,CAAC;QAED,IAAI,KAAK;YACP,OAAO,IAAI,IAAI,CAAC,UAAU,EAAE,CAAA;QAC9B,CAAC;KACF;CACF,EAAE;IACD,UAAU,EAAE;QACV,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAE,CAAA,CAAA,CAAC;KACvD;CACF,CAAC,CAAA;AAEF,4EAA4E;AAC5E,uBAAuB;AACvB,SAAS,YAAY,CAAC,MAAM;IAC1B,OAAO,MAAM,CAAC,OAAO,CAAC,qCAAqC,EAAE,MAAM,CAAC,CAAC;AACvE,CAAC"}
@@ -1,40 +0,0 @@
1
- /**
2
- * `SetExtensions` is a constant that applies a patch to the global
3
- * `Set` constructor. This patch extends the `Set` 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, `Set`), 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 SetExtensions
12
- * const set = new Set();
13
- * console.log(Set.isSet(set)); // Output: true
14
- *
15
- * @const
16
- * @type {Patch}
17
- * @memberof module:set.extensions
18
- */
19
- export const SetExtensions: Patch;
20
- /**
21
- * `SetPrototypeExtensions` is a constant that applies a patch to the
22
- * prototype of the built-in JavaScript `Set` object. This patch extends the
23
- * `Set` prototype with additional methods and properties, enhancing its
24
- * functionality.
25
- *
26
- * The `Patch` function takes two arguments: the target object to be patched
27
- * (in this case, `Set.prototype`), and an object containing the methods and
28
- * properties to be added to the target object.
29
- *
30
- * @example
31
- * // Using a method added by SetPrototypeExtensions
32
- * const mySet = new Set();
33
- * mySet.myNewMethod(); // Calls the new method added by the patch
34
- *
35
- * @const
36
- * @type {Patch}
37
- * @memberof module:set.extensions
38
- */
39
- export const SetPrototypeExtensions: Patch;
40
- import { Patch } from '@nejs/extension';