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