@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.
- package/README.md +78 -4
- package/dist/@nejs/basic-extensions.bundle.2.22.6.js +25 -0
- package/dist/@nejs/basic-extensions.bundle.2.22.6.js.map +7 -0
- package/dist/cjs/classes/index.cjs +11129 -0
- package/dist/cjs/classes/index.cjs.map +7 -0
- package/dist/cjs/index.cjs +15191 -0
- package/dist/cjs/index.cjs.map +7 -0
- package/dist/cjs/utils/index.cjs +3954 -0
- package/dist/cjs/utils/index.cjs.map +7 -0
- package/dist/esm/basic-extensions.mjs +25 -0
- package/dist/esm/basic-extensions.mjs.map +7 -0
- package/package.json +16 -22
- package/repl.bootstrap.js +4 -7
- package/repl.history +26 -26
- package/src/classes/enumeration.js +466 -0
- package/src/classes/index.js +5 -1
- package/src/index.js +3 -1
- package/src/regular.expression.extensions.js +0 -35
- package/src/utils/toolkit.js +699 -516
- package/tests/arrayextensions.test.js +3 -3
- package/tests/index.test.js +3 -1
- package/tests/newClasses/asyncIterable.test.js +3 -3
- package/tests/newClasses/deferred.test.js +3 -3
- package/tests/newClasses/descriptor.test.js +3 -3
- package/tests/newClasses/iterable.test.js +3 -3
- package/tests/newClasses/refmap.test.js +3 -3
- package/tests/newClasses/refset.test.js +3 -3
- package/tests/objectextensions.test.js +3 -3
- package/tests/setextensions.test.js +3 -3
- package/tests/stringextensions.test.js +3 -2
- package/tests/utils/descriptor.utils.test.js +1 -1
- package/tests/utils/toolkit.test.js +429 -163
- package/.esdoc.json +0 -9
- package/.vscode/settings.json +0 -5
- package/bin/build +0 -27
- package/bin/clean +0 -14
- package/bin/esbuild +0 -91
- package/bin/fixup +0 -13
- package/bin/repl.basics.js +0 -584
- package/bin/repl.signature.js +0 -63
- package/bin/version +0 -100
- package/dist/@nejs/basic-extensions.bundle.2.21.5.js +0 -25
- package/dist/@nejs/basic-extensions.bundle.2.21.5.js.map +0 -7
- package/dist/cjs/array.extensions.d.ts +0 -39
- package/dist/cjs/array.extensions.js +0 -477
- package/dist/cjs/array.extensions.js.map +0 -1
- package/dist/cjs/big.int.extension.d.ts +0 -31
- package/dist/cjs/big.int.extension.js +0 -273
- package/dist/cjs/big.int.extension.js.map +0 -1
- package/dist/cjs/classes/asyncIterable.d.ts +0 -126
- package/dist/cjs/classes/asyncIterable.js +0 -209
- package/dist/cjs/classes/asyncIterable.js.map +0 -1
- package/dist/cjs/classes/deferred.d.ts +0 -146
- package/dist/cjs/classes/deferred.js +0 -291
- package/dist/cjs/classes/deferred.js.map +0 -1
- package/dist/cjs/classes/descriptor.d.ts +0 -334
- package/dist/cjs/classes/descriptor.js +0 -537
- package/dist/cjs/classes/descriptor.js.map +0 -1
- package/dist/cjs/classes/enum.d.ts +0 -50
- package/dist/cjs/classes/enum.js +0 -405
- package/dist/cjs/classes/enum.js.map +0 -1
- package/dist/cjs/classes/index.d.ts +0 -15
- package/dist/cjs/classes/index.js +0 -63
- package/dist/cjs/classes/index.js.map +0 -1
- package/dist/cjs/classes/introspector.d.ts +0 -20
- package/dist/cjs/classes/introspector.js +0 -130
- package/dist/cjs/classes/introspector.js.map +0 -1
- package/dist/cjs/classes/iterable.d.ts +0 -169
- package/dist/cjs/classes/iterable.js +0 -268
- package/dist/cjs/classes/iterable.js.map +0 -1
- package/dist/cjs/classes/param.parser.d.ts +0 -221
- package/dist/cjs/classes/param.parser.js +0 -242
- package/dist/cjs/classes/param.parser.js.map +0 -1
- package/dist/cjs/classes/pluggable.proxy.d.ts +0 -153
- package/dist/cjs/classes/pluggable.proxy.js +0 -444
- package/dist/cjs/classes/pluggable.proxy.js.map +0 -1
- package/dist/cjs/classes/property.d.ts +0 -79
- package/dist/cjs/classes/property.js +0 -284
- package/dist/cjs/classes/property.js.map +0 -1
- package/dist/cjs/classes/refmap.d.ts +0 -238
- package/dist/cjs/classes/refmap.js +0 -421
- package/dist/cjs/classes/refmap.js.map +0 -1
- package/dist/cjs/classes/refset.d.ts +0 -186
- package/dist/cjs/classes/refset.js +0 -370
- package/dist/cjs/classes/refset.js.map +0 -1
- package/dist/cjs/classes/symkeys.d.ts +0 -349
- package/dist/cjs/classes/symkeys.js +0 -510
- package/dist/cjs/classes/symkeys.js.map +0 -1
- package/dist/cjs/classes/type.d.ts +0 -56
- package/dist/cjs/classes/type.js +0 -405
- package/dist/cjs/classes/type.js.map +0 -1
- package/dist/cjs/function.extensions.d.ts +0 -12
- package/dist/cjs/function.extensions.js +0 -758
- package/dist/cjs/function.extensions.js.map +0 -1
- package/dist/cjs/global.this.d.ts +0 -2
- package/dist/cjs/global.this.js +0 -300
- package/dist/cjs/global.this.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -31
- package/dist/cjs/index.js +0 -228
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/json.extensions.d.ts +0 -2
- package/dist/cjs/json.extensions.js +0 -109
- package/dist/cjs/json.extensions.js.map +0 -1
- package/dist/cjs/map.extensions.d.ts +0 -3
- package/dist/cjs/map.extensions.js +0 -143
- package/dist/cjs/map.extensions.js.map +0 -1
- package/dist/cjs/math.extension.d.ts +0 -14
- package/dist/cjs/math.extension.js +0 -71
- package/dist/cjs/math.extension.js.map +0 -1
- package/dist/cjs/number.extension.d.ts +0 -44
- package/dist/cjs/number.extension.js +0 -278
- package/dist/cjs/number.extension.js.map +0 -1
- package/dist/cjs/object.extensions.d.ts +0 -33
- package/dist/cjs/object.extensions.js +0 -1091
- package/dist/cjs/object.extensions.js.map +0 -1
- package/dist/cjs/package.json +0 -3
- package/dist/cjs/proxy.extensions.d.ts +0 -2
- package/dist/cjs/proxy.extensions.js +0 -207
- package/dist/cjs/proxy.extensions.js.map +0 -1
- package/dist/cjs/reflect.extensions.d.ts +0 -14
- package/dist/cjs/reflect.extensions.js +0 -316
- package/dist/cjs/reflect.extensions.js.map +0 -1
- package/dist/cjs/regular.expression.extensions.d.ts +0 -2
- package/dist/cjs/regular.expression.extensions.js +0 -423
- package/dist/cjs/regular.expression.extensions.js.map +0 -1
- package/dist/cjs/set.extensions.d.ts +0 -40
- package/dist/cjs/set.extensions.js +0 -355
- package/dist/cjs/set.extensions.js.map +0 -1
- package/dist/cjs/string.extensions.d.ts +0 -23
- package/dist/cjs/string.extensions.js +0 -704
- package/dist/cjs/string.extensions.js.map +0 -1
- package/dist/cjs/symbol.extensions.d.ts +0 -11
- package/dist/cjs/symbol.extensions.js +0 -735
- package/dist/cjs/symbol.extensions.js.map +0 -1
- package/dist/cjs/utils/copy.object.d.ts +0 -408
- package/dist/cjs/utils/copy.object.js +0 -720
- package/dist/cjs/utils/copy.object.js.map +0 -1
- package/dist/cjs/utils/descriptor.utils.d.ts +0 -298
- package/dist/cjs/utils/descriptor.utils.js +0 -889
- package/dist/cjs/utils/descriptor.utils.js.map +0 -1
- package/dist/cjs/utils/index.d.ts +0 -75
- package/dist/cjs/utils/index.js +0 -61
- package/dist/cjs/utils/index.js.map +0 -1
- package/dist/cjs/utils/stdout.d.ts +0 -742
- package/dist/cjs/utils/stdout.js +0 -1042
- package/dist/cjs/utils/stdout.js.map +0 -1
- package/dist/cjs/utils/toolkit.d.ts +0 -1898
- package/dist/cjs/utils/toolkit.js +0 -1378
- package/dist/cjs/utils/toolkit.js.map +0 -1
- package/dist/cjs/weakref.extensions.d.ts +0 -2
- package/dist/cjs/weakref.extensions.js +0 -19
- package/dist/cjs/weakref.extensions.js.map +0 -1
- package/dist/mjs/array.extensions.d.ts +0 -39
- package/dist/mjs/array.extensions.js +0 -474
- package/dist/mjs/array.extensions.js.map +0 -1
- package/dist/mjs/big.int.extension.d.ts +0 -31
- package/dist/mjs/big.int.extension.js +0 -270
- package/dist/mjs/big.int.extension.js.map +0 -1
- package/dist/mjs/classes/asyncIterable.d.ts +0 -126
- package/dist/mjs/classes/asyncIterable.js +0 -204
- package/dist/mjs/classes/asyncIterable.js.map +0 -1
- package/dist/mjs/classes/deferred.d.ts +0 -146
- package/dist/mjs/classes/deferred.js +0 -287
- package/dist/mjs/classes/deferred.js.map +0 -1
- package/dist/mjs/classes/descriptor.d.ts +0 -334
- package/dist/mjs/classes/descriptor.js +0 -533
- package/dist/mjs/classes/descriptor.js.map +0 -1
- package/dist/mjs/classes/enum.d.ts +0 -50
- package/dist/mjs/classes/enum.js +0 -400
- package/dist/mjs/classes/enum.js.map +0 -1
- package/dist/mjs/classes/index.d.ts +0 -15
- package/dist/mjs/classes/index.js +0 -46
- package/dist/mjs/classes/index.js.map +0 -1
- package/dist/mjs/classes/introspector.d.ts +0 -20
- package/dist/mjs/classes/introspector.js +0 -126
- package/dist/mjs/classes/introspector.js.map +0 -1
- package/dist/mjs/classes/iterable.d.ts +0 -169
- package/dist/mjs/classes/iterable.js +0 -263
- package/dist/mjs/classes/iterable.js.map +0 -1
- package/dist/mjs/classes/param.parser.d.ts +0 -221
- package/dist/mjs/classes/param.parser.js +0 -238
- package/dist/mjs/classes/param.parser.js.map +0 -1
- package/dist/mjs/classes/pluggable.proxy.d.ts +0 -153
- package/dist/mjs/classes/pluggable.proxy.js +0 -438
- package/dist/mjs/classes/pluggable.proxy.js.map +0 -1
- package/dist/mjs/classes/property.d.ts +0 -79
- package/dist/mjs/classes/property.js +0 -280
- package/dist/mjs/classes/property.js.map +0 -1
- package/dist/mjs/classes/refmap.d.ts +0 -238
- package/dist/mjs/classes/refmap.js +0 -417
- package/dist/mjs/classes/refmap.js.map +0 -1
- package/dist/mjs/classes/refset.d.ts +0 -186
- package/dist/mjs/classes/refset.js +0 -366
- package/dist/mjs/classes/refset.js.map +0 -1
- package/dist/mjs/classes/symkeys.d.ts +0 -349
- package/dist/mjs/classes/symkeys.js +0 -506
- package/dist/mjs/classes/symkeys.js.map +0 -1
- package/dist/mjs/classes/type.d.ts +0 -56
- package/dist/mjs/classes/type.js +0 -401
- package/dist/mjs/classes/type.js.map +0 -1
- package/dist/mjs/function.extensions.d.ts +0 -12
- package/dist/mjs/function.extensions.js +0 -755
- package/dist/mjs/function.extensions.js.map +0 -1
- package/dist/mjs/global.this.d.ts +0 -2
- package/dist/mjs/global.this.js +0 -264
- package/dist/mjs/global.this.js.map +0 -1
- package/dist/mjs/index.d.ts +0 -31
- package/dist/mjs/index.js +0 -206
- package/dist/mjs/index.js.map +0 -1
- package/dist/mjs/json.extensions.d.ts +0 -2
- package/dist/mjs/json.extensions.js +0 -106
- package/dist/mjs/json.extensions.js.map +0 -1
- package/dist/mjs/map.extensions.d.ts +0 -3
- package/dist/mjs/map.extensions.js +0 -140
- package/dist/mjs/map.extensions.js.map +0 -1
- package/dist/mjs/math.extension.d.ts +0 -14
- package/dist/mjs/math.extension.js +0 -68
- package/dist/mjs/math.extension.js.map +0 -1
- package/dist/mjs/number.extension.d.ts +0 -44
- package/dist/mjs/number.extension.js +0 -275
- package/dist/mjs/number.extension.js.map +0 -1
- package/dist/mjs/object.extensions.d.ts +0 -33
- package/dist/mjs/object.extensions.js +0 -1088
- package/dist/mjs/object.extensions.js.map +0 -1
- package/dist/mjs/package.json +0 -3
- package/dist/mjs/proxy.extensions.d.ts +0 -2
- package/dist/mjs/proxy.extensions.js +0 -204
- package/dist/mjs/proxy.extensions.js.map +0 -1
- package/dist/mjs/reflect.extensions.d.ts +0 -14
- package/dist/mjs/reflect.extensions.js +0 -313
- package/dist/mjs/reflect.extensions.js.map +0 -1
- package/dist/mjs/regular.expression.extensions.d.ts +0 -2
- package/dist/mjs/regular.expression.extensions.js +0 -420
- package/dist/mjs/regular.expression.extensions.js.map +0 -1
- package/dist/mjs/set.extensions.d.ts +0 -40
- package/dist/mjs/set.extensions.js +0 -352
- package/dist/mjs/set.extensions.js.map +0 -1
- package/dist/mjs/string.extensions.d.ts +0 -23
- package/dist/mjs/string.extensions.js +0 -701
- package/dist/mjs/string.extensions.js.map +0 -1
- package/dist/mjs/symbol.extensions.d.ts +0 -11
- package/dist/mjs/symbol.extensions.js +0 -732
- package/dist/mjs/symbol.extensions.js.map +0 -1
- package/dist/mjs/utils/copy.object.d.ts +0 -408
- package/dist/mjs/utils/copy.object.js +0 -702
- package/dist/mjs/utils/copy.object.js.map +0 -1
- package/dist/mjs/utils/descriptor.utils.d.ts +0 -298
- package/dist/mjs/utils/descriptor.utils.js +0 -875
- package/dist/mjs/utils/descriptor.utils.js.map +0 -1
- package/dist/mjs/utils/index.d.ts +0 -75
- package/dist/mjs/utils/index.js +0 -45
- package/dist/mjs/utils/index.js.map +0 -1
- package/dist/mjs/utils/stdout.d.ts +0 -742
- package/dist/mjs/utils/stdout.js +0 -1037
- package/dist/mjs/utils/stdout.js.map +0 -1
- package/dist/mjs/utils/toolkit.d.ts +0 -1898
- package/dist/mjs/utils/toolkit.js +0 -1373
- package/dist/mjs/utils/toolkit.js.map +0 -1
- package/dist/mjs/weakref.extensions.d.ts +0 -2
- package/dist/mjs/weakref.extensions.js +0 -16
- package/dist/mjs/weakref.extensions.js.map +0 -1
- package/jsdoc-config.json +0 -31
- package/tsconfig.base.json +0 -28
- package/tsconfig.cjs.json +0 -8
- package/tsconfig.esm.json +0 -8
- package/vitest.config.js +0 -7
package/dist/mjs/classes/enum.js
DELETED
|
@@ -1,400 +0,0 @@
|
|
|
1
|
-
import { Extension } from '@nejs/extension';
|
|
2
|
-
import { accessor, as, data, isDescriptor, redescribe } from '../utils/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* Creates an enumeration object with specified values and properties.
|
|
5
|
-
*
|
|
6
|
-
* @param {string} name - The name of the enumeration.
|
|
7
|
-
* @param {Array|any} values - The values to be included in the enumeration.
|
|
8
|
-
* If not an array, it will be converted into a single-element array.
|
|
9
|
-
* @param {Object|Map} [properties] - Additional properties to be added to
|
|
10
|
-
* the enumeration. Can be an object or a Map.
|
|
11
|
-
* @returns {Object} The constructed enumeration object.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* const colors = Enum('Colors', ['red', 'green', 'blue'])
|
|
15
|
-
* console.log(colors.red) // EnumValue object for 'red'
|
|
16
|
-
*
|
|
17
|
-
* @description
|
|
18
|
-
* The `Enum` function constructs an enumeration object with a given name,
|
|
19
|
-
* values, and optional properties. It supports primitive types, arrays,
|
|
20
|
-
* and objects as values. The function uses a combination of `Object.create`
|
|
21
|
-
* and `Proxy` to define and manage the properties of the enumeration.
|
|
22
|
-
*
|
|
23
|
-
* The enumeration object includes:
|
|
24
|
-
* - A `toString` method that returns the enumeration name.
|
|
25
|
-
* - A `Symbol.toStringTag` for identifying the object as an 'Enum'.
|
|
26
|
-
* - A `Symbol.for('Enum.name')` for storing the enumeration name.
|
|
27
|
-
*
|
|
28
|
-
* For array values, it creates a maker function that returns an
|
|
29
|
-
* `EnumValue` object with properties like `real`, `value`, `type`,
|
|
30
|
-
* `name`, and `compare`.
|
|
31
|
-
*/
|
|
32
|
-
export function Enum(name, values, properties) {
|
|
33
|
-
const enumeration = makeBaseEnum(name);
|
|
34
|
-
if (!Array.isArray(values)) {
|
|
35
|
-
values = [values];
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* A new base `EnumValue` type object. It contains enough custom symbols and
|
|
39
|
-
* identifiers to allow things like a `compare(to)` function to also work on
|
|
40
|
-
* each of the elements. Thing of this as the shared base functionality for
|
|
41
|
-
* each `Enum` element.
|
|
42
|
-
*
|
|
43
|
-
* @param {any} enumValue the value around which an `EnumValue` type is
|
|
44
|
-
* created.
|
|
45
|
-
* @returns an object defined by {@link Symbol.toStringTag} as well as some
|
|
46
|
-
* custom {@link Symbol} keys. The `node.js` custom inspect symbol is also
|
|
47
|
-
* defined for better REPL representation.
|
|
48
|
-
*/
|
|
49
|
-
const makeEnumValue = (property, enumValue) => ({
|
|
50
|
-
toString: data(() => enumValue, false, true, false),
|
|
51
|
-
[Symbol.for('Enum.name')]: data(name, false, true, false),
|
|
52
|
-
[Symbol.for('Enum.is')]: data(true, false, false, false),
|
|
53
|
-
[Symbol.for('nodejs.util.inspect.custom')]: data(function (depth, options, inspect) {
|
|
54
|
-
const _options = { ...(options || {}), colors: true };
|
|
55
|
-
const _skip = this.value === Symbol.for('Enum.NonAssociatedValue');
|
|
56
|
-
const _value = _skip
|
|
57
|
-
? ''
|
|
58
|
-
: ` { value: ${inspect(this.value, _options)} }`;
|
|
59
|
-
return `${property}${_value}`;
|
|
60
|
-
}, false, true, false),
|
|
61
|
-
[Symbol.toStringTag]: accessor('EnumValue', false, true, false),
|
|
62
|
-
[Symbol.for('compare')]: data(function compareValue(to) {
|
|
63
|
-
const toObj = (to && typeof to === 'object') ? to : { real: to };
|
|
64
|
-
const kName = Symbol.for('Enum.name');
|
|
65
|
-
const hasAndIs = o => (Reflect.has(o, Symbol.for('Enum.is')) && o[Symbol.for('Enum.is')]);
|
|
66
|
-
const isLEnum = hasAndIs(this);
|
|
67
|
-
const isREnum = hasAndIs(toObj);
|
|
68
|
-
if (!isLEnum || !isREnum)
|
|
69
|
-
return false;
|
|
70
|
-
const { real: lReal, value: lValue, name: lName, type: lType } = this;
|
|
71
|
-
const { real: rReal, value: rValue, name: rName, type: rType } = toObj;
|
|
72
|
-
return (lName === rName && lType === rType &&
|
|
73
|
-
lReal === rReal && lValue === rValue);
|
|
74
|
-
}, false, true, false),
|
|
75
|
-
[Symbol.toPrimitive]: data(function EnumValueToPrimitive(hint) {
|
|
76
|
-
const original = this.real;
|
|
77
|
-
const type = typeof original;
|
|
78
|
-
switch (hint) {
|
|
79
|
-
case 'string':
|
|
80
|
-
if ('string' === type)
|
|
81
|
-
return original;
|
|
82
|
-
else
|
|
83
|
-
return String(original);
|
|
84
|
-
case 'number':
|
|
85
|
-
if ('number' === type)
|
|
86
|
-
return original;
|
|
87
|
-
else
|
|
88
|
-
return NaN;
|
|
89
|
-
case 'bigint':
|
|
90
|
-
if ('bigint' === type)
|
|
91
|
-
return original;
|
|
92
|
-
else
|
|
93
|
-
return NaN;
|
|
94
|
-
default:
|
|
95
|
-
return original;
|
|
96
|
-
}
|
|
97
|
-
}, false, true, false),
|
|
98
|
-
});
|
|
99
|
-
/**
|
|
100
|
-
* Given a value, determine how to represent it as both a key and a response
|
|
101
|
-
* or underlying original value. The method for this is dependent on the type
|
|
102
|
-
* of the value itself.
|
|
103
|
-
*
|
|
104
|
-
* @param {any} value the value to be converted
|
|
105
|
-
* @returns {[string, any]} an array where the first value is the transformed
|
|
106
|
-
* value as a key and the second element is the originally supplied value.
|
|
107
|
-
*/
|
|
108
|
-
const fromPrimitive = (value) => {
|
|
109
|
-
let valueType = typeof value;
|
|
110
|
-
switch (valueType) {
|
|
111
|
-
case 'string':
|
|
112
|
-
case 'number':
|
|
113
|
-
case 'bigint':
|
|
114
|
-
case 'boolean':
|
|
115
|
-
default:
|
|
116
|
-
return [String(value), value];
|
|
117
|
-
case 'symbol':
|
|
118
|
-
return [value.description, value];
|
|
119
|
-
case 'function':
|
|
120
|
-
return [value.name, value];
|
|
121
|
-
case 'object': {
|
|
122
|
-
const str = asString(value);
|
|
123
|
-
return [str, str];
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
// Determine the keys that the final proxy should be aware of when computing
|
|
128
|
-
// the enumeration value itself.
|
|
129
|
-
const kValueProps = ['real', 'value', 'type', 'name', 'compare', 'isEnum'];
|
|
130
|
-
const kCustomPropKeys = [];
|
|
131
|
-
// Capture and calculate any custom properties defined for each element
|
|
132
|
-
// of the enumeration. Each custom property is appended to `kCustomPropKeys`
|
|
133
|
-
const props = {};
|
|
134
|
-
if (properties) {
|
|
135
|
-
if (Array.isArray(properties)) {
|
|
136
|
-
const entries = properties.filter(e => Array.isArray(e) && e.length === 2);
|
|
137
|
-
if (entries.length)
|
|
138
|
-
properties = new Map(entries);
|
|
139
|
-
else
|
|
140
|
-
properties = new Map();
|
|
141
|
-
}
|
|
142
|
-
else if (typeof properties === 'object') {
|
|
143
|
-
properties = new Map(Object.entries(Object.getOwnPropertyDescriptors(properties)));
|
|
144
|
-
}
|
|
145
|
-
if (properties instanceof Map) {
|
|
146
|
-
const applyPropertiesOf = (object, baseDescriptor) => {
|
|
147
|
-
const property = {
|
|
148
|
-
configurable: baseDescriptor?.configurable ?? true,
|
|
149
|
-
enumerable: baseDescriptor?.enumerable ?? true,
|
|
150
|
-
writable: baseDescriptor?.writable ?? true,
|
|
151
|
-
};
|
|
152
|
-
const descriptors = Object.getOwnPropertyDescriptors(object);
|
|
153
|
-
for (const [key, subvalue] of Object.entries(descriptors)) {
|
|
154
|
-
const stats = isDescriptor(subvalue, true);
|
|
155
|
-
const baseStats = isDescriptor(baseDescriptor, true);
|
|
156
|
-
if (stats.isAccessor && baseStats.isValid) {
|
|
157
|
-
props[key] = { ...subvalue, ...accessor.keys.from(baseDescriptor) };
|
|
158
|
-
}
|
|
159
|
-
else if (stats.isData && baseStats.isValid) {
|
|
160
|
-
props[key] = { ...subvalue, ...data.keys.from(baseDescriptor) };
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
let stats = {};
|
|
165
|
-
for (const [property, value] of properties.entries()) {
|
|
166
|
-
kCustomPropKeys.push(property);
|
|
167
|
-
if (isDescriptor(property)) {
|
|
168
|
-
if (typeof value === 'object') {
|
|
169
|
-
applyPropertiesOf(value, property);
|
|
170
|
-
continue;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
props[property] = value;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
for (const value of values) {
|
|
178
|
-
const valueType = Array.isArray(value) ? 'array' : typeof value;
|
|
179
|
-
let property = undefined;
|
|
180
|
-
let response = undefined;
|
|
181
|
-
let wasArray = false;
|
|
182
|
-
let elements = value;
|
|
183
|
-
switch (valueType) {
|
|
184
|
-
case 'array':
|
|
185
|
-
if (value.length >= 1) {
|
|
186
|
-
wasArray = true;
|
|
187
|
-
([property, response] = fromPrimitive(elements[0]));
|
|
188
|
-
}
|
|
189
|
-
default:
|
|
190
|
-
([property, response] = fromPrimitive(value));
|
|
191
|
-
}
|
|
192
|
-
const maker = {
|
|
193
|
-
[property](initialValue) {
|
|
194
|
-
const storage = new Map();
|
|
195
|
-
const key = property;
|
|
196
|
-
const realValue = accessor(response, false, { storage, key });
|
|
197
|
-
let _opts, associatedValue;
|
|
198
|
-
if (wasArray) {
|
|
199
|
-
_opts = { storage, key: key + '.associated' };
|
|
200
|
-
associatedValue = elements.length === 1
|
|
201
|
-
? accessor(initialValue, true, _opts)
|
|
202
|
-
: accessor(elements?.[1], elements?.[2], _opts);
|
|
203
|
-
}
|
|
204
|
-
else
|
|
205
|
-
associatedValue = accessor(Symbol.for('Enum.NonAssociatedValue'), false, false, false);
|
|
206
|
-
const _prop = Object(asString(response));
|
|
207
|
-
const valueProps = [...kValueProps, ...kCustomPropKeys];
|
|
208
|
-
const enumResponse = Object.create(_prop, {
|
|
209
|
-
...makeEnumValue(property, response),
|
|
210
|
-
...props,
|
|
211
|
-
});
|
|
212
|
-
const proxy = new Proxy(_prop, {
|
|
213
|
-
get(target, _property, receiver) {
|
|
214
|
-
if (_property === 'real')
|
|
215
|
-
return realValue.get();
|
|
216
|
-
if (_property === 'value')
|
|
217
|
-
return associatedValue.get();
|
|
218
|
-
if (_property === 'type')
|
|
219
|
-
return name;
|
|
220
|
-
if (_property === 'name')
|
|
221
|
-
return property;
|
|
222
|
-
if (_property === 'compare')
|
|
223
|
-
return enumResponse[Symbol.for('compare')];
|
|
224
|
-
if (_property === 'isEnum')
|
|
225
|
-
return true;
|
|
226
|
-
if (!valueProps.includes(_property))
|
|
227
|
-
return undefined;
|
|
228
|
-
},
|
|
229
|
-
has(target, _property) {
|
|
230
|
-
return valueProps.includes(_property);
|
|
231
|
-
},
|
|
232
|
-
ownKeys(target) {
|
|
233
|
-
return valueProps;
|
|
234
|
-
},
|
|
235
|
-
set(target, _property, value, receiver) {
|
|
236
|
-
if (_property === 'value' && wasArray)
|
|
237
|
-
return associatedValue.set(value);
|
|
238
|
-
return false;
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
Object.setPrototypeOf(proxy, Object.getPrototypeOf(_prop));
|
|
242
|
-
Object.setPrototypeOf(enumResponse, proxy);
|
|
243
|
-
return enumResponse;
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
enumeration[Symbol.for('Enum.valueKeys')].push(property);
|
|
247
|
-
const dataValue = wasArray ? maker[property] : maker[property]();
|
|
248
|
-
const baseProps = {
|
|
249
|
-
writable: false,
|
|
250
|
-
configurable: false,
|
|
251
|
-
enumerable: true,
|
|
252
|
-
};
|
|
253
|
-
Object.defineProperty(enumeration, property, data(dataValue, baseProps));
|
|
254
|
-
}
|
|
255
|
-
return enumeration;
|
|
256
|
-
}
|
|
257
|
-
export const EnumExtension = new Extension(Enum);
|
|
258
|
-
/**
|
|
259
|
-
* Converts a given value to a string representation with additional
|
|
260
|
-
* options for description and string tag.
|
|
261
|
-
*
|
|
262
|
-
* @param {any} value - The value to be converted to a string. This can
|
|
263
|
-
* be of any type, including objects, arrays, numbers, etc.
|
|
264
|
-
* @returns {string} A string representation of the input value, enhanced
|
|
265
|
-
* with a description and string tag if applicable.
|
|
266
|
-
*
|
|
267
|
-
* @example
|
|
268
|
-
* // Convert a number to a string with additional options
|
|
269
|
-
* const result = asString(123)
|
|
270
|
-
* console.log(result) // Outputs: "123" with description and string tag
|
|
271
|
-
*
|
|
272
|
-
* @example
|
|
273
|
-
* // Convert an object to a string with additional options
|
|
274
|
-
* const obj = { key: 'value' }
|
|
275
|
-
* const result = asString(obj)
|
|
276
|
-
* console.log(result) // Outputs: "[object Object]" with description and
|
|
277
|
-
* // string tag
|
|
278
|
-
*/
|
|
279
|
-
function asString(value) {
|
|
280
|
-
return as.string(value, { description: true, stringTag: true });
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Creates a base enumeration object with predefined properties and
|
|
284
|
-
* symbols. This function is used to initialize an enumeration with
|
|
285
|
-
* specific characteristics, such as a name and various symbolic
|
|
286
|
-
* properties that enhance its functionality and identification.
|
|
287
|
-
*
|
|
288
|
-
* @param {string} name - The name of the enumeration. This name is
|
|
289
|
-
* used to identify the enumeration and is stored as a symbol on
|
|
290
|
-
* the object.
|
|
291
|
-
* @returns {Object} A new enumeration object with specific properties
|
|
292
|
-
* and symbols set for enhanced functionality and identification.
|
|
293
|
-
*
|
|
294
|
-
* @example
|
|
295
|
-
* // Create a base enum with the name 'Color'
|
|
296
|
-
* const colorEnum = makeBaseEnum('Color')
|
|
297
|
-
* console.log(colorEnum[Symbol.for('Enum.name')]) // Outputs: 'Color'
|
|
298
|
-
*/
|
|
299
|
-
export function makeBaseEnum(name) {
|
|
300
|
-
return Object.create({}, {
|
|
301
|
-
/**
|
|
302
|
-
* Defines the `toStringTag` symbol on each enumeration to allow for
|
|
303
|
-
* type identification and to be consistent in naming conventions.
|
|
304
|
-
*
|
|
305
|
-
* @type {string}
|
|
306
|
-
*/
|
|
307
|
-
[Symbol.toStringTag]: accessor('Enum', false, true, false),
|
|
308
|
-
/**
|
|
309
|
-
* In addition to the `toStringTag` symbol which defines this enumeration
|
|
310
|
-
* as an Enum type, the name of the enum is also codified in as a symbol
|
|
311
|
-
* on the object. It can be found using `Symbol.for('Enum.name')`.
|
|
312
|
-
*
|
|
313
|
-
* @type {string|symbol|number}
|
|
314
|
-
*/
|
|
315
|
-
[Symbol.for('Enum.name')]: accessor(name, false, true, false),
|
|
316
|
-
/**
|
|
317
|
-
* Knowing which keys of the enum are part of the keys themselves is also
|
|
318
|
-
* crucial for enumerations. These can always be found on each Enum type
|
|
319
|
-
* as `Symbol.for('Enum.valueKeys')` as an array, but can also be found
|
|
320
|
-
* as the `.keys` property if there is no enum value of that name.
|
|
321
|
-
*/
|
|
322
|
-
[Symbol.for('Enum.valueKeys')]: data([], false, true, false),
|
|
323
|
-
/**
|
|
324
|
-
* For users of the node.js REPL, this symbol represents enum types in a
|
|
325
|
-
* more readily readable format. See the docs for node's `util.inspect()`
|
|
326
|
-
* function for more details.
|
|
327
|
-
*
|
|
328
|
-
* @type {(number, object, Function) => string}
|
|
329
|
-
*/
|
|
330
|
-
[Symbol.for('nodejs.util.inspect.custom')]: data(function (depth, options, inspect) {
|
|
331
|
-
const valueKeys = this[Symbol.for('Enum.valueKeys')] ?? [];
|
|
332
|
-
let valueText = valueKeys
|
|
333
|
-
.map(key => `\x1b[1;2m${key}\x1b[22m`)
|
|
334
|
-
.join(', ');
|
|
335
|
-
if (valueText.length)
|
|
336
|
-
valueText = ` { ${valueText} }`;
|
|
337
|
-
return `\x1b[1menum \x1b[22m${name}${valueText}`;
|
|
338
|
-
}, false, true, false),
|
|
339
|
-
/**
|
|
340
|
-
* This function checks the supplied `possibleEnumValue` to see if it
|
|
341
|
-
* is an enum value type from this enum.
|
|
342
|
-
*
|
|
343
|
-
* @param {any} possibleEnumValue the value to evaluate
|
|
344
|
-
* @returns {boolean} returns `true` if the value is an enum value type
|
|
345
|
-
* from this `Enum`, irrespective of any associated value. Returns `false`
|
|
346
|
-
* otherwise.
|
|
347
|
-
*/
|
|
348
|
-
isValueOf: data(function isValueOf(possibleEnumValue) {
|
|
349
|
-
if (!possibleEnumValue || typeof possibleEnumValue !== 'object')
|
|
350
|
-
return false;
|
|
351
|
-
const enumValueType = possibleEnumValue?.type;
|
|
352
|
-
const enumValueName = possibleEnumValue?.name;
|
|
353
|
-
const thisEnumName = this[Symbol.for('Enum.name')];
|
|
354
|
-
const thisEnumKeys = this[Symbol.for('Enum.valueKeys')];
|
|
355
|
-
return (enumValueType === thisEnumName &&
|
|
356
|
-
thisEnumKeys.includes(enumValueName));
|
|
357
|
-
}, false, true, false),
|
|
358
|
-
/**
|
|
359
|
-
* A simple overload of the `toString()` method to represent the enum
|
|
360
|
-
* more identifiably when called. The result will be the word enum with
|
|
361
|
-
* the name of the enum in parenthesis. So a Gender enum might be seen
|
|
362
|
-
* as `Enum(Gender)` as a result to calling this function.
|
|
363
|
-
*
|
|
364
|
-
* @returns {string} a {@link String} representation of this object.
|
|
365
|
-
*/
|
|
366
|
-
toString: data(function toString() {
|
|
367
|
-
return `Enum(${name})`;
|
|
368
|
-
}, false, true, false)
|
|
369
|
-
});
|
|
370
|
-
const applySyntacticSugar = () => {
|
|
371
|
-
createSymlinks(Symbol.for('Enum.valueKeys'), 'keys');
|
|
372
|
-
createSymlinks(Symbol.for('Enum.name'), 'name');
|
|
373
|
-
};
|
|
374
|
-
return [base, applySyntacticSugar];
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* Creates a symlink for a property from an existing key to a new key on
|
|
378
|
-
* the specified object. This function checks if the new key already
|
|
379
|
-
* exists on the object and, if not, it creates a new property with the
|
|
380
|
-
* same descriptor as the old key.
|
|
381
|
-
*
|
|
382
|
-
* Since this method creates the new link through the use of property
|
|
383
|
-
* descriptors, computed getters and setters also are mapped properly.
|
|
384
|
-
*
|
|
385
|
-
* @param {Object} on - The target object on which the symlink is to be
|
|
386
|
-
* created.
|
|
387
|
-
* @param {string|symbol} oldKey - The existing key whose property
|
|
388
|
-
* descriptor will be used for the new key.
|
|
389
|
-
* @param {string|symbol} newKey - The new key under which the property
|
|
390
|
-
* will be accessible.
|
|
391
|
-
*
|
|
392
|
-
* @example
|
|
393
|
-
* const obj = { a: 1 }
|
|
394
|
-
* createSymlink(obj, 'a', 'b')
|
|
395
|
-
* console.log(obj.b) // Outputs: 1
|
|
396
|
-
*/
|
|
397
|
-
function createSymlinks(on, oldKey, ...newKeys) {
|
|
398
|
-
redescribe(on, oldKey, {}, { alsoAs: newKeys });
|
|
399
|
-
}
|
|
400
|
-
//# sourceMappingURL=enum.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../src/classes/enum.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU;IAC3C,MAA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,IAAI,CAAA;YAE7C,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAA;YAClD,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAA;YAEvD,OAAO,CACL,aAAa,KAAK,YAAY;gBAC9B,YAAY,CAAC,QAAQ,CAAC,aAAa,CAAC,CACrC,CAAA;QACH,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC;QAEtB;;;;;;;WAOG;QACH,QAAQ,EAAE,IAAI,CAAC,SAAS,QAAQ;YAC9B,OAAO,QAAQ,IAAI,GAAG,CAAA;QACxB,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC;KACvB,CAAC,CAAA;IAEF,MAAM,mBAAmB,GAAG,GAAG,EAAE;QAC/B,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC,CAAA;QACpD,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,CAAA;IACjD,CAAC,CAAA;IAED,OAAO,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAA;AACpC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAS,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,OAAO;IAC5C,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAA;AACjD,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export * from "./asyncIterable.js";
|
|
2
|
-
export * from "./deferred.js";
|
|
3
|
-
export * from "./descriptor.js";
|
|
4
|
-
export * from "./enum.js";
|
|
5
|
-
export * from "./introspector.js";
|
|
6
|
-
export * from "./iterable.js";
|
|
7
|
-
export * from "./param.parser.js";
|
|
8
|
-
export * from "./pluggable.proxy.js";
|
|
9
|
-
export * from "./property.js";
|
|
10
|
-
export * from "./refmap.js";
|
|
11
|
-
export * from "./refset.js";
|
|
12
|
-
export * from "./symkeys.js";
|
|
13
|
-
export * from "./type.js";
|
|
14
|
-
export const NewClassesExtension: Patch;
|
|
15
|
-
import { Patch } from '@nejs/extension';
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Patch } from '@nejs/extension';
|
|
2
|
-
import { AsyncIterable, AsyncIterator } from './asyncIterable.js';
|
|
3
|
-
export * from './asyncIterable.js';
|
|
4
|
-
import { Deferred } from './deferred.js';
|
|
5
|
-
export * from './deferred.js';
|
|
6
|
-
import { Descriptor } from './descriptor.js';
|
|
7
|
-
export * from './descriptor.js';
|
|
8
|
-
import { Enum } from './enum.js';
|
|
9
|
-
export * from './enum.js';
|
|
10
|
-
import { Introspector } from './introspector.js';
|
|
11
|
-
export * from './introspector.js';
|
|
12
|
-
import { Iterable, Iterator } from './iterable.js';
|
|
13
|
-
export * from './iterable.js';
|
|
14
|
-
import { ParamParser } from './param.parser.js';
|
|
15
|
-
export * from './param.parser.js';
|
|
16
|
-
import { PluggableProxy, ProxyHandler } from './pluggable.proxy.js';
|
|
17
|
-
export * from './pluggable.proxy.js';
|
|
18
|
-
import { Property, PropertyExtensions } from './property.js';
|
|
19
|
-
export * from './property.js';
|
|
20
|
-
import { RefMap } from './refmap.js';
|
|
21
|
-
export * from './refmap.js';
|
|
22
|
-
import { RefSet } from './refset.js';
|
|
23
|
-
export * from './refset.js';
|
|
24
|
-
import { Symkeys } from './symkeys.js';
|
|
25
|
-
export * from './symkeys.js';
|
|
26
|
-
import { Type } from './type.js';
|
|
27
|
-
export * from './type.js';
|
|
28
|
-
export const NewClassesExtension = new Patch(globalThis, {
|
|
29
|
-
AsyncIterable,
|
|
30
|
-
AsyncIterator,
|
|
31
|
-
Deferred,
|
|
32
|
-
Descriptor,
|
|
33
|
-
Enum,
|
|
34
|
-
Introspector,
|
|
35
|
-
Iterable,
|
|
36
|
-
Iterator,
|
|
37
|
-
ParamParser,
|
|
38
|
-
PluggableProxy,
|
|
39
|
-
ProxyHandler,
|
|
40
|
-
Property,
|
|
41
|
-
RefMap,
|
|
42
|
-
RefSet,
|
|
43
|
-
Symkeys,
|
|
44
|
-
Type,
|
|
45
|
-
});
|
|
46
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/classes/index.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAEvC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACjE,cAAc,oBAAoB,CAAA;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,cAAc,eAAe,CAAA;AAE7B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,cAAc,iBAAiB,CAAA;AAE/B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,cAAc,WAAW,CAAA;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,cAAc,mBAAmB,CAAA;AAEjC,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,cAAc,eAAe,CAAA;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,cAAc,mBAAmB,CAAA;AAEjC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnE,cAAc,sBAAsB,CAAA;AAEpC,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAC5D,cAAc,eAAe,CAAA;AAE7B,OAAO,EAAE,MAAM,EAAG,MAAM,aAAa,CAAA;AACrC,cAAc,aAAa,CAAA;AAE3B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,cAAc,aAAa,CAAA;AAE3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,cAAc,cAAc,CAAA;AAE5B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,cAAc,WAAW,CAAA;AAEzB,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,KAAK,CAAC,UAAU,EAAE;IACvD,aAAa;IACb,aAAa;IACb,QAAQ;IACR,UAAU;IACV,IAAI;IACJ,YAAY;IACZ,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,cAAc;IACd,YAAY;IACZ,QAAQ;IACR,MAAM;IACN,MAAM;IACN,OAAO;IACP,IAAI;CACL,CAAC,CAAA"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export class Introspector {
|
|
2
|
-
static addExpansion(array: any): any;
|
|
3
|
-
static accessors(owner?: typeof globalThis, keys?: any[]): Map<any, any>;
|
|
4
|
-
static classes(owner?: typeof globalThis): any;
|
|
5
|
-
static functions(owner?: typeof globalThis): any;
|
|
6
|
-
static objects(owner?: typeof globalThis): any;
|
|
7
|
-
static properties(owner?: typeof globalThis): any;
|
|
8
|
-
static symbols(owner?: typeof globalThis): any;
|
|
9
|
-
static metadata(owner: any, key: any): {
|
|
10
|
-
owner: any;
|
|
11
|
-
key: any;
|
|
12
|
-
descriptor: undefined;
|
|
13
|
-
value: undefined;
|
|
14
|
-
readonly type: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
|
|
15
|
-
};
|
|
16
|
-
static fetcher(typeNameOrTyperFn: any, regExp?: undefined, searchClass?: ObjectConstructor, searchFunction?: string, owner?: typeof globalThis): any;
|
|
17
|
-
static makeReport(owner?: typeof globalThis): {};
|
|
18
|
-
}
|
|
19
|
-
export const IntrospectorExtensions: Extension;
|
|
20
|
-
import { Extension } from '@nejs/extension';
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { Extension } from '@nejs/extension';
|
|
2
|
-
export class Introspector {
|
|
3
|
-
static addExpansion(array) {
|
|
4
|
-
const toEntriesFrom = (owner = globalThis) => {
|
|
5
|
-
return (accumulator, key) => {
|
|
6
|
-
const count = accumulator.length;
|
|
7
|
-
try {
|
|
8
|
-
const value = owner[key];
|
|
9
|
-
accumulator.splice(count, 0, [key, value], [value, key]);
|
|
10
|
-
}
|
|
11
|
-
catch (error) {
|
|
12
|
-
accumulator.splice(count, 0, [key, error]);
|
|
13
|
-
}
|
|
14
|
-
return accumulator;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
return Object.defineProperty(array, 'expand', {
|
|
18
|
-
get() {
|
|
19
|
-
return new Map(this.reduce(toEntriesFrom(globalThis), []));
|
|
20
|
-
},
|
|
21
|
-
configurable: true,
|
|
22
|
-
enumerable: true,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
static accessors(owner = globalThis, keys = []) {
|
|
26
|
-
const entries = [];
|
|
27
|
-
for (const key of keys) {
|
|
28
|
-
try {
|
|
29
|
-
const metadata = this.metadata(owner, key);
|
|
30
|
-
if (metadata.get || metadata.set) {
|
|
31
|
-
entries.push([key, metadata]);
|
|
32
|
-
}
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
entries.push([key, error]);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return new Map(entries);
|
|
40
|
-
}
|
|
41
|
-
static classes(owner = globalThis) {
|
|
42
|
-
return this.fetcher('function', /^[A-Z]/, Object, 'getOwnPropertyNames', owner);
|
|
43
|
-
}
|
|
44
|
-
static functions(owner = globalThis) {
|
|
45
|
-
return this.fetcher('function', /^[a-z]/, Object, 'getOwnPropertyNames', owner);
|
|
46
|
-
}
|
|
47
|
-
static objects(owner = globalThis) {
|
|
48
|
-
return this.fetcher('object', null, Object, 'getOwnPropertyNames', owner);
|
|
49
|
-
}
|
|
50
|
-
static properties(owner = globalThis) {
|
|
51
|
-
return this.fetcher((v, t, d) => t !== 'object' && t !== 'function', null, Object, 'getOwnPropertyNames', owner);
|
|
52
|
-
}
|
|
53
|
-
static symbols(owner = globalThis) {
|
|
54
|
-
return this.addExpansion(Object.getOwnPropertySymbols(owner));
|
|
55
|
-
}
|
|
56
|
-
static metadata(owner, key) {
|
|
57
|
-
const metadata = {
|
|
58
|
-
owner, key,
|
|
59
|
-
descriptor: undefined,
|
|
60
|
-
value: undefined,
|
|
61
|
-
get type() { return typeof this.value; },
|
|
62
|
-
};
|
|
63
|
-
try {
|
|
64
|
-
metadata.descriptor = Object.getOwnPropertyDescriptor(owner, key);
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
metadata.descriptor = error;
|
|
68
|
-
}
|
|
69
|
-
try {
|
|
70
|
-
metadata.value = (metadata.descriptor?.value ??
|
|
71
|
-
metadata.descriptor?.get?.bind(owner)?.() ??
|
|
72
|
-
owner[key]);
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
metadata.value = error;
|
|
76
|
-
}
|
|
77
|
-
return metadata;
|
|
78
|
-
}
|
|
79
|
-
static fetcher(typeNameOrTyperFn, regExp = undefined, searchClass = Object, searchFunction = 'getOwnPropertyNames', owner = globalThis) {
|
|
80
|
-
let typer = typeNameOrTyperFn;
|
|
81
|
-
if (typeof typeNameOrTyperFn !== 'function') {
|
|
82
|
-
const type = String(typeNameOrTyperFn);
|
|
83
|
-
typer = (function (value, typeName, descriptor) {
|
|
84
|
-
return typeName === type;
|
|
85
|
-
}).bind(this);
|
|
86
|
-
}
|
|
87
|
-
return this.addExpansion(searchClass[searchFunction](owner).filter(key => {
|
|
88
|
-
const metadata = this.metadata(owner, key);
|
|
89
|
-
return ((!regExp || regExp.exec(String(key))) &&
|
|
90
|
-
typer(metadata.value, metadata.type, metadata.descriptor));
|
|
91
|
-
}).toSorted());
|
|
92
|
-
}
|
|
93
|
-
static makeReport(owner = globalThis) {
|
|
94
|
-
let names = [
|
|
95
|
-
'classes', 'functions', 'objects', 'properties', 'symbols', 'accessors'
|
|
96
|
-
];
|
|
97
|
-
let bound = names.reduce((a, n) => { a[n] = this[n].bind(this); return a; }, {});
|
|
98
|
-
const { classes, functions, objects, properties, symbols, accessors } = bound;
|
|
99
|
-
const result = {};
|
|
100
|
-
Object.assign(result, {
|
|
101
|
-
accessors: {
|
|
102
|
-
classes: undefined,
|
|
103
|
-
functions: undefined,
|
|
104
|
-
objects: undefined,
|
|
105
|
-
properties: undefined,
|
|
106
|
-
symbols: undefined,
|
|
107
|
-
},
|
|
108
|
-
classes: this[classes.name](),
|
|
109
|
-
functions: this[functions.name](),
|
|
110
|
-
objects: this[objects.name](),
|
|
111
|
-
properties: this[properties.name](),
|
|
112
|
-
symbols: this[symbols.name](),
|
|
113
|
-
expandAll() {
|
|
114
|
-
names.forEach(reportName => {
|
|
115
|
-
result[reportName] = result?.[reportName]?.expand;
|
|
116
|
-
});
|
|
117
|
-
},
|
|
118
|
-
})(names.forEach(type => {
|
|
119
|
-
debugger;
|
|
120
|
-
result.accessors[type] = accessors(globalThis, result[type]);
|
|
121
|
-
}));
|
|
122
|
-
return result;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
export const IntrospectorExtensions = new Extension(Introspector);
|
|
126
|
-
//# sourceMappingURL=introspector.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"introspector.js","sourceRoot":"","sources":["../../../src/classes/introspector.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,MAAM,OAAO,YAAY;IACvB,MAAM,CAAC,YAAY,CAAC,KAAK;QACvB,MAAM,aAAa,GAAG,CAAC,KAAK,GAAG,UAAU,EAAE,EAAE;YAC3C,OAAO,CAAC,WAAW,EAAE,GAAG,EAAE,EAAE;gBAC1B,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC;gBAEjC,IAAI,CAAC;oBACH,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAA;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