@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,284 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PropertyExtensions = exports.Property = void 0;
4
- const extension_1 = require("@nejs/extension");
5
- class Property {
6
- constructor(key, descriptor) {
7
- if (key.startsWith(':'))
8
- key = Symbol.for(key.slice(1));
9
- if (typeof key !== 'string' && typeof key !== 'symbol') {
10
- throw new TypeError('Key or symbol or :symbol must be supplied!');
11
- }
12
- this.key = key;
13
- if (!Property.is.descriptor(descriptor)) {
14
- this.descriptor = {
15
- value: descriptor,
16
- writable: true,
17
- configurable: true,
18
- enumerable: true,
19
- };
20
- }
21
- else {
22
- this.descriptor = descriptor;
23
- }
24
- }
25
- apply(toObject, asKey) {
26
- if (!toObject || !['object', 'function'].some(k => k == typeof toObject))
27
- return;
28
- return Object.defineProperty(toObject, asKey ?? this.key, this.descriptor);
29
- }
30
- get descriptor() {
31
- const baseline = { configurable: true, enumerable: false };
32
- const result = {
33
- enumerable: this.meta.enumerable,
34
- configurable: this.meta.configurable,
35
- };
36
- if (this.is.accessor) {
37
- result.get = this.meta.accessor.get;
38
- result.set = this.meta.accessor.set;
39
- }
40
- else {
41
- result.value = this.meta.data.value;
42
- result.writable = this.meta.data.writable;
43
- }
44
- return Object.defineProperties(result, {
45
- make: {
46
- ...baseline,
47
- get() {
48
- const self = this;
49
- return {
50
- get enumerable() { self.enumerable = true; return self; },
51
- get hidden() { self.enumerable = false; return self; },
52
- get writable() { self.writable = true; return self; },
53
- get readonly() { self.writable = false; return self; },
54
- get configurable() { self.configurable = true; return self; },
55
- get immutable() { self.configurable = false; return self; },
56
- };
57
- }
58
- },
59
- is: {
60
- ...baseline,
61
- get() {
62
- const self = this;
63
- return {
64
- get accessor() { return self.is.accssor; },
65
- get data() { return self.is.data; }
66
- };
67
- }
68
- },
69
- });
70
- }
71
- set descriptor(descriptor) {
72
- const { is } = this.constructor;
73
- if (!is.descriptor(descriptor))
74
- return;
75
- this.meta.configurable = descriptor.configurable ?? true;
76
- this.meta.enumerable = descriptor.enumerable ?? true;
77
- if (Reflect.has(descriptor, 'get') || Reflect.has(descriptor, 'set')) {
78
- const { get, set } = descriptor;
79
- if (get !== undefined)
80
- this.meta.accessor.get = get;
81
- if (set !== undefined)
82
- this.meta.accessor.set = set;
83
- }
84
- else {
85
- const { value, writable } = descriptor;
86
- this.meta.data.value = value;
87
- this.meta.data.writable = writable ?? true;
88
- }
89
- }
90
- get is() {
91
- const self = this;
92
- return {
93
- get accessor() {
94
- return !!(self.meta.accessor.get ||
95
- self.meta.accessor.set);
96
- },
97
- get data() {
98
- return !!!this.accessor;
99
- },
100
- };
101
- }
102
- toString(colors = false, { key, descriptor } = {}) {
103
- const bold = s => colors ? `\x1b[1m${s}\x1b[22m` : s;
104
- const dim = s => colors ? `\x1b[2m${s}\x1b[22m` : s;
105
- const red = s => colors ? `\x1b[31m${s}\x1b[39m` : s;
106
- const green = s => colors ? `\x1b[32m${s}\x1b[39m` : s;
107
- const blue = s => colors ? `\x1b[34m${s}\x1b[39m` : s;
108
- if (!key)
109
- ({ key } = this);
110
- if (!descriptor || !Property.is.descriptor(descriptor))
111
- ({ descriptor } = this);
112
- const buffer = [`${bold(key)} { `];
113
- const keyPresent = (object) => (key) => Reflect.has(object, key);
114
- const eqeq = (value, compare = (a, b) => a === b) => (element) => compare(element, value);
115
- if (['get', 'set'].some(keyPresent(descriptor))) {
116
- if (descriptor.get) {
117
- buffer.push(blue('getter'));
118
- if (descriptor.set) {
119
- buffer.push(bold('|'));
120
- }
121
- }
122
- if (descriptor.set) {
123
- buffer.push(blue('setter'));
124
- }
125
- }
126
- else {
127
- buffer.push(green('value'));
128
- buffer.push(bold('|'));
129
- buffer.push(descriptor.writable ? green('writable') : red('readonly'));
130
- }
131
- buffer.push(' ');
132
- buffer.push(descriptor.configurable ? green('mutable') : red('immuatable'));
133
- buffer.push(' ');
134
- buffer.push(descriptor.enumerable ? green('visible') : red('hidden'));
135
- buffer.push(' }');
136
- return buffer.join('');
137
- }
138
- [Symbol.for('nodejs.util.inspect.custom')](depth, options, inspect) {
139
- return this.toString(true);
140
- }
141
- /**
142
- * Creates an accessor property with customizable getter and setter functions.
143
- *
144
- * This method offers flexible ways to define accessor properties, including
145
- * support for storage-based getters and setters. It can handle various input
146
- * formats, making it versatile for different use cases.
147
- *
148
- * @param {string} name - The name of the accessor property.
149
- * @param {Object} accessors - Object containing getter and/or setter functions.
150
- * @param {Function} [accessors.get] - Getter function for the property.
151
- * @param {Function} [accessors.set] - Setter function for the property.
152
- * @param {Object} [accessors.prototype] - Prototype object for getter/setter.
153
- * @param {Object} [options] - Additional options for the accessor property.
154
- * @param {boolean} [options.configurable=true] - Whether property is configurable.
155
- * @param {boolean} [options.enumerable=true] - Whether property is enumerable.
156
- * @param {Object} [options.storage] - Storage object for getter/setter closures.
157
- * @returns {Property} A new Property instance representing the accessor.
158
- * @throws {TypeError} If no name, getter, or setter is provided.
159
- *
160
- * @example
161
- * // Basic usage
162
- * Property.accessor('color', {
163
- * get() { return this._color; },
164
- * set(value) { this._color = value; }
165
- * });
166
- *
167
- * @example
168
- * // Using storage
169
- * Property.accessor('keyword', {
170
- * get(storage) { return () => storage.keyword; },
171
- * set(storage) { return (value) => { storage.keyword = value; } }
172
- * }, { storage: { keyword: 'initial' } });
173
- *
174
- * @example
175
- * // Using named getter function
176
- * Property.accessor('color', function get() { return 'red' })
177
- *
178
- * @example
179
- * // Using prototype
180
- * const ColorAccessors = {
181
- * red: { get() { return this._red; } }
182
- * };
183
- * Property.accessor('red', ColorAccessors.red);
184
- */
185
- static accessor(name, { get, set, prototype }, { configurable, enumerable, storage } = {}) {
186
- if (!get && !set && prototype) {
187
- const constructor = prototype?.constructor;
188
- if (constructor?.name === 'get') {
189
- get = constructor;
190
- }
191
- else if (constructor?.name === 'set') {
192
- set = constructor;
193
- }
194
- }
195
- if (get && storage && get.length == 1) {
196
- get = get(storage);
197
- }
198
- if (set && storage && set.length == 1) {
199
- set = set(storage);
200
- }
201
- if (!name && !get && !set)
202
- throw new TypeError('Cannot create accessor');
203
- configurable ??= true;
204
- enumerable ??= true;
205
- return new Property(name, { get, set, configurable, enumerable });
206
- }
207
- static data(name, value, { writable, configurable, enumerable } = {}) {
208
- if (!name)
209
- throw new TypeError('Cannot create data property without name');
210
- writable ??= true;
211
- configurable ??= true;
212
- enumerable ??= true;
213
- return new Property(name, { value, writable, configurable, enumerable });
214
- }
215
- static from(object, name) {
216
- const descriptor = Object.getOwnPropertyDescriptor(object, name);
217
- return new Property(name, descriptor);
218
- }
219
- static get is() {
220
- return {
221
- object(value) {
222
- return value && ['object', 'function'].some(k => k == typeof value);
223
- },
224
- descriptor(object) {
225
- if (!Property.is.object(object)) {
226
- return false;
227
- }
228
- const present = element => Reflect.has(object, element);
229
- const props = {
230
- base: ['configurable', 'enumerable'],
231
- data: ['writable', 'value'],
232
- accessor: ['get', 'set'],
233
- };
234
- if (Object.getOwnPropertyNames(object).length > 4)
235
- return false;
236
- if (props.data.some(present) && props.accessor.some(present))
237
- return false;
238
- if (props.base.some(present))
239
- return true;
240
- if (props.data.some(present))
241
- return true;
242
- if (props.accessor.some(present))
243
- return true;
244
- return false;
245
- }
246
- };
247
- }
248
- static {
249
- const storage = Object.assign(Object.create(null), {
250
- key: undefined,
251
- meta: {
252
- enumerable: true,
253
- configurable: true,
254
- accessor: {
255
- get: undefined,
256
- set: undefined
257
- },
258
- data: {
259
- value: undefined,
260
- writable: true
261
- },
262
- },
263
- });
264
- basic_accessor(this.prototype, 'key', storage.key, storage);
265
- basic_accessor(this.prototype, 'meta', storage.meta, storage);
266
- }
267
- }
268
- exports.Property = Property;
269
- exports.PropertyExtensions = new extension_1.Extension(Property);
270
- function basic_accessor(prototype, key, initialValue, storage = {}) {
271
- storage[key] = initialValue;
272
- Object.defineProperty(prototype, key, {
273
- get() {
274
- return storage[key];
275
- },
276
- set(value) {
277
- storage[key] = value;
278
- },
279
- enumerable: true,
280
- configurable: true,
281
- });
282
- return Object.getOwnPropertyDescriptor(prototype, key);
283
- }
284
- //# sourceMappingURL=property.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"property.js","sourceRoot":"","sources":["../../../src/classes/property.js"],"names":[],"mappings":";;;AAAA,+CAA2C;AAE3C,MAAa,QAAQ;IACnB,YAAY,GAAG,EAAE,UAAU;QACzB,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;QACvD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YACvD,MAAM,IAAI,SAAS,CAAC,4CAA4C,CAAC,CAAC;QACpE,CAAC;QAED,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QAEf,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YACxC,IAAI,CAAC,UAAU,GAAG;gBAChB,KAAK,EAAE,UAAU;gBACjB,QAAQ,EAAE,IAAI;gBACd,YAAY,EAAE,IAAI;gBAClB,UAAU,EAAE,IAAI;aACjB,CAAA;QACH,CAAC;aACI,CAAC;YACJ,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,KAAK,CAAC,QAAQ,EAAE,KAAK;QACnB,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,EAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,OAAO,QAAQ,CAAC;YACrE,OAAO;QAET,OAAO,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,IAAI,IAAI,CAAC,GAAG,E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ACzD,CAAC"}
@@ -1,238 +0,0 @@
1
- /**
2
- * RefMap class extends the standard Map object to manage a collection of
3
- * WeakRef values mapped to strong keys. It provides additional functionality
4
- * such as objectification of values and various utility methods.
5
- *
6
- * Unlike standard Maps or Objects, RefMap stores weak references to objects,
7
- * allowing them to be garbage-collected if there are no other references to
8
- * them. This behavior is different from Maps and standard Objects, which
9
- * maintain strong references to their elements.
10
- *
11
- * @extends Map
12
- */
13
- export class RefMap extends Map<any, any> {
14
- constructor(...args: any[]);
15
- /**
16
- * Method to control whether the RefMap should objectify its values. When
17
- * objectifying, primitive values (number, string, boolean, bigint) are
18
- * converted to their respective object types, which allows them to be used as
19
- * WeakRef targets.
20
- *
21
- * @param {boolean} setObjectification - Flag to enable or disable
22
- * objectification.
23
- * @returns {RefMap} - The current RefMap instance to allow method chaining.
24
- */
25
- objectifying(setObjectification?: boolean): RefMap;
26
- /**
27
- * Setting this value to true, will cause all set values to the Map to
28
- * be analyzed for validity as a candidate to be wrapped in a `WeakRef`
29
- * object. If true, and if possible, the object will be turned into an
30
- * `Object` variant first.
31
- *
32
- * @param {boolean} value - The new state to set for objectifyValues.
33
- */
34
- set objectifyValues(value: boolean);
35
- /**
36
- * Returns the state indicating whether or not `RefMap` will attempt to
37
- * convert non-valid primitives into targets that are valid input for
38
- * new `WeakRef` object instances. If this value is `false` then no
39
- * *objectification* will occur.
40
- *
41
- * @returns {boolean} The current state of objectifyValues.
42
- */
43
- get objectifyValues(): boolean;
44
- /**
45
- * The function converts a JavaScript Map object into a regular JavaScript
46
- * object, handling invalid keys by converting them to strings.
47
- *
48
- * @returns {object} an object; keys that are not either a `String` or a
49
- * `Symbol` will be converted to a string.
50
- */
51
- asObject(): object;
52
- /**
53
- * The `get` function retrieves a value from a map and returns it, or returns a
54
- * default value if the value is null or undefined. The actual retrieved value
55
- * is a dereferenced `WeakRef`. If the result is `undefined` and this is not the
56
- * expected response, it is likely the value has been garbage collected.
57
- *
58
- * @param {any} key - The key parameter is the key of the value you want to
59
- * retrieve from the data structure.
60
- * @param {any} defaultValue - The `defaultValue` parameter is the value that
61
- * will be returned if the key does not exist in the map or if the value
62
- * associated with the key has been garbage collected (i.e., it no longer
63
- * exists).
64
- * @returns The method is returning the value associated with the given key.
65
- * If the value is not found or if it has been garbage collected (deref()
66
- * returns null), then the defaultValue is returned.
67
- */
68
- get(key: any, defaultValue: any): any;
69
- /**
70
- * Overrides the set method of `Map`. Adds a value to the `RefMap`,
71
- * converting it to a `WeakRef`. Throws an error if the value is not a
72
- * valid `WeakRef` target (e.g., `null`, `undefined`, or a registered
73
- * `symbol`). If {@link objectifyValues} is enabled, an attempt to convert
74
- * primitives to their object variants will be made. These are `numbers`,
75
- * `strings`, `boolean` values and `bigint`s.
76
- *
77
- * @param {*} key - The `key` to be set on the `RefMap`
78
- * @param {*} value - The value to be associated with the `key`
79
- * @throws {TypeError} If the value is not a valid WeakRef target.
80
- */
81
- set(key: any, value: any): void;
82
- /**
83
- * Sets multiple values at a single time. The format is an array of array
84
- * or rather an array of {@link Object.entries} (for example,
85
- * `[[key1,value1], [key2,value2]]`). For each entry pair, if the length
86
- * is not 2, either missing a key or value, it will be skipped.
87
- *
88
- * @param {Iterable} values - An iterable of values to add to the RefMap.
89
- * @throws {TypeError} If the supplied values are falsey or non-iterable.
90
- * @returns {RepMap} returns `this` to allow for chaining
91
- */
92
- setAll(entries: any): RepMap;
93
- /**
94
- * Removes all elements from the RefMap that have been garbage collected
95
- * (i.e., their WeakRef no longer points to an object).
96
- *
97
- * @returns {RefMap} - The current RefMap instance to allow method chaining.
98
- */
99
- clean(): RefMap;
100
- /**
101
- * Executes a provided function once for each value in the RefMap. The callback
102
- * function receives the dereferenced value, the value again (as RefMap doesn't
103
- * use keys), and the RefMap itself. This method provides a way to iterate over
104
- * and apply operations to the values stored in the RefMap, taking into account
105
- * that they are weak references and may have been garbage-collected.
106
- *
107
- * @param {Function} forEachFn - Function to execute for each element. It
108
- * takes three arguments: element, element (again, as RefMap has no key), and
109
- * the RefMap itself.
110
- * @param {*} thisArg - Value to use as `this` when executing `forEachFn`.
111
- */
112
- entries(): Iterator;
113
- /**
114
- * Iterate over the items in the map and pass them to the supplied
115
- * function ala `Map.prototype.forEach`. Note however, there are no
116
- * indexes on Maps and as such, the index parameter of the callback
117
- * will always be the value's key. Subsequently the `array` or third
118
- * parameter will receive the map instance rather than an array.
119
- *
120
- * @param {function} forEachFn the function to use for each element in
121
- * the set.
122
- * @param {object} thisArg the `this` argument to be applied to each
123
- * invocation of the `forEachFn` callback. Note, this value is unable
124
- * to be applied if the `forEachFn` is a big arrow function
125
- */
126
- forEach(forEachFn: Function, thisArg: object): void;
127
- /**
128
- * Returns an iterator for the values in the RefMap. Each value is
129
- * dereferenced from its WeakRef before being returned. This method allows
130
- * iterating over he set's values, similar to how one would iterate over
131
- * values in a standard Map or Array, but with the understanding that the
132
- * values are weakly referenced and may no longer exist (in which case
133
- * they are skipped).
134
- *
135
- * @returns {Iterator} An iterator for the values.
136
- */
137
- values(): Iterator;
138
- /**
139
- * Determines whether an element with the specified value exists in the
140
- * `RefMap`. For non-objectified sets, this method checks if the dereferenced
141
- * values of the map include the specified value.
142
- *
143
- * For objectified sets, strict is set to false which uses loose
144
- * equality to allow for things like `Object(5)` to equal `5`. This is important
145
- * because otherwise primitives could not be weakly referenced. In the grand
146
- * scheme of things, this is only useful if the objectified value is the
147
- * one being referenced.
148
- *
149
- * @param {*} value - The value to check for presence in the RefMap.
150
- * @param {boolean} strict - if `true`, the default, then the supplied value
151
- * is hard compared to the dereferenced value (`===`). If `false`, then a
152
- * loose comparison is used (`==`)
153
- * @returns {boolean} - True if an element with the specified value exists
154
- * in the RefMap, false otherwise.
155
- */
156
- hasValue(value: any, strict?: boolean): boolean;
157
- /**
158
- * The `filter` function filters the entries of a `RefMap` object based on
159
- * a given filter function. The dereferenced entries of the values of the map
160
- * will be passed to the function rather than a `WeakRef` itself.
161
- *
162
- * A new resulting entry set will be generated and a new `RefMap` will be made
163
- * from these entries and returned. Note that this function never returns
164
- * `null`
165
- *
166
- * @param {function} filterFn - The `filterFn` parameter is a function that
167
- * will be used to filter the entries in the `RefMap`. It will be called with
168
- * three arguments: the value of the current entry, the key of the current
169
- * entry, and the `RefMap` itself. The function should return `true`
170
- * @param {object} thisArg - The `thisArg` parameter is an optional argument
171
- * that specifies the value to be used as `this` when executing the
172
- * `filterFn` function. It allows you to explicitly set the context in which
173
- * the `filterFn` function is called. If `thisArg` is not provided, `this
174
- * @returns {array} The `filter` method is returning an array of filtered map
175
- * entries
176
- */
177
- filter(filterFn: Function, thisArg: object): array;
178
- /**
179
- * The `find` function iterates over a map and calls a given function on
180
- * each value, returning the first value for which the function returns
181
- * a truthy value.
182
- *
183
- * The function signature of `findFn` is
184
- * ```
185
- * function findFn(value, key, map)
186
- * ```
187
- * 'value' is passed to findFn up to two times; first with the `WeakRef`
188
- * value, second with the result of {@link WeakRef.deref}. If `findFn`
189
- * returns true for either of these the dereferenced value will be
190
- * returned from the call to {@link RefMap.find}.
191
- * `key` represents the key object that the value is mapped to.
192
- * `map` is simply a reference to `this` map.
193
- *
194
- * @param findFn - `findFn` is a function that will be called for each
195
- * element in the map. It takes three arguments: `ref`, `key`, and `map`;
196
- * where `ref` is the value of the current element in the map, `key` is
197
- * the key of the current element, and `map` is a reference to the instance
198
- * being searched.
199
- * @param thisArg - The `thisArg` parameter is the value to be used as
200
- * the `this` value when executing the `findFn` function. It allows you
201
- * to specify the context in which the `findFn` function should be called.
202
- * @returns the first dereferenced value that satisfies the condition
203
- * specified by the `findFn` function. If no value satisfies the condition,
204
- * it returns `null`.
205
- */
206
- find(findFn: any, thisArg: any): any;
207
- /**
208
- * Creates a new array or `RefMap` with the results of calling a provided
209
- * function on every element in the calling `RefMap`. This method dereferences
210
- * each value, applies the `mapFn`, and collects the results. If `toRefMap` is
211
- * `true`, a new `RefMap` is returned; otherwise, an array. This method
212
- * differs from `Array.map` in handling weak references and the potential to
213
- * return a new `RefMap` instead of an array.
214
- *
215
- * @param {Function} mapFn - Function that produces an element of the new
216
- * array or `RefMap`, taking three arguments.
217
- * @param {*} thisArg - Value to use as this when executing mapFn.
218
- * @param {boolean} toRefMap - Determines if the output should be a new
219
- * `RefMap` (`true`) or an array (`false`).
220
- * @param {boolean} mirrorObjectification - If `true` and `toRefMap` is
221
- * `true`, the new `RefMap` mirrors the objectification setting of the
222
- * original.
223
- * @returns {Array|RefMap} - A new array or `RefMap` with each element being
224
- * the result of the `mapFn`.
225
- */
226
- map(mapFn: Function, thisArg: any, toRefMap: boolean, mirrorObjectification: boolean): any[] | RefMap;
227
- /**
228
- * The function returns an iterator that iterates over the entries of an object,
229
- * dereferencing any weak references.
230
- *
231
- * @returns {Iterator} A new iterator object is being returned.
232
- */
233
- [Symbol.iterator](): Iterator;
234
- #private;
235
- }
236
- export const RefMapExtensions: Extension;
237
- import { Iterator } from './iterable.js';
238
- import { Extension } from '@nejs/extension';