@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,537 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DescriptorExtensions = exports.Descriptor = void 0;
4
- const extension_1 = require("@nejs/extension");
5
- const descriptor_utils_js_1 = require("../utils/descriptor.utils.js");
6
- class Descriptor {
7
- /**
8
- * The default private descriptor value is that of `enigmatic`
9
- *
10
- * @private
11
- * @type {object}
12
- */
13
- _desc = undefined;
14
- /**
15
- * An optionally associated object, usually the parent from which
16
- * the descriptor was taken, or undefined if none was able to be
17
- * derived.
18
- *
19
- * @type {object}
20
- */
21
- _object = undefined;
22
- /**
23
- * Constructs a Descriptor instance which wraps and manages an object
24
- * property descriptor. The constructor can handle an existing descriptor
25
- * object or create a new one based on an object and a property key.
26
- *
27
- * @param {object|Descriptor} object - The target object or an existing
28
- * Descriptor instance. If it's an object, it is used in conjunction with
29
- * `key` to create a descriptor. If it's a Descriptor instance, it is used
30
- * directly as the descriptor.
31
- * @param {string|symbol} [key] - The property key for which the descriptor
32
- * is to be created. This parameter is ignored if `object` is a Descriptor
33
- * instance. If `key` is an object and `object` is a valid descriptor, `key`
34
- * is treated as the associated object.
35
- * @throws {Error} Throws an error if the constructed descriptor is not
36
- * valid.
37
- */
38
- constructor(object, key) {
39
- if (arguments.length === 0) {
40
- this._desc = Descriptor.enigmatic;
41
- }
42
- else if (Descriptor.isDescriptor(object)) {
43
- this._desc = object;
44
- this._object = isObject(key) ? key : undefined;
45
- }
46
- else if (isObject(object) && isValidKey(key)) {
47
- console.log('new Descriptor(%o, %o)', object, key);
48
- this._desc = Object.getOwnPropertyDescriptor(object, key);
49
- this._object = object;
50
- }
51
- if (!this.isDescriptor) {
52
- const objectMsg = object === globalThis
53
- ? '[GLOBAL]'
54
- : (typeof key === 'object' ? JSON.stringify(object) : String(object));
55
- const keyMsg = key === globalThis
56
- ? '[GLOBAL]'
57
- : (typeof key === 'object' ? JSON.stringify(key) : String(key));
58
- console.error(`
59
- Descriptor(object: ${object}, key: ${key}) FAILED:
60
- object: ${objectMsg}
61
- key: ${keyMsg}
62
- descriptor: `, this._desc);
63
- throw new Error(`Not a valid descriptor:`, this._desc);
64
- }
65
- }
66
- /**
67
- * Detects whether or not this instance is an accessor object descriptor
68
- *
69
- * @returns {boolean} true if this object has a getter or setter and is not
70
- * a data descriptor
71
- */
72
- get isAccessor() {
73
- return (0, descriptor_utils_js_1.isDescriptor)(this._desc, true).isAccessor;
74
- }
75
- /**
76
- * Detects whether or not this instance is an data object descriptor
77
- *
78
- * @returns {boolean} true if this object has a value property and is not
79
- * an accessor descriptor
80
- */
81
- get isData() {
82
- return (0, descriptor_utils_js_1.isDescriptor)(this._desc, true).isData;
83
- }
84
- /**
85
- * Detects whether or not this instance is a valid object descriptor
86
- *
87
- * @returns {boolean} true if this descriptor store is a valid descriptor
88
- */
89
- get isDescriptor() {
90
- return (0, descriptor_utils_js_1.isDescriptor)(this._desc);
91
- }
92
- /**
93
- * Retrieves the {@link get} function for this accessor and binds it to
94
- * the object from which the descriptor was derived, if that value is set.
95
- * Otherwise this method is identical to the {@link get} accessor.
96
- *
97
- * @returns {function} the getter if one is defined. If possible this
98
- * getter will be bound the associated and previously set `object`.
99
- */
100
- get boundGet() {
101
- return (isObject(this._object) ? this.get?.bind(this._object) : this.get);
102
- }
103
- /**
104
- * Retrieves the {@link set} function for this accessor and binds it to
105
- * the object from which the descriptor was derived, if that value is set.
106
- * Otherwise this method is identical to the {@link set} accessor.
107
- *
108
- * @returns {function} the setter if one is defined. If possible this
109
- * setter will be bound the associated and previously set `object`.
110
- */
111
- get boundSet() {
112
- return (isObject(this._object) ? this.set?.bind(this._object) : this.set);
113
- }
114
- /**
115
- * The function checks the descriptor's associated object has been set on this
116
- * instance of `Descriptor`.
117
- *
118
- * @returns {boolean} `true` if the `object` property has been set,
119
- * `false` otherwise
120
- */
121
- get hasObject() { return isObject(this._object); }
122
- /**
123
- * Returns the descriptor's associated `object` value. This is usually the
124
- * parent object from which the descriptor was derived. If the value is preset
125
- * it will be returned. Undefined will be returned otherwise
126
- *
127
- * @returns {object} the associated object for this descriptor or undefined
128
- * if it has not yet been set.
129
- */
130
- get object() { return this._object; }
131
- /**
132
- * Sets the descriptor's associated `object` value. This is usually the
133
- * parent object from which the descriptor was derived.
134
- *
135
- * @param {object} value sets the object for which this descriptor is to
136
- * be associated with.
137
- */
138
- set object(value) { this._object = Object(value); }
139
- /**
140
- * Take the descriptor defined by this objects values and apply them to
141
- * the specified object using the specified key.
142
- *
143
- * @param {object} object the object to apply this descriptor to
144
- * @param {string|symbol} forKey the string or symbol for which this
145
- * descriptor will abe applied
146
- */
147
- applyTo(object, forKey, bindAccessors = false) {
148
- if (!isObject(object) || !isValidKey(forKey)) {
149
- throw new Error(`Cannot apply descriptor to non-object or invalid key`);
150
- }
151
- return Object.defineProperty(object, forKey, this.toObject(bindAccessors));
152
- }
153
- /**
154
- * Converts this Descriptor class instance into a basic object descriptor
155
- * that is accepted by all the standard JavaScript runtime methods that
156
- * deal with object descriptors.
157
- *
158
- * @param {boolean|object} bindAccessors if `true`, a non-fatal attempt to
159
- * bind accessor getter and setter methods is made before returning the
160
- * object. If `bindAccessors` is truthy and is also an object, this is the
161
- * object the accessors will be bound to. If the value is falsy or if the
162
- * descriptor instance represents a data descriptor, nothing happens.
163
- * @returns {object} the object instance's basic object representation as
164
- * a descriptor.
165
- */
166
- toObject(bindAccessors = false) {
167
- let descriptor = { ...this._desc };
168
- if (bindAccessors && this.isAccessor) {
169
- if (this.hasObject) {
170
- descriptor = {
171
- ...descriptor,
172
- get: this.boundGet,
173
- set: this.boundSet
174
- };
175
- }
176
- else if (isObject(bindAccessors)) {
177
- descriptor = {
178
- ...descriptor,
179
- get: this.get?.bind(bindAccessors),
180
- set: this.set?.bind(bindAccessors)
181
- };
182
- }
183
- }
184
- return descriptor;
185
- }
186
- /**
187
- * The function returns a string representation of a descriptor object with
188
- * additional information about its type when used in the NodeJS repl.
189
- *
190
- * @param {number} depth - The `depth` parameter is used to specify the
191
- * maximum depth to which nested objects and arrays will be formatted. If
192
- * the depth is exceeded, the output will be truncated with ellipses.
193
- * @param {object} options - The `options` parameter is an object that
194
- * contains various configuration options for the `inspect` function.
195
- * These options can be used to customize the output of the inspection.
196
- * @param {function} inspect - The `inspect` parameter is a function that
197
- * is used to convert an object into a string representation. It is
198
- * typically used for debugging purposes or when displaying an object's
199
- * properties.
200
- * @returns a string that represents a descriptor. The string includes the
201
- * type of the descriptor (either "Accessor" or "Data") and the result of
202
- * inspecting the descriptor object using the provided options and depth.
203
- */
204
- [Symbol.for('nodejs.util.inspect.custom')](depth, options, inspect) {
205
- const type = this.isAccessor ? ' (Accessor)' : this.isData ? ' (Data)' : '';
206
- return `Descriptor${type} ${inspect(this._desc, { ...options, depth })}`;
207
- }
208
- /**
209
- * Converts this descriptor object into a base representation
210
- *
211
- * @param {string} hint one of `string`, `number` or default;
212
- * @returns if the hint is 'string', then a string identifying the enum
213
- * and its type is returned. `number` will always be NaN since it is incoret
214
- */
215
- [Symbol.toPrimitive](hint) {
216
- switch (hint) {
217
- case 'string':
218
- if (this.isAccessor) {
219
- const props = [];
220
- if (Reflect.has(this._desc, 'get'))
221
- props.push('getter');
222
- if (Reflect.has(this._desc, 'set'))
223
- props.push('setter');
224
- return `Accessor (${props.join(', ')})`;
225
- }
226
- else if (this.isData) {
227
- const props = [];
228
- if (Reflect.has(this._desc, 'value'))
229
- props.push('value');
230
- if (Reflect.has(this._desc, 'writable'))
231
- props.push('writable');
232
- return `Data (${props.join(', ')})`;
233
- }
234
- break;
235
- case 'number':
236
- return NaN;
237
- default:
238
- return this.toObject();
239
- }
240
- }
241
- /**
242
- * Ensures that the constructor of this object instance's name
243
- * is returned if the string tag for this instance is queried
244
- *
245
- * @returns {string} the name of the class
246
- */
247
- get [Symbol.toStringTag]() {
248
- return this.constructor.name;
249
- }
250
- /**
251
- * The function `getData` retrieves the value of a property from an object
252
- * if it exists and is a data property.
253
- *
254
- * @param {object} object - The "object" parameter is the object from which
255
- * we want to retrieve data.
256
- * @param {string|symbol} property - The `property` parameter is the name of
257
- * the property that you want to retrieve the data from.
258
- * @returns either the value of the specified property if it exists and is
259
- * a data property, or undefined if the property does not exist or is not
260
- * a data property.
261
- */
262
- static getData(object, property) {
263
- if (!isObject(object) || !Reflect.has(object, property)) {
264
- return undefined;
265
- }
266
- const descriptor = Descriptor.for(object, property, true);
267
- if (!descriptor.isData) {
268
- return null;
269
- }
270
- return descriptor.value;
271
- }
272
- /**
273
- * The function `getAccessor` checks if an object has a getter/setter accessor
274
- * for a given property and returns the accessor functions if found.
275
- *
276
- * @param object - The `object` parameter is the object from which we want to
277
- * retrieve the accessor for a specific property.
278
- * @param property - The `property` parameter is the name of the property for
279
- * which we want to get the accessor.
280
- * @returns an object that contains the getter and setter functions for the
281
- * specified property of the given object. If the property is an accessor
282
- * property (defined with a getter and/or setter), the returned object will
283
- * also have additional properties such as "accessor" and "descriptor". If
284
- * the property is not found or is not an accessor property, the function
285
- * returns undefined.
286
- */
287
- static getAccessor(object, property) {
288
- if (!isObject(object) || !Reflect.has(object, property)) {
289
- return undefined;
290
- }
291
- const descriptor = Descriptor.for(object, property, true);
292
- if (!descriptor.isAccessor) {
293
- return null;
294
- }
295
- return descriptor.get.bind(object)();
296
- }
297
- /**
298
- * The function returns an object with enumerable and configurable properties
299
- * based on the input parameters.
300
- *
301
- * @param [enumerable=false] - A boolean value indicating whether the property
302
- * can be enumerated (listed) when iterating over the object's properties.
303
- * @param [configurable=false] - The `configurable` parameter determines
304
- * whether the property can be deleted or its attributes can be modified.
305
- * If `configurable` is set to `true`, the property can be deleted and its
306
- * attributes can be changed. If `configurable` is set to `false`, the
307
- * property cannot be deleted and
308
- * @returns An object with the properties `enumerable` and `configurable` is
309
- * being returned. The values of these properties are determined by the
310
- * arguments passed to the `base` function.
311
- */
312
- static base(enumerable = false, configurable = false) {
313
- return {
314
- enumerable,
315
- configurable
316
- };
317
- }
318
- /**
319
- * The function "newAccessor" creates a new property descriptor object with a
320
- * getter and setter function, along with optional enumerable and configurable
321
- * flags.
322
- *
323
- * @param getter - The getter parameter is a function that will be used as the
324
- * getter for the property. It will be called when the property is accessed.
325
- * @param setter - The `setter` parameter is a function that will be used as
326
- * the setter for the property. It will be called whenever the property is
327
- * assigned a new value.
328
- * @param [] - - `getter`: A function that will be used as the getter for the
329
- * property.
330
- * @returns an object with properties "get", "set", "enumerable", and
331
- * "configurable".
332
- */
333
- static accessor() {
334
- return (0, descriptor_utils_js_1.accessor)(...arguments);
335
- }
336
- /**
337
- * The function "newData" creates a new data object with customizable
338
- * properties.
339
- *
340
- * @param value - The value parameter represents the value that will be
341
- * assigned to the property.
342
- * @param [writable=true] - The `writable` parameter determines whether the
343
- * value of the property can be changed. If `writable` is set to `true`, the
344
- * value can be changed. If `writable` is set to `false`, the value cannot be
345
- * changed.
346
- * @param [] - - `value`: The value to be assigned to the property.
347
- * @returns an object with properties `value`, `enumerable`, `writable`, and
348
- * `configurable`.
349
- */
350
- static data(value, writable = true, { enumerable, configurable } = { configurable: true, enumerable: true }) {
351
- return (0, descriptor_utils_js_1.data)(value, writable, enumerable, configurable);
352
- }
353
- /**
354
- * Shorthand for Object.getOwnPropertyDescriptor()
355
- *
356
- * @param {object} object a non-null object instance
357
- * @param {string|symbol} key a symbol or string referencing which key on the
358
- * object to return a descriptor for.
359
- * @returns an object descriptor for the requested field or null
360
- */
361
- static for(object, key, wrap = false) {
362
- if (!isObject(object) || !isValidKey(key) || !Reflect.has(object, key)) {
363
- return null;
364
- }
365
- return (wrap
366
- ? new Descriptor(Object.getOwnPropertyDescriptor(object, key))
367
- : Object.getOwnPropertyDescriptor(object, key));
368
- }
369
- /**
370
- * The function checks if an object is a likely an object descriptor in
371
- * JavaScript. This is determined as an object with some of the known
372
- * descriptor keys (e.g. enumerable, configurable, value, writable, get,
373
- * or set). Technically, any object could serve as a descriptor but this
374
- * function only returns true if known descriptor keys are found.
375
- *
376
- * @param {any} object - Any value we want to check for being a descriptor.
377
- * @param {boolean} returnStatsInstead defaults to false, but if the value
378
- * is `true` then an object with reasoning behind the decision of whether
379
- * or not the
380
- * @returns {IsDescriptorResponse} either a {@link boolean} value or
381
- * an object conforming to {@link IsDescriptorStats} if `returnStatsInstead`
382
- * is `true`
383
- *
384
- * @see {@link DescriptorUtils.isDescriptor}
385
- */
386
- static isDescriptor(object, returnStatsInstead = false) {
387
- return (0, descriptor_utils_js_1.isDescriptor)(object, returnStatsInstead);
388
- }
389
- /**
390
- * The function checks if a given property descriptor or property of an
391
- * object is an accessor.
392
- *
393
- * @param {object} objectOrDescriptor - The `objectOrDescriptor` parameter
394
- * can be either a descriptor object or a property name.
395
- * @param {(string|number|symbol)?} property the property name you wish to
396
- * check the validity as an accessor descriptor. Only expected if the
397
- * `objectOrDescriptor` parameter is the object that would contain this
398
- * property.
399
- * @returns {@link Boolean} returning `true` if the `descriptor` object
400
- * has any keys that match the {@link Descriptor.ACCESSOR_KEYS} array,
401
- * otherwise it returns `false`.
402
- */
403
- static isAccessor(objectOrDescriptor, property) {
404
- const needsDescriptor = objectOrDescriptor &&
405
- property &&
406
- isObject(objectOrDescriptor) &&
407
- isValidKey(property);
408
- const descriptor = needsDescriptor
409
- ? Descriptor.for(objectOrDescriptor, property)
410
- : objectOrDescriptor;
411
- return (0, descriptor_utils_js_1.isDescriptor)(descriptor, true).isAccessor;
412
- }
413
- /**
414
- * The function checks if a given property or descriptor is a data property.
415
- *
416
- * @param {object} objectOrDescriptor - The `objectOrDescriptor` parameter
417
- * can be either a descriptor object or a property name.
418
- * @param {(string|number|symbol)?} property the property name you wish to
419
- * check the validity as an accessor descriptor. Only expected if the
420
- * `objectOrDescriptor` parameter is the object that would contain this
421
- * property.
422
- * @returns {@link Boolean} returning `true` if the `descriptor` object
423
- * has any keys that match the {@link Descriptor.DATA_KEYS} array, otherwise
424
- * it returns `false`.
425
- */
426
- static isData(objectOrDescriptor, property) {
427
- const needsDescriptor = objectOrDescriptor &&
428
- property &&
429
- isObject(objectOrDescriptor) &&
430
- isValidKey(property);
431
- const descriptor = needsDescriptor
432
- ? Descriptor.for(objectOrDescriptor, property)
433
- : objectOrDescriptor;
434
- return (0, descriptor_utils_js_1.isDescriptor)(descriptor, true).isData;
435
- }
436
- /**
437
- * A base descriptor (new for each read) that is both enumerable and
438
- * configurable
439
- *
440
- * @returns `{ enumerable: true, configurable: true }`
441
- */
442
- static get flexible() {
443
- return { enumerable: true, configurable: true };
444
- }
445
- /**
446
- * A base descriptor (new for each read) that is not enumerable but is
447
- * configurable
448
- *
449
- * @returns `{ enumerable: false, configurable: true }`
450
- */
451
- static get enigmatic() {
452
- return { enumerable: false, configurable: true };
453
- }
454
- /**
455
- * A base descriptor (new for each read) that is neither enumerable
456
- * nor configurable.
457
- *
458
- * @returns `{ enumerable: false, configurable: false }`
459
- */
460
- static get intrinsic() {
461
- return { enumerable: false, configurable: false };
462
- }
463
- /**
464
- * A base descriptor (new for each read) that is enumerable but
465
- * not configurable
466
- *
467
- * @returns `{ enumerable: true, configurable: false }`
468
- */
469
- static get transparent() {
470
- return { enumerable: true, configurable: false };
471
- }
472
- /**
473
- * The function returns an array of shared descriptor keys.
474
- *
475
- * @returns An array containing the strings 'configurable' and 'enumerable'.
476
- */
477
- static get SHARED_KEYS() {
478
- return descriptor_utils_js_1.kSharedDescriptorKeys;
479
- }
480
- /**
481
- * The function returns an array of accessor descriptor keys.
482
- *
483
- * @returns An array containing the strings 'get' and 'set' is being returned.
484
- */
485
- static get ACCESSOR_KEYS() {
486
- return descriptor_utils_js_1.kAccessorDescriptorKeys;
487
- }
488
- /**
489
- * The function returns an array of data descriptor keys.
490
- *
491
- * @returns An array containing the strings 'value' and 'writable' is being
492
- * returned.
493
- */
494
- static get DATA_KEYS() {
495
- return descriptor_utils_js_1.kDataDescriptorKeys;
496
- }
497
- static {
498
- for (const key of descriptor_utils_js_1.kDescriptorKeys) {
499
- Object.defineProperties(Descriptor.prototype, {
500
- [key]: (0, descriptor_utils_js_1.accessor)(function getMaker(storage) {
501
- return function get() {
502
- return this._desc[key];
503
- };
504
- }, function setMaker(storage) {
505
- return function set(value) {
506
- this._desc[key] = value;
507
- };
508
- })
509
- });
510
- }
511
- }
512
- }
513
- exports.Descriptor = Descriptor;
514
- exports.DescriptorExtensions = new extension_1.Extension(Descriptor);
515
- function typeOrType(type, Class, notNullish = true) {
516
- return (value) => ((!notNullish || (notNullish && value !== null && value !== undefined)) &&
517
- (typeof value === type || (value && value instanceof Class)));
518
- }
519
- function isObject(o) { return typeOrType('object', Object)(o); }
520
- function isString(o) { return typeOrType('string', String)(o); }
521
- function isNumber(o) { return typeOrType('number', Number)(o); }
522
- function isSymbol(o) { return typeOrType('symbol', Symbol)(o); }
523
- function isFunction(o) { return typeOrType('function', Function)(o); }
524
- function isValidKey(o) { return isString(o) || isNumber(o) || isSymbol(o); }
525
- function hasAll(object, ...keys) { return hasQuantity('every', object, keys); }
526
- function hasSome(object, ...keys) { return hasQuantity('some', object, keys); }
527
- function hasQuantity(quantityFn, object, keys) {
528
- return isObject(object) && (keys.flat(Infinity)
529
- .map(key => Reflect.has(object, key))[quantityFn](has => has));
530
- }
531
- function hasOne(object, ...keys) {
532
- return isObject(object) && (keys.flat(Infinity)
533
- .map(key => Reflect.has(object, key))
534
- .filter(has => has)
535
- .length === 1);
536
- }
537
- //# sourceMappingURL=descriptor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"descriptor.js","sourceRoot":"","sources":["../../../src/classes/descriptor.js"],"names":[],"mappings":";;;AAAA,+CAA2C;AAE3C,sEAQqC;AAErC,MAAa,UAAU;IACrB;;;;;OAKG;IACH,KAAK,GAAG,SAAS,CAAA;IAEjB;;;;;;OAMG;IACH,OAAO,GAAG,SAAS,CAAA;IAEnB;;;;;;;;;;;;;;;OAeG;IACH,YAAY,M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,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;SAC5C,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;SACpC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC;SAClB,MAAM,KAAK,CAAC,CACd,CAAA;AACH,CAAC"}
@@ -1,50 +0,0 @@
1
- /**
2
- * Creates an enumeration object with specified values and properties.
3
- *
4
- * @param {string} name - The name of the enumeration.
5
- * @param {Array|any} values - The values to be included in the enumeration.
6
- * If not an array, it will be converted into a single-element array.
7
- * @param {Object|Map} [properties] - Additional properties to be added to
8
- * the enumeration. Can be an object or a Map.
9
- * @returns {Object} The constructed enumeration object.
10
- *
11
- * @example
12
- * const colors = Enum('Colors', ['red', 'green', 'blue'])
13
- * console.log(colors.red) // EnumValue object for 'red'
14
- *
15
- * @description
16
- * The `Enum` function constructs an enumeration object with a given name,
17
- * values, and optional properties. It supports primitive types, arrays,
18
- * and objects as values. The function uses a combination of `Object.create`
19
- * and `Proxy` to define and manage the properties of the enumeration.
20
- *
21
- * The enumeration object includes:
22
- * - A `toString` method that returns the enumeration name.
23
- * - A `Symbol.toStringTag` for identifying the object as an 'Enum'.
24
- * - A `Symbol.for('Enum.name')` for storing the enumeration name.
25
- *
26
- * For array values, it creates a maker function that returns an
27
- * `EnumValue` object with properties like `real`, `value`, `type`,
28
- * `name`, and `compare`.
29
- */
30
- export function Enum(name: string, values: any[] | any, properties?: Object | Map<any, any>): Object;
31
- /**
32
- * Creates a base enumeration object with predefined properties and
33
- * symbols. This function is used to initialize an enumeration with
34
- * specific characteristics, such as a name and various symbolic
35
- * properties that enhance its functionality and identification.
36
- *
37
- * @param {string} name - The name of the enumeration. This name is
38
- * used to identify the enumeration and is stored as a symbol on
39
- * the object.
40
- * @returns {Object} A new enumeration object with specific properties
41
- * and symbols set for enhanced functionality and identification.
42
- *
43
- * @example
44
- * // Create a base enum with the name 'Color'
45
- * const colorEnum = makeBaseEnum('Color')
46
- * console.log(colorEnum[Symbol.for('Enum.name')]) // Outputs: 'Color'
47
- */
48
- export function makeBaseEnum(name: string): Object;
49
- export const EnumExtension: Extension;
50
- import { Extension } from '@nejs/extension';