@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/package.json
CHANGED
|
@@ -1,36 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Brielle Harrison <nyteshade at gmail.com>",
|
|
3
|
-
"browser": "dist/@nejs/basic-extensions.bundle.2.
|
|
3
|
+
"browser": "dist/@nejs/basic-extensions.bundle.2.22.6.js",
|
|
4
4
|
"description": "Basic but commonly used extensions",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@nejs/extension": "^2.20.0"
|
|
7
|
-
"zod": "^3.23.8"
|
|
6
|
+
"@nejs/extension": "^2.20.0"
|
|
8
7
|
},
|
|
9
8
|
"devDependencies": {
|
|
10
|
-
"docdash": "^2.0.2",
|
|
11
|
-
"documentation": "^14.0.3",
|
|
12
9
|
"esbuild": "^0.25.3",
|
|
13
|
-
"esdoc": "^0.0.2",
|
|
14
|
-
"esdoc-standard-plugin": "^1.0.0",
|
|
15
|
-
"rimraf": "^6.0.1",
|
|
16
|
-
"typescript": "^5.5.4",
|
|
17
10
|
"vitest": "^3.1.2"
|
|
18
11
|
},
|
|
19
12
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
13
|
+
"node": ">=22"
|
|
21
14
|
},
|
|
22
15
|
"exports": {
|
|
23
16
|
".": {
|
|
24
|
-
"
|
|
25
|
-
"
|
|
17
|
+
"browser": "./dist/esm/basic-extensions.mjs",
|
|
18
|
+
"import": "./src/index.js",
|
|
19
|
+
"require": "./dist/cjs/index.cjs"
|
|
26
20
|
},
|
|
27
21
|
"./classes": {
|
|
28
|
-
"import": "./
|
|
29
|
-
"require": "./dist/cjs/classes/index.
|
|
22
|
+
"import": "./src/classes/index.js",
|
|
23
|
+
"require": "./dist/cjs/classes/index.cjs"
|
|
30
24
|
},
|
|
31
25
|
"./utils": {
|
|
32
|
-
"import": "./
|
|
33
|
-
"require": "./dist/cjs/utils/index.
|
|
26
|
+
"import": "./src/utils/index.js",
|
|
27
|
+
"require": "./dist/cjs/utils/index.cjs"
|
|
34
28
|
}
|
|
35
29
|
},
|
|
36
30
|
"keywords": [
|
|
@@ -39,18 +33,18 @@
|
|
|
39
33
|
"localStorage"
|
|
40
34
|
],
|
|
41
35
|
"license": "MIT",
|
|
42
|
-
"main": "dist/cjs/index.
|
|
43
|
-
"module": "
|
|
36
|
+
"main": "dist/cjs/index.cjs",
|
|
37
|
+
"module": "src/index.js",
|
|
44
38
|
"name": "@nejs/basic-extensions",
|
|
45
39
|
"scripts": {
|
|
40
|
+
"build": "bin/clean && bin/version patch bump && bin/esbuild",
|
|
41
|
+
"distribute": "bin/clean && bin/version minor bump && bin/esbuild && npm publish",
|
|
46
42
|
"browser": "bin/esbuild",
|
|
47
|
-
"build": "bin/clean && bin/version patch bump && bin/esbuild && bin/build",
|
|
48
43
|
"clean": "bin/clean",
|
|
49
|
-
"
|
|
50
|
-
"module": "bin/build",
|
|
44
|
+
"prepack": "bin/clean && bin/esbuild",
|
|
51
45
|
"repl": "npm run build && node --no-warnings repl.bootstrap.js",
|
|
52
46
|
"test": "vitest"
|
|
53
47
|
},
|
|
54
48
|
"type": "module",
|
|
55
|
-
"version": "2.
|
|
49
|
+
"version": "2.22.6"
|
|
56
50
|
}
|
package/repl.bootstrap.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node --no-warnings --no-deprecations --enable-source-maps
|
|
2
2
|
|
|
3
3
|
// Import everything for playtesting.
|
|
4
|
-
(await import('./
|
|
4
|
+
(await import('./src/index.js')).Controls.enableAll();
|
|
5
5
|
(await import('./bin/repl.signature.js'))
|
|
6
6
|
|
|
7
|
-
// Grab typescript
|
|
8
|
-
const ts = await import('typescript')
|
|
9
|
-
|
|
10
7
|
const {
|
|
11
8
|
accessor, data, describe, describeMany, extract, isDescriptor,
|
|
12
9
|
isAccessor, isData, redescribe,
|
|
13
|
-
} = await import('./
|
|
10
|
+
} = await import('./src/utils/index.js')
|
|
14
11
|
|
|
15
|
-
const { inspect } = await import('util');
|
|
12
|
+
const { inspect } = await import('node:util');
|
|
16
13
|
const nejsExtension = await import('@nejs/extension');
|
|
17
14
|
|
|
18
15
|
const repl = await import('node:repl');
|
|
@@ -53,7 +50,7 @@ replServer = createRepl({
|
|
|
53
50
|
Extension: nejsExtension.Extension,
|
|
54
51
|
|
|
55
52
|
accessor, data, describe, describeMany, extract, inspect,
|
|
56
|
-
isAccessor, isData, isDescriptor, redescribe,
|
|
53
|
+
isAccessor, isData, isDescriptor, redescribe,
|
|
57
54
|
},
|
|
58
55
|
onReady() {
|
|
59
56
|
console.log(help())
|
package/repl.history
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
+
.exit
|
|
2
|
+
.help
|
|
3
|
+
clear
|
|
4
|
+
is
|
|
5
|
+
.exit
|
|
6
|
+
is.objectKey(/asdfads/)
|
|
7
|
+
is.objectKey(Symbol())
|
|
8
|
+
is.objectKey('asdfads')
|
|
9
|
+
is.objectKey(234)
|
|
10
|
+
is.objectEntry([Symbol(), 234])
|
|
11
|
+
is.objectEntry(['name', 234])
|
|
12
|
+
is.objectEntry(['name', 'Brie'])
|
|
13
|
+
is
|
|
14
|
+
var { is, si, has, as } = await import('./dist/mjs/index.js')
|
|
15
|
+
is.objectEntry(['name', 'Brie'])
|
|
16
|
+
Colors.red
|
|
17
|
+
class Colors extends Enumeration { static { Colors.define('red') } }
|
|
18
|
+
Enumeration
|
|
19
|
+
toolkit.is.a(undefined, undefined)
|
|
20
|
+
toolkit.is.a(undefined, 'undefined')
|
|
21
|
+
toolkit = await import('./src/utils/toolkit.js')
|
|
22
|
+
await import('./src/utils/toolkit.js')
|
|
23
|
+
.exit
|
|
24
|
+
await import('./src/toolkit.js')
|
|
25
|
+
is
|
|
1
26
|
(20n).within(10n, 20n, false)
|
|
2
27
|
(20n).within(10n, 20n, true)
|
|
3
28
|
(30n).within(10n, 20n, true)
|
|
4
29
|
(33n).within(10n, 20n, true)
|
|
5
|
-
(-33n).within(10n, 20n, true)
|
|
6
|
-
(-33n).within(10n, 20n)
|
|
7
|
-
(-33n).clamp(10n, 30n)
|
|
8
|
-
BigInt.max(10n, BigInt.min(30n, -33n))
|
|
9
|
-
-33n.clamp(10n, 30n)
|
|
10
|
-
BigIntExtensions.apply(); BigIntPrototypeExtensions.apply()
|
|
11
|
-
var { BigIntExtensions, BigIntPrototypeExtensions } = await import('./dist/mjs/big.int.extension.js')
|
|
12
|
-
-33n.clamp(10n, 25n)
|
|
13
|
-
BigIntExtensions.apply(); BigIntPrototypeExtensions.apply()
|
|
14
|
-
var { BigIntExtensions, BigIntPrototypeExtensions } = await import('./dist/mjs/big.int.extension.js')
|
|
15
|
-
BigInt.max(10n, BigInt.min(25n, -33n))
|
|
16
|
-
BigInt.max(10n, -33n)
|
|
17
|
-
BigInt.min(25n, -33n)
|
|
18
|
-
-33n.clamp(10n, 25n)
|
|
19
|
-
33n.clamp(10n, 25n)
|
|
20
|
-
BigIntExtensions.apply(); BigIntPrototypeExtensions.apply()
|
|
21
|
-
var { BigIntExtensions, BigIntPrototypeExtensions } = await import('./dist/mjs/big.int.extension.js')
|
|
22
|
-
BigInt(Number.MAX_VALUE + 1)
|
|
23
|
-
BigInt.max
|
|
24
|
-
Number.MAX_VALUE
|
|
25
|
-
BigInt(Number.MAX_VALUE)
|
|
26
|
-
BigInt(Infinity)
|
|
27
|
-
33n.clamp(5n,25n)
|
|
28
|
-
BigIntPrototypeExtensions.apply()
|
|
29
|
-
BigIntExtensions.apply()
|
|
30
|
-
var { BigIntExtensions, BigIntPrototypeExtensions } = await import('./dist/mjs/big.int.extension.js')js/math.extension.js')p) } })get(p) } return Reflect.get(t,p,r) }, has(t,p) { if (t.has(p)) { return true } return Reflect.has(t,p) } })ypeOf(m)ame')ame', 'Brielle']])wner')mport ('.')og','This is being logged'], ['error', 'But something terrible happened'])p('Fun', ['log','This is being logged'], ['error', 'But something terrible happened']).print()ics','underline']).print()int() { console.log(this) }brave new world', ['italics','underline']))['italics','underline'])
|
|
30
|
+
(-33n).within(10n, 20n, true)).within(10n, 20n)).clamp(10n, 30n)t.max(10n, BigInt.min(30n, -33n))3n.clamp(10n, 30n)tExtensions.apply(); BigIntPrototypeExtensions.apply() BigIntPrototypeExtensions } = await import('./dist/mjs/big.int.extension.js') BigIntPrototypeExtensions.apply()sions, BigIntPrototypeExtensions } = await import('./dist/mjs/big.int.extension.js') -33n))gIntPrototypeExtensions } = await import('./dist/mjs/big.int.extension.js')h.extension.js')p) } })get(p) } return Reflect.get(t,p,r) }, has(t,p) { if (t.has(p)) { return true } return Reflect.has(t,p) } })ypeOf(m)ame')ame', 'Brielle']])wner')mport ('.')og','This is being logged'], ['error', 'But something terrible happened'])p('Fun', ['log','This is being logged'], ['error', 'But something terrible happened']).print()ics','underline']).print()int() { console.log(this) }brave new world', ['italics','underline']))['italics','underline'])
|
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
import { Extension } from '@nejs/extension'
|
|
2
|
+
import { is } from '../utils/toolkit.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Allows the creation of static, complex, enumeration values
|
|
6
|
+
* that can be used and identified at runtime (as opposed to
|
|
7
|
+
* TypeScript enum values).
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* class Color extends Enumeration {
|
|
11
|
+
* static {
|
|
12
|
+
* Color.define('red', {r: 255, g: 0, b: 0})
|
|
13
|
+
* Color.define('green', {r: 0, g:255, b: 0})
|
|
14
|
+
* Color.define('blue', {r: 0, g: 0, b: 255})
|
|
15
|
+
*
|
|
16
|
+
* // Color.rgb instances that have no associated
|
|
17
|
+
* // r,g,b values will return a value of 0 for
|
|
18
|
+
* // all r, g, and b values, dynamically.
|
|
19
|
+
* Color.define('rgb', undefined, {
|
|
20
|
+
* get value() {
|
|
21
|
+
* const { r, g, b } = this;
|
|
22
|
+
* return { r: r ?? 0, g: g ?? 0, b: b ?? 0 };
|
|
23
|
+
* }
|
|
24
|
+
* })
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* let thing = {name: 'pole', color: Color.rgb.associate({
|
|
29
|
+
* r: 200,
|
|
30
|
+
* g: 200,
|
|
31
|
+
* b: 200
|
|
32
|
+
* })}
|
|
33
|
+
*
|
|
34
|
+
* switch (thing.key) {
|
|
35
|
+
* case Color.red.key:
|
|
36
|
+
* case Color.green.key:
|
|
37
|
+
* case Color.blue.key:
|
|
38
|
+
* return thing.value;
|
|
39
|
+
*
|
|
40
|
+
* case Color.rgb.key: {
|
|
41
|
+
* // Uses SubscriptProxy to get at custom associations
|
|
42
|
+
* const { r, g, b } = thing
|
|
43
|
+
*
|
|
44
|
+
* return { r, g, b }
|
|
45
|
+
* }
|
|
46
|
+
* }
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
49
|
+
export class Enumeration {
|
|
50
|
+
/**
|
|
51
|
+
* The case name for this {@link Enumeration} instance.
|
|
52
|
+
*
|
|
53
|
+
* @type {string|symbol}
|
|
54
|
+
*/
|
|
55
|
+
key;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The value for this case name, defaults to the same as the
|
|
59
|
+
* case name unless specifically supplied.
|
|
60
|
+
*
|
|
61
|
+
* @type {any}
|
|
62
|
+
*/
|
|
63
|
+
value;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* For {@link Enumeration} instances that have instance level associated
|
|
67
|
+
* values. This is uncommon but is modeled after Swift's enums with
|
|
68
|
+
* associated values. This object is `null` if there are no associations.
|
|
69
|
+
*
|
|
70
|
+
* @type {object}
|
|
71
|
+
*/
|
|
72
|
+
associations;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Creates a new simple {@link Enumeration} case with a key (case name)
|
|
76
|
+
* and associated value of any type. If no value is supplied, it will be
|
|
77
|
+
* set to the value of the key unless `acceptUndefinedValue` is set to
|
|
78
|
+
* true.
|
|
79
|
+
*
|
|
80
|
+
* @param {string|number|symbol} key the case name represented by this
|
|
81
|
+
* instance of {@link Enumeration}.
|
|
82
|
+
* @param {any} value any value for this enumeration case. If this is
|
|
83
|
+
* `undefined` and `acceptUndefinedValue` is set to false (the default)
|
|
84
|
+
* then the value will be identical to the `key`.
|
|
85
|
+
* @param {boolean} [acceptUndefinedValue=false] a flag that allows the
|
|
86
|
+
* rare case of setting a case's value explicitly to `undefined`
|
|
87
|
+
* @returns {Enumeration} a new {@link Enumeration} value, or instance of
|
|
88
|
+
* whatever child class has extended `Enumeration`.
|
|
89
|
+
*/
|
|
90
|
+
constructor(key, value, acceptUndefinedValue = false) {
|
|
91
|
+
if (value === undefined && !acceptUndefinedValue) value = key;
|
|
92
|
+
|
|
93
|
+
Object.assign(this, { key, value });
|
|
94
|
+
Object.defineProperty(this, 'associations', {
|
|
95
|
+
value: null,
|
|
96
|
+
configurable: true,
|
|
97
|
+
enumerable: false,
|
|
98
|
+
writable: true,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Enables a subscript proxy on the instances of each {@link Enumeration}
|
|
103
|
+
* derived instance such that if there is no actual relevant property of
|
|
104
|
+
* the same name, and the instance has associated values, then it returns
|
|
105
|
+
* the value of the property of the same name on the associations object
|
|
106
|
+
* within.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* class Shapes extends Enumeration {
|
|
110
|
+
* static {
|
|
111
|
+
* Shapes.define('other')
|
|
112
|
+
* }
|
|
113
|
+
* }
|
|
114
|
+
*
|
|
115
|
+
* let customShape = Shapes.other.associate({name: 'Dodecahedron'})
|
|
116
|
+
*
|
|
117
|
+
* console.log(customShape.name) // "Dodecahedron"
|
|
118
|
+
*
|
|
119
|
+
* @note if there is an existing property of the same name, such as the
|
|
120
|
+
* `.key` or `.value`, it is safer to use the {@link Enumeration#associated}
|
|
121
|
+
* function retrieve the value. You have been warned.
|
|
122
|
+
*/
|
|
123
|
+
Object.setPrototypeOf(
|
|
124
|
+
this.constructor.prototype,
|
|
125
|
+
SubscriptProxy(
|
|
126
|
+
Object.create(Object.getPrototypeOf(this.constructor.prototype))
|
|
127
|
+
)
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
return this;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Creates a duplicate of this enumeration case, and assigns instance
|
|
135
|
+
* level associated key/value pairs on the copy. It is still of the
|
|
136
|
+
* same enum class type, but has instance level associated value.
|
|
137
|
+
*
|
|
138
|
+
* @param {...(object|string|number|symbol|[string|number|symbol,any])} entries
|
|
139
|
+
* a variadic list of objects (whose key/value pairs will be flattened
|
|
140
|
+
* and added to the associations), a key (string|number|symbol) whose
|
|
141
|
+
* value will be the same as the key, or an Object entry (i.e. an array with
|
|
142
|
+
* the first value being the key and the second value being the value).
|
|
143
|
+
* @returns {*} an instance of this class
|
|
144
|
+
*/
|
|
145
|
+
associate(...entries) {
|
|
146
|
+
const associations = { };
|
|
147
|
+
|
|
148
|
+
for (const entry of entries) {
|
|
149
|
+
if (is.object(entry, Object)) {
|
|
150
|
+
Object.assign(associations, ...entries);
|
|
151
|
+
}
|
|
152
|
+
else if (is.array(entry)) {
|
|
153
|
+
const key = is.objectKey(entry[0]);
|
|
154
|
+
|
|
155
|
+
associations[key] = entry[1];
|
|
156
|
+
}
|
|
157
|
+
else if (is.objectKey(entry)) {
|
|
158
|
+
associations[entry] = entry;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (this.hasAssociatedValues) {
|
|
163
|
+
Object.assign(this.associations, associations);
|
|
164
|
+
|
|
165
|
+
return this;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Create a duplicate of this case instance
|
|
169
|
+
const variantCase = Object.create(this);
|
|
170
|
+
|
|
171
|
+
// Assign the associations object we created
|
|
172
|
+
variantCase.associations = associations;
|
|
173
|
+
|
|
174
|
+
return variantCase;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Shorthand for retrieving an internal associated value
|
|
179
|
+
*
|
|
180
|
+
* @param {string|number|symbol} key a key into the internal
|
|
181
|
+
* associations store. Typically, this value is null.
|
|
182
|
+
* @returns {any|null} null if there is no such named association
|
|
183
|
+
* or if there are no associations stored on this enum value.
|
|
184
|
+
*/
|
|
185
|
+
associated(key) {
|
|
186
|
+
return this.associations?.[key];
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Returns true if there is an associated value for this enumeration case.
|
|
191
|
+
*
|
|
192
|
+
* @returns {boolean} true if associations exist, denoting this is as
|
|
193
|
+
* a variant case; false otherwise.
|
|
194
|
+
*/
|
|
195
|
+
get hasAssociatedValues() {
|
|
196
|
+
return this.associations !== null;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Checks to see if this object is, or is loosely, the same as
|
|
201
|
+
* the supplied `someCase` value. This is determined by comparing
|
|
202
|
+
* the `.key` property.
|
|
203
|
+
*
|
|
204
|
+
* @param {any} someCase some object value that might have a
|
|
205
|
+
* matching (double equals) key property value
|
|
206
|
+
* @returns {boolean} true if the objects are loosely equal (==)
|
|
207
|
+
* or if each of `.key` values are loosely equal (==)
|
|
208
|
+
*/
|
|
209
|
+
is(someCase) {
|
|
210
|
+
// noinspection EqualityComparisonWithCoercionJS
|
|
211
|
+
return this == someCase || this?.key == someCase?.key;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Define the string representation of any given {@link Enumeration}
|
|
216
|
+
* instance to be its `.key` value.
|
|
217
|
+
*
|
|
218
|
+
* @returns {string} the value of the `.key` property wrapped in
|
|
219
|
+
* a call to `String()` to ensure conversion.
|
|
220
|
+
*/
|
|
221
|
+
toString() {
|
|
222
|
+
return String(this.key);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Returns a combination of the this class' name followed by this
|
|
227
|
+
* instances key value. This can be more explicit than just using
|
|
228
|
+
* the `.key` property.
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* class Shape extends Enumeration {
|
|
232
|
+
* static {
|
|
233
|
+
* Shape.define('circle')
|
|
234
|
+
* Shape.define('square')
|
|
235
|
+
* }
|
|
236
|
+
* }
|
|
237
|
+
*
|
|
238
|
+
* console.log(Shape.circle.case) // 'Shape.circle'
|
|
239
|
+
*
|
|
240
|
+
* // ['Shape.circle', 'Shape.square']
|
|
241
|
+
* console.log([...Shape.values()].map(s => s.case))
|
|
242
|
+
*
|
|
243
|
+
* @type {string}
|
|
244
|
+
*/
|
|
245
|
+
get case() {
|
|
246
|
+
return `${this.constructor.name}.${String(this.key)}`
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Define the result of a call to {@link #valueOf} to always be
|
|
251
|
+
* the contents of the `.value` property.
|
|
252
|
+
*
|
|
253
|
+
* @returns {any} the contents of the `.value` property
|
|
254
|
+
*/
|
|
255
|
+
valueOf() {
|
|
256
|
+
return this.value
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Returns the `.key` value as a primitive, unless a conversion to
|
|
261
|
+
* number is requested. In which case, if the `.value` propert is
|
|
262
|
+
* of type {@link Number} then it will be returned. In all other
|
|
263
|
+
* cases the result will be `String(this.key)`.
|
|
264
|
+
*
|
|
265
|
+
* @returns {string|number|NaN} returns a {@link String} representation
|
|
266
|
+
* of the `.key` property unless a number is requested. See above
|
|
267
|
+
* for custom logic pertaining to number coercion.
|
|
268
|
+
*/
|
|
269
|
+
[Symbol.toPrimitive](hint) {
|
|
270
|
+
switch (hint) {
|
|
271
|
+
default:
|
|
272
|
+
case 'string':
|
|
273
|
+
return String(this.key);
|
|
274
|
+
|
|
275
|
+
case 'number':
|
|
276
|
+
return isNumber(this.value)
|
|
277
|
+
? this.value
|
|
278
|
+
: Number(this.key)
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Generates a custom tag name that matches this instances class name.
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* class Shape extends Enumeration {
|
|
287
|
+
* static { Shape.define('circle') }
|
|
288
|
+
* }
|
|
289
|
+
*
|
|
290
|
+
* console.log(Shape.circle[Symbol.toStringTag]) // 'Shape'
|
|
291
|
+
*/
|
|
292
|
+
get [Symbol.toStringTag]() {
|
|
293
|
+
return this.constructor.name;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Static variant of {@link Enumeration#is} that takes a left and
|
|
298
|
+
* right hand value, then checks to see if both objects are, or are
|
|
299
|
+
* loosely, the same as each other's `.key` value.
|
|
300
|
+
*
|
|
301
|
+
* @param {any} leftCase some object value that might have a
|
|
302
|
+
* matching (double equals) key property value
|
|
303
|
+
* @param {any} rightCase some object value that might have a
|
|
304
|
+
* matching (double equals) key property value
|
|
305
|
+
* @returns {boolean} true if the objects are loosely equal (==)
|
|
306
|
+
* or if each of `.key` values are loosely equal (==)
|
|
307
|
+
*/
|
|
308
|
+
static is(leftCase, rightCase) {
|
|
309
|
+
// noinspection EqualityComparisonWithCoercionJS
|
|
310
|
+
return leftCase == rightCase || leftCase?.key == rightCase?.key;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Used when creating a static instance of {@link Enumeration}. Generally
|
|
315
|
+
* this is done as follows:
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* class Shape extends Enumeration {
|
|
319
|
+
* static {
|
|
320
|
+
* Shape.define('cylinder')
|
|
321
|
+
* Shape.define('cube')
|
|
322
|
+
* Shade.define('other')
|
|
323
|
+
* }
|
|
324
|
+
* }
|
|
325
|
+
*
|
|
326
|
+
* @param {string|number|symbol} key the case name of the this particular
|
|
327
|
+
* enumeration instance.
|
|
328
|
+
* @param {any|[string|number|symbol, any]} value the value of the newly
|
|
329
|
+
* defined {@link Enumeration} instance.
|
|
330
|
+
* @param {function|object} [customizeInstance=undefined] defaults to
|
|
331
|
+
* `undefined`, but when it is passed in as a function, the signature
|
|
332
|
+
* would be to take an instance of this Enumeration class and return
|
|
333
|
+
* one (presumably after modification), or in the form of an object whose
|
|
334
|
+
* property descriptors are copied onto the defined instance. This later
|
|
335
|
+
* approach retains getter and setter application as well as other rare
|
|
336
|
+
* descriptor modifications.
|
|
337
|
+
* @returns {*} an instance of this {@link Enumeration} class type.
|
|
338
|
+
*/
|
|
339
|
+
static define(key, value, customizeInstance) {
|
|
340
|
+
if (!is.objectKey(key)) {
|
|
341
|
+
throw new TypeError(
|
|
342
|
+
'Enumeration.define() must have a string/number/symbol key'
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
let caseName = key
|
|
347
|
+
let caseValue = value
|
|
348
|
+
|
|
349
|
+
if (is.objectEntry(value)) {
|
|
350
|
+
([caseName, caseValue] = value);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
let instance = new this(key, value);
|
|
354
|
+
|
|
355
|
+
if (customizeInstance instanceof Function) {
|
|
356
|
+
const newInstance = customizeInstance(instance);
|
|
357
|
+
|
|
358
|
+
if (newInstance instanceof this)
|
|
359
|
+
instance = newInstance;
|
|
360
|
+
}
|
|
361
|
+
else if (is.object(customizeInstance)) {
|
|
362
|
+
const descriptors = Object.getOwnPropertyDescriptors(customizeInstance)
|
|
363
|
+
Object.defineProperties(instance, descriptors)
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
Object.defineProperty(this, key, {
|
|
367
|
+
get() {
|
|
368
|
+
return instance;
|
|
369
|
+
},
|
|
370
|
+
configurable: true,
|
|
371
|
+
enumerable: true,
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Creates an iterator of all {@link Enumeration} derived instances that
|
|
377
|
+
* are statically assigned to this class. Generally this is only useful
|
|
378
|
+
* if applied to child class of `Enumeration`.
|
|
379
|
+
*
|
|
380
|
+
* @returns {Generator<string, void, *>} an iterator that walks instances
|
|
381
|
+
* of derived {@link Enumeration} classes and returns their `.key` values
|
|
382
|
+
*/
|
|
383
|
+
static *cases() {
|
|
384
|
+
for (let [key, _] of this) yield key;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Creates an iterator of all {@link Enumeration} derived instances that
|
|
389
|
+
* are statically assigned to this class. Generally this is only useful
|
|
390
|
+
* if applied to child class of `Enumeration`.
|
|
391
|
+
*
|
|
392
|
+
* @returns {Generator<string, void, *>} an iterator that walks instances
|
|
393
|
+
* of derived {@link Enumeration} classes and returns their `.value` values
|
|
394
|
+
*/
|
|
395
|
+
static *values() {
|
|
396
|
+
for (let [_, value] of this) yield value;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Creates an iterator of all {@link Enumeration} derived instances that
|
|
401
|
+
* are statically assigned to this class. Generally this is only useful
|
|
402
|
+
* if applied to child class of `Enumeration`.
|
|
403
|
+
*
|
|
404
|
+
* @returns {Generator<string, void, *>} an iterator that walks instances
|
|
405
|
+
* of derived {@link Enumeration} classes and returns each key/value pair
|
|
406
|
+
* as arrays. **This is the same as `Object.entries(ChildEnumerationClass)`
|
|
407
|
+
* and then filter the results for pairs whose values are instances of
|
|
408
|
+
* `ChildEnumerationClass`**
|
|
409
|
+
*/
|
|
410
|
+
static *[Symbol.iterator]() {
|
|
411
|
+
const keys = Object.keys(this);
|
|
412
|
+
|
|
413
|
+
for (const key of keys) {
|
|
414
|
+
const value = this[key];
|
|
415
|
+
|
|
416
|
+
if (value instanceof this) yield [key, value];
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Creates a prototype safe {@link Proxy} object, specific to
|
|
423
|
+
* {@link Enumeration} instances, that if a getter tries to reach a named
|
|
424
|
+
* property that doesn't exist on the enum, **and** `.hasAssociatedValues`
|
|
425
|
+
* is `true`, then it will attempt to return `this.associations[property]`
|
|
426
|
+
* instead.
|
|
427
|
+
*
|
|
428
|
+
* @param {object} proxied the object to the behavior to; typically this is
|
|
429
|
+
* the prototype of the class itself. See the constructor in Enumeration for
|
|
430
|
+
* usage.
|
|
431
|
+
* @returns {*|null|object} a {@link Proxy} instance around the supplied
|
|
432
|
+
* object to be proxied with the above defined behavior.
|
|
433
|
+
*/
|
|
434
|
+
export function SubscriptProxy(proxied) {
|
|
435
|
+
return new Proxy(proxied, {
|
|
436
|
+
get(target, property, receiver) {
|
|
437
|
+
if (!Reflect.has(target, property) && receiver.hasAssociatedValues) {
|
|
438
|
+
return receiver.associated(property);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
return Reflect.get(target, property, receiver);
|
|
442
|
+
},
|
|
443
|
+
|
|
444
|
+
set(target, property, newValue, receiver) {
|
|
445
|
+
if (
|
|
446
|
+
!Reflect.has(target, property) &&
|
|
447
|
+
receiver.hasAssociatedValues &&
|
|
448
|
+
Reflect.has(receiver.associations, property)
|
|
449
|
+
) {
|
|
450
|
+
receiver.associations[property] = newValue
|
|
451
|
+
return
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
return Reflect.set(target, property, newValue, receiver);
|
|
455
|
+
},
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* A Extension instance wrapping Enumeration
|
|
461
|
+
*
|
|
462
|
+
* @type {Extension}
|
|
463
|
+
*/
|
|
464
|
+
export const EnumerationExtension = new Extension(Enumeration)
|
|
465
|
+
|
|
466
|
+
export default Enumeration
|
package/src/classes/index.js
CHANGED
|
@@ -12,6 +12,9 @@ export * from './descriptor.js'
|
|
|
12
12
|
import { Enum } from './enum.js'
|
|
13
13
|
export * from './enum.js'
|
|
14
14
|
|
|
15
|
+
import { Enumeration } from './enumeration.js'
|
|
16
|
+
export * from './enumeration.js'
|
|
17
|
+
|
|
15
18
|
import { Introspector } from './introspector.js'
|
|
16
19
|
export * from './introspector.js'
|
|
17
20
|
|
|
@@ -45,6 +48,7 @@ export const NewClassesExtension = new Patch(globalThis, {
|
|
|
45
48
|
Deferred,
|
|
46
49
|
Descriptor,
|
|
47
50
|
Enum,
|
|
51
|
+
Enumeration,
|
|
48
52
|
Introspector,
|
|
49
53
|
Iterable,
|
|
50
54
|
Iterator,
|
|
@@ -56,4 +60,4 @@ export const NewClassesExtension = new Patch(globalThis, {
|
|
|
56
60
|
RefSet,
|
|
57
61
|
Symkeys,
|
|
58
62
|
Type,
|
|
59
|
-
})
|
|
63
|
+
})
|
package/src/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import { SymbolExtensions, SymbolPrototypeExtensions } from './symbol.extensions
|
|
|
16
16
|
import { DeferredExtension } from './classes/deferred.js'
|
|
17
17
|
import { DescriptorExtensions, Descriptor } from './classes/descriptor.js'
|
|
18
18
|
import { EnumExtension, Enum } from './classes/enum.js'
|
|
19
|
+
import { EnumerationExtension, Enumeration } from './classes/enumeration.js'
|
|
19
20
|
import { IntrospectorExtensions } from './classes/introspector.js'
|
|
20
21
|
import { IteratorExtensions, IterableExtensions } from './classes/iterable.js'
|
|
21
22
|
import { ParamParserExtensions } from './classes/param.parser.js'
|
|
@@ -90,6 +91,7 @@ const Extensions = {
|
|
|
90
91
|
[DeferredExtension.key]: DeferredExtension,
|
|
91
92
|
[DescriptorExtensions.key]: DescriptorExtensions,
|
|
92
93
|
[EnumExtension.key]: EnumExtension,
|
|
94
|
+
[EnumerationExtension.key]: EnumerationExtension,
|
|
93
95
|
[IntrospectorExtensions.key]: IntrospectorExtensions,
|
|
94
96
|
[IterableExtensions.key]: IterableExtensions,
|
|
95
97
|
[IteratorExtensions.key]: IteratorExtensions,
|
|
@@ -263,4 +265,4 @@ function toFilterFn(filter = ([owner, extension]) => true) {
|
|
|
263
265
|
}
|
|
264
266
|
|
|
265
267
|
return filterFn
|
|
266
|
-
}
|
|
268
|
+
}
|