@nejs/basic-extensions 2.7.0 → 2.8.0
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/.vscode/settings.json +5 -0
- package/README.md +6129 -1574
- package/dist/@nejs/basic-extensions.bundle.2.7.0.js +19 -0
- package/dist/@nejs/basic-extensions.bundle.2.7.0.js.map +7 -0
- package/dist/cjs/array.extensions.d.ts +39 -0
- package/dist/cjs/array.extensions.js +303 -0
- package/dist/cjs/array.extensions.js.map +1 -0
- package/dist/cjs/big.int.extension.d.ts +31 -0
- package/dist/cjs/big.int.extension.js +164 -0
- package/dist/cjs/big.int.extension.js.map +1 -0
- package/dist/cjs/{newClasses → classes}/asyncIterable.js +32 -44
- package/dist/cjs/classes/asyncIterable.js.map +1 -0
- package/dist/cjs/{newClasses → classes}/deferred.js +66 -138
- package/dist/cjs/classes/deferred.js.map +1 -0
- package/dist/cjs/{newClasses → classes}/descriptor.js +56 -90
- package/dist/cjs/classes/descriptor.js.map +1 -0
- package/dist/cjs/classes/index.d.ts +13 -0
- package/dist/cjs/classes/index.js +57 -0
- package/dist/cjs/classes/index.js.map +1 -0
- package/dist/cjs/classes/introspector.d.ts +20 -0
- package/dist/cjs/classes/introspector.js +130 -0
- package/dist/cjs/classes/introspector.js.map +1 -0
- package/dist/cjs/{newClasses → classes}/iterable.js +42 -63
- package/dist/cjs/classes/iterable.js.map +1 -0
- package/dist/cjs/classes/param.parser.d.ts +227 -0
- package/dist/cjs/classes/param.parser.js +242 -0
- package/dist/cjs/classes/param.parser.js.map +1 -0
- package/dist/cjs/classes/pluggable.proxy.d.ts +152 -0
- package/dist/cjs/classes/pluggable.proxy.js +444 -0
- package/dist/cjs/classes/pluggable.proxy.js.map +1 -0
- package/dist/cjs/{newClasses → classes}/refmap.js +18 -30
- package/dist/cjs/classes/refmap.js.map +1 -0
- package/dist/cjs/{newClasses → classes}/refset.js +28 -47
- package/dist/cjs/classes/refset.js.map +1 -0
- package/dist/cjs/classes/symkeys.d.ts +292 -0
- package/dist/cjs/classes/symkeys.js +424 -0
- package/dist/cjs/classes/symkeys.js.map +1 -0
- package/dist/cjs/classes/type.d.ts +56 -0
- package/dist/cjs/classes/type.js +405 -0
- package/dist/cjs/classes/type.js.map +1 -0
- package/dist/cjs/function.extensions.js +757 -0
- package/dist/cjs/function.extensions.js.map +1 -0
- package/dist/cjs/global.this.js +261 -0
- package/dist/cjs/global.this.js.map +1 -0
- package/dist/cjs/index.d.ts +4 -3
- package/dist/cjs/index.js +62 -32
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/json.extensions.d.ts +2 -0
- package/dist/cjs/json.extensions.js +107 -0
- package/dist/cjs/json.extensions.js.map +1 -0
- package/dist/{mjs/mapextensions.d.ts → cjs/map.extensions.d.ts} +1 -0
- package/dist/cjs/map.extensions.js +142 -0
- package/dist/cjs/map.extensions.js.map +1 -0
- package/dist/cjs/number.extension.d.ts +44 -0
- package/dist/cjs/number.extension.js +260 -0
- package/dist/cjs/number.extension.js.map +1 -0
- package/dist/cjs/object.extensions.d.ts +62 -0
- package/dist/cjs/object.extensions.js +1116 -0
- package/dist/cjs/object.extensions.js.map +1 -0
- package/dist/cjs/proxy.extensions.d.ts +2 -0
- package/dist/cjs/proxy.extensions.js +207 -0
- package/dist/cjs/proxy.extensions.js.map +1 -0
- package/dist/cjs/reflect.extensions.js +316 -0
- package/dist/cjs/reflect.extensions.js.map +1 -0
- package/dist/cjs/regular.expression.extensions.d.ts +2 -0
- package/dist/cjs/regular.expression.extensions.js +423 -0
- package/dist/cjs/regular.expression.extensions.js.map +1 -0
- package/dist/cjs/set.extensions.d.ts +40 -0
- package/dist/cjs/{setextensions.js → set.extensions.js} +150 -2
- package/dist/cjs/set.extensions.js.map +1 -0
- package/dist/cjs/string.extensions.js +471 -0
- package/dist/cjs/string.extensions.js.map +1 -0
- package/dist/{mjs/symbolextensions.d.ts → cjs/symbol.extensions.d.ts} +1 -0
- package/dist/cjs/symbol.extensions.js +259 -0
- package/dist/cjs/symbol.extensions.js.map +1 -0
- package/dist/cjs/{weakrefextensions.js → weakref.extensions.js} +1 -1
- package/dist/cjs/weakref.extensions.js.map +1 -0
- package/dist/mjs/array.extensions.d.ts +39 -0
- package/dist/mjs/array.extensions.js +300 -0
- package/dist/mjs/array.extensions.js.map +1 -0
- package/dist/mjs/big.int.extension.d.ts +31 -0
- package/dist/mjs/big.int.extension.js +161 -0
- package/dist/mjs/big.int.extension.js.map +1 -0
- package/dist/mjs/classes/asyncIterable.js.map +1 -0
- package/dist/mjs/classes/deferred.js.map +1 -0
- package/dist/mjs/{newClasses → classes}/descriptor.js +7 -4
- package/dist/mjs/classes/descriptor.js.map +1 -0
- package/dist/mjs/classes/index.d.ts +13 -0
- package/dist/mjs/classes/index.js +40 -0
- package/dist/mjs/classes/index.js.map +1 -0
- package/dist/mjs/classes/introspector.d.ts +20 -0
- package/dist/mjs/classes/introspector.js +126 -0
- package/dist/mjs/classes/introspector.js.map +1 -0
- package/dist/mjs/classes/iterable.js.map +1 -0
- package/dist/mjs/classes/param.parser.d.ts +227 -0
- package/dist/mjs/classes/param.parser.js +238 -0
- package/dist/mjs/classes/param.parser.js.map +1 -0
- package/dist/mjs/classes/pluggable.proxy.d.ts +152 -0
- package/dist/mjs/classes/pluggable.proxy.js +438 -0
- package/dist/mjs/classes/pluggable.proxy.js.map +1 -0
- package/dist/mjs/{newClasses → classes}/refmap.js +3 -3
- package/dist/mjs/classes/refmap.js.map +1 -0
- package/dist/mjs/classes/refset.js.map +1 -0
- package/dist/mjs/classes/symkeys.d.ts +292 -0
- package/dist/mjs/classes/symkeys.js +420 -0
- package/dist/mjs/classes/symkeys.js.map +1 -0
- package/dist/mjs/classes/type.d.ts +56 -0
- package/dist/mjs/classes/type.js +401 -0
- package/dist/mjs/classes/type.js.map +1 -0
- package/dist/mjs/function.extensions.js +754 -0
- package/dist/mjs/function.extensions.js.map +1 -0
- package/dist/mjs/global.this.js +258 -0
- package/dist/mjs/global.this.js.map +1 -0
- package/dist/mjs/index.d.ts +4 -3
- package/dist/mjs/index.js +49 -19
- package/dist/mjs/index.js.map +1 -1
- package/dist/mjs/json.extensions.d.ts +2 -0
- package/dist/mjs/json.extensions.js +104 -0
- package/dist/mjs/json.extensions.js.map +1 -0
- package/dist/{cjs/mapextensions.d.ts → mjs/map.extensions.d.ts} +1 -0
- package/dist/mjs/map.extensions.js +139 -0
- package/dist/mjs/map.extensions.js.map +1 -0
- package/dist/mjs/number.extension.d.ts +44 -0
- package/dist/mjs/number.extension.js +257 -0
- package/dist/mjs/number.extension.js.map +1 -0
- package/dist/mjs/object.extensions.d.ts +62 -0
- package/dist/mjs/object.extensions.js +1112 -0
- package/dist/mjs/object.extensions.js.map +1 -0
- package/dist/mjs/proxy.extensions.d.ts +2 -0
- package/dist/mjs/proxy.extensions.js +204 -0
- package/dist/mjs/proxy.extensions.js.map +1 -0
- package/dist/mjs/reflect.extensions.js +313 -0
- package/dist/mjs/reflect.extensions.js.map +1 -0
- package/dist/mjs/regular.expression.extensions.d.ts +2 -0
- package/dist/mjs/regular.expression.extensions.js +420 -0
- package/dist/mjs/regular.expression.extensions.js.map +1 -0
- package/dist/mjs/set.extensions.d.ts +40 -0
- package/dist/mjs/{setextensions.js → set.extensions.js} +149 -1
- package/dist/mjs/set.extensions.js.map +1 -0
- package/dist/mjs/string.extensions.js +468 -0
- package/dist/mjs/string.extensions.js.map +1 -0
- package/dist/{cjs/symbolextensions.d.ts → mjs/symbol.extensions.d.ts} +1 -0
- package/dist/mjs/symbol.extensions.js +256 -0
- package/dist/mjs/symbol.extensions.js.map +1 -0
- package/dist/mjs/{weakrefextensions.js → weakref.extensions.js} +1 -1
- package/dist/mjs/weakref.extensions.js.map +1 -0
- package/docs/index.html +24045 -5805
- package/package.json +6 -4
- package/src/array.extensions.js +322 -0
- package/src/big.int.extension.js +163 -0
- package/src/{newClasses → classes}/descriptor.js +16 -12
- package/src/classes/index.js +51 -0
- package/src/classes/introspector.js +167 -0
- package/src/classes/param.parser.js +253 -0
- package/src/classes/pluggable.proxy.js +485 -0
- package/src/{newClasses → classes}/refmap.js +5 -3
- package/src/classes/symkeys.js +464 -0
- package/src/classes/type.js +427 -0
- package/src/function.extensions.js +818 -0
- package/src/global.this.js +304 -0
- package/src/index.js +56 -23
- package/src/json.extensions.js +108 -0
- package/src/map.extensions.js +144 -0
- package/src/number.extension.js +273 -0
- package/src/object.extensions.js +1222 -0
- package/src/proxy.extensions.js +229 -0
- package/src/reflect.extensions.js +346 -0
- package/src/regular.expression.extensions.js +451 -0
- package/src/{setextensions.js → set.extensions.js} +151 -2
- package/src/string.extensions.js +515 -0
- package/src/symbol.extensions.js +268 -0
- package/tests/newClasses/refmap.test.js +3 -2
- package/tsconfig.base.json +5 -3
- package/tsconfig.cjs.json +2 -2
- package/tsconfig.esm.json +2 -2
- package/dist/@nejs/basic-extensions.bundle.2.6.0.js +0 -17
- package/dist/@nejs/basic-extensions.bundle.2.6.0.js.map +0 -7
- package/dist/cjs/arrayextensions.d.ts +0 -10
- package/dist/cjs/arrayextensions.js +0 -73
- package/dist/cjs/arrayextensions.js.map +0 -1
- package/dist/cjs/functionextensions.js +0 -202
- package/dist/cjs/functionextensions.js.map +0 -1
- package/dist/cjs/globals.js +0 -166
- package/dist/cjs/globals.js.map +0 -1
- package/dist/cjs/mapextensions.js +0 -32
- package/dist/cjs/mapextensions.js.map +0 -1
- package/dist/cjs/newClasses/asyncIterable.js.map +0 -1
- package/dist/cjs/newClasses/deferred.js.map +0 -1
- package/dist/cjs/newClasses/descriptor.js.map +0 -1
- package/dist/cjs/newClasses/iterable.js.map +0 -1
- package/dist/cjs/newClasses/refmap.js.map +0 -1
- package/dist/cjs/newClasses/refset.js.map +0 -1
- package/dist/cjs/objectextensions.d.ts +0 -11
- package/dist/cjs/objectextensions.js +0 -232
- package/dist/cjs/objectextensions.js.map +0 -1
- package/dist/cjs/reflectextensions.js +0 -111
- package/dist/cjs/reflectextensions.js.map +0 -1
- package/dist/cjs/setextensions.d.ts +0 -2
- package/dist/cjs/setextensions.js.map +0 -1
- package/dist/cjs/stringextensions.js +0 -158
- package/dist/cjs/stringextensions.js.map +0 -1
- package/dist/cjs/symbolextensions.js +0 -69
- package/dist/cjs/symbolextensions.js.map +0 -1
- package/dist/cjs/weakrefextensions.js.map +0 -1
- package/dist/mjs/arrayextensions.d.ts +0 -10
- package/dist/mjs/arrayextensions.js +0 -70
- package/dist/mjs/arrayextensions.js.map +0 -1
- package/dist/mjs/functionextensions.js +0 -199
- package/dist/mjs/functionextensions.js.map +0 -1
- package/dist/mjs/globals.js +0 -163
- package/dist/mjs/globals.js.map +0 -1
- package/dist/mjs/mapextensions.js +0 -29
- package/dist/mjs/mapextensions.js.map +0 -1
- package/dist/mjs/newClasses/asyncIterable.js.map +0 -1
- package/dist/mjs/newClasses/deferred.js.map +0 -1
- package/dist/mjs/newClasses/descriptor.js.map +0 -1
- package/dist/mjs/newClasses/iterable.js.map +0 -1
- package/dist/mjs/newClasses/refmap.js.map +0 -1
- package/dist/mjs/newClasses/refset.js.map +0 -1
- package/dist/mjs/objectextensions.d.ts +0 -11
- package/dist/mjs/objectextensions.js +0 -229
- package/dist/mjs/objectextensions.js.map +0 -1
- package/dist/mjs/reflectextensions.js +0 -108
- package/dist/mjs/reflectextensions.js.map +0 -1
- package/dist/mjs/setextensions.d.ts +0 -2
- package/dist/mjs/setextensions.js.map +0 -1
- package/dist/mjs/stringextensions.js +0 -155
- package/dist/mjs/stringextensions.js.map +0 -1
- package/dist/mjs/symbolextensions.js +0 -66
- package/dist/mjs/symbolextensions.js.map +0 -1
- package/dist/mjs/weakrefextensions.js.map +0 -1
- package/src/arrayextensions.js +0 -75
- package/src/functionextensions.js +0 -225
- package/src/globals.js +0 -196
- package/src/mapextensions.js +0 -32
- package/src/objectextensions.js +0 -256
- package/src/reflectextensions.js +0 -118
- package/src/stringextensions.js +0 -166
- package/src/symbolextensions.js +0 -69
- /package/dist/cjs/{newClasses → classes}/asyncIterable.d.ts +0 -0
- /package/dist/cjs/{newClasses → classes}/deferred.d.ts +0 -0
- /package/dist/cjs/{newClasses → classes}/descriptor.d.ts +0 -0
- /package/dist/cjs/{newClasses → classes}/iterable.d.ts +0 -0
- /package/dist/cjs/{newClasses → classes}/refmap.d.ts +0 -0
- /package/dist/cjs/{newClasses → classes}/refset.d.ts +0 -0
- /package/dist/cjs/{functionextensions.d.ts → function.extensions.d.ts} +0 -0
- /package/dist/cjs/{globals.d.ts → global.this.d.ts} +0 -0
- /package/dist/cjs/{reflectextensions.d.ts → reflect.extensions.d.ts} +0 -0
- /package/dist/cjs/{stringextensions.d.ts → string.extensions.d.ts} +0 -0
- /package/dist/cjs/{weakrefextensions.d.ts → weakref.extensions.d.ts} +0 -0
- /package/dist/mjs/{newClasses → classes}/asyncIterable.d.ts +0 -0
- /package/dist/mjs/{newClasses → classes}/asyncIterable.js +0 -0
- /package/dist/mjs/{newClasses → classes}/deferred.d.ts +0 -0
- /package/dist/mjs/{newClasses → classes}/deferred.js +0 -0
- /package/dist/mjs/{newClasses → classes}/descriptor.d.ts +0 -0
- /package/dist/mjs/{newClasses → classes}/iterable.d.ts +0 -0
- /package/dist/mjs/{newClasses → classes}/iterable.js +0 -0
- /package/dist/mjs/{newClasses → classes}/refmap.d.ts +0 -0
- /package/dist/mjs/{newClasses → classes}/refset.d.ts +0 -0
- /package/dist/mjs/{newClasses → classes}/refset.js +0 -0
- /package/dist/mjs/{functionextensions.d.ts → function.extensions.d.ts} +0 -0
- /package/dist/mjs/{globals.d.ts → global.this.d.ts} +0 -0
- /package/dist/mjs/{reflectextensions.d.ts → reflect.extensions.d.ts} +0 -0
- /package/dist/mjs/{stringextensions.d.ts → string.extensions.d.ts} +0 -0
- /package/dist/mjs/{weakrefextensions.d.ts → weakref.extensions.d.ts} +0 -0
- /package/src/{newClasses → classes}/asyncIterable.js +0 -0
- /package/src/{newClasses → classes}/deferred.js +0 -0
- /package/src/{newClasses → classes}/iterable.js +0 -0
- /package/src/{newClasses → classes}/refset.js +0 -0
- /package/src/{weakrefextensions.js → weakref.extensions.js} +0 -0
package/src/objectextensions.js
DELETED
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
import { Patch } from '@nejs/extension';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* `ObjectExtensions` is a patch for the JavaScript built-in `Object` class.
|
|
5
|
-
* It adds utility methods to the `Object` class without modifying the global
|
|
6
|
-
* namespace directly. This patch includes methods for key validation, object
|
|
7
|
-
* type checking, and retrieving the string tag of an object. These methods
|
|
8
|
-
* are useful for enhancing the capabilities of the standard `Object` class
|
|
9
|
-
* with additional utility functions.
|
|
10
|
-
*/
|
|
11
|
-
export const ObjectExtensions = new Patch(Object, {
|
|
12
|
-
/**
|
|
13
|
-
* The function checks if a value is either `undefined` or `null`.
|
|
14
|
-
*
|
|
15
|
-
* @param {any} value - The parameter "value" is a variable that can hold
|
|
16
|
-
* any value.
|
|
17
|
-
* @returns {boolean} `true` if the value is either `undefined` or `null`,
|
|
18
|
-
* and `false` otherwise.
|
|
19
|
-
*/
|
|
20
|
-
isNullDefined(value) {
|
|
21
|
-
return value === undefined || value === null
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Checks to see if the supplied `value` is both an object, and has the
|
|
26
|
-
* appropriate symbol defined.
|
|
27
|
-
*
|
|
28
|
-
* @param {any} value the value to determine if it contains a defined
|
|
29
|
-
* `Symbol.toStringTag` defined.
|
|
30
|
-
* @returns true if the symbol is defined, false otherwise
|
|
31
|
-
*/
|
|
32
|
-
hasStringTag(value) {
|
|
33
|
-
return Object.isObject(value) && Reflect.has(value, Symbol.toStringTag)
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Retrieves the string tag of an object. The string tag is a representation
|
|
38
|
-
* of the object's type, as defined by its `Object.prototype.toString`
|
|
39
|
-
* method. This utility method is helpful for getting a more descriptive
|
|
40
|
-
* type of an object than what is returned by the `typeof` operator,
|
|
41
|
-
* especially for custom objects.
|
|
42
|
-
*
|
|
43
|
-
* @param {*} value - The object whose string tag is to be retrieved.
|
|
44
|
-
* @param {boolean} strict - if this is set to true, undefined will be
|
|
45
|
-
* returned whenever a supplied object does not have a
|
|
46
|
-
* `Symbol.toStringTag` defined, period. if false, the default,
|
|
47
|
-
* @returns {string} - The string tag of the object, indicating its type.
|
|
48
|
-
*/
|
|
49
|
-
getStringTag(value, strict = false) {
|
|
50
|
-
if (Object.hasStringTag(value)) {
|
|
51
|
-
return value[Symbol.toStringTag]
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (strict) {
|
|
55
|
-
return undefined
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (value && (typeof value === 'function')) {
|
|
59
|
-
return value.name
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return /\s(.+)]/.exec(Object.prototype.toString.call(value))[1];
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Determines the type of the given value based on its string tag. This method
|
|
67
|
-
* uses `Object.getStringTag` to obtain the string tag of the value, which
|
|
68
|
-
* represents its more specific type (e.g., Array, Map, Set) rather than just
|
|
69
|
-
* 'object'. The method then maps this string tag to the corresponding type
|
|
70
|
-
* present in the provided `owner` object, which defaults to `globalThis`.
|
|
71
|
-
* This utility method is especially useful for identifying the specific
|
|
72
|
-
* constructor or class of an object, beyond the basic types identified by
|
|
73
|
-
* the `typeof` operator.
|
|
74
|
-
*
|
|
75
|
-
* @param {any} value - The value whose type is to be determined.
|
|
76
|
-
* @param {object} [owner=globalThis] - The object in which to look up the
|
|
77
|
-
* constructor corresponding to the string tag. Defaults to `globalThis`,
|
|
78
|
-
* which covers global constructors like `Array`, `Object`, etc.
|
|
79
|
-
* @returns {Function|object|null|undefined} - Returns the constructor or
|
|
80
|
-
* type of the value based on its string tag. For 'Null' and 'Undefined',
|
|
81
|
-
* it returns `null` and `undefined`, respectively. For other types, it
|
|
82
|
-
* returns the corresponding constructor (e.g., `Array` for arrays) if
|
|
83
|
-
* available in the `owner` object.
|
|
84
|
-
*/
|
|
85
|
-
getType(value, owner = globalThis) {
|
|
86
|
-
const stringTag = Object.getStringTag(value)
|
|
87
|
-
|
|
88
|
-
switch (stringTag) {
|
|
89
|
-
case 'Null': return null
|
|
90
|
-
case 'Undefined': return undefined
|
|
91
|
-
default:
|
|
92
|
-
return owner[stringTag]
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Determines if the provided value is an object. This method checks whether
|
|
98
|
-
* the value is an instance of `Object` or if its type is 'object'. It's a
|
|
99
|
-
* utility method for type-checking, ensuring that a value is an object
|
|
100
|
-
* before performing operations that are specific to objects.
|
|
101
|
-
*
|
|
102
|
-
* @param {*} value - The value to be checked.
|
|
103
|
-
* @returns {boolean} - Returns `true` if the value is an object,
|
|
104
|
-
* otherwise `false`.
|
|
105
|
-
*/
|
|
106
|
-
isObject(value) {
|
|
107
|
-
return value && (value instanceof Object || typeof value === 'object');
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Checks to see if the supplied value is a primitive value.
|
|
112
|
-
*
|
|
113
|
-
* @param {any} value the value to test to see if it is a primitive value type
|
|
114
|
-
* @returns true if the object is considered widely to be a primitive value,
|
|
115
|
-
* false otherwise.
|
|
116
|
-
*/
|
|
117
|
-
isPrimitive(value) {
|
|
118
|
-
// Check for null as a special case because typeof null
|
|
119
|
-
// is 'object'
|
|
120
|
-
if (value === null) {
|
|
121
|
-
return true;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// Check for other primitives
|
|
125
|
-
switch (typeof value) {
|
|
126
|
-
case 'string':
|
|
127
|
-
case 'number':
|
|
128
|
-
case 'bigint':
|
|
129
|
-
case 'boolean':
|
|
130
|
-
case 'undefined':
|
|
131
|
-
case 'symbol':
|
|
132
|
-
return true;
|
|
133
|
-
default:
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Checks if the given value is a valid key for an object. In JavaScript, a
|
|
140
|
-
* valid key can be either a string or a symbol. This method is useful for
|
|
141
|
-
* validating object keys before using them in operations like setting or
|
|
142
|
-
* getting object properties.
|
|
143
|
-
*
|
|
144
|
-
* @param {*} value - The value to be checked.
|
|
145
|
-
* @returns {boolean} - Returns `true` if the value is a valid object key
|
|
146
|
-
* (string or symbol), otherwise `false`.
|
|
147
|
-
*/
|
|
148
|
-
isValidKey(value) {
|
|
149
|
-
return (typeof value === 'string' || typeof value === 'symbol');
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Strips an object down to only the keys specified. Optionally, any
|
|
154
|
-
* accessors can be made to retain their context on the source object.
|
|
155
|
-
*
|
|
156
|
-
* @param {object} object the object to pare down
|
|
157
|
-
* @param {Array<string|symbol>} keys the keys that should appear in the
|
|
158
|
-
* final reduced object
|
|
159
|
-
* @param {boolean} [bindAccessors = true] if this value is true then any
|
|
160
|
-
* accessors from the source object will continue to have their `this`
|
|
161
|
-
* value bound to the source. If the getter or setter on that object is
|
|
162
|
-
* defined using an arrow function, this will not work as intended.
|
|
163
|
-
* @returns {object} an object containing only the keys and symbols
|
|
164
|
-
* specified in the `keys` parameter.
|
|
165
|
-
*/
|
|
166
|
-
stripTo(object, keys, bindAccessors = true) {
|
|
167
|
-
if (!object || typeof object !== 'object') {
|
|
168
|
-
throw new TypeError(
|
|
169
|
-
'Object.stripTo requires an object to strip. Received',
|
|
170
|
-
object
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const result = {};
|
|
175
|
-
|
|
176
|
-
if (!Array.isArray(keys)) {
|
|
177
|
-
return result;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
for (let key of keys) {
|
|
181
|
-
if (Reflect.has(object, key)) {
|
|
182
|
-
const originalDescriptor = Object.getOwnPropertyDescriptor(object, key);
|
|
183
|
-
const descriptor = { ...originalDescriptor };
|
|
184
|
-
|
|
185
|
-
if (
|
|
186
|
-
typeof descriptor.get === 'function' ||
|
|
187
|
-
typeof descriptor.set === 'function'
|
|
188
|
-
) {
|
|
189
|
-
if (bindAccessors) {
|
|
190
|
-
descriptor.get = descriptor.get?.bind(object);
|
|
191
|
-
descriptor.set = descriptor.set?.bind(object);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
Object.defineProperty(result, key, descriptor);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
return result;
|
|
200
|
-
},
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
const staticPatches = ObjectExtensions.patches;
|
|
204
|
-
|
|
205
|
-
export const ObjectPrototypeExtensions = new Patch(Object.prototype, {
|
|
206
|
-
[Patch.kMutablyHidden](store) {
|
|
207
|
-
return {
|
|
208
|
-
/**
|
|
209
|
-
* Checks to see if the supplied `value` is both an object, and has the
|
|
210
|
-
* appropriate symbol defined.
|
|
211
|
-
*
|
|
212
|
-
* @param {any} value the value to determine if it contains a defined
|
|
213
|
-
* `Symbol.toStringTag` defined.
|
|
214
|
-
* @returns true if the symbol is defined, false otherwise
|
|
215
|
-
*/
|
|
216
|
-
get hasStringTag() {
|
|
217
|
-
return staticPatches.hasStringTag(this)
|
|
218
|
-
},
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Retrieves the string tag of an object. The string tag is a representation
|
|
222
|
-
* of the object's type, as defined by its `Object.prototype.toString`
|
|
223
|
-
* method. This utility method is helpful for getting a more descriptive
|
|
224
|
-
* type of an object than what is returned by the `typeof` operator,
|
|
225
|
-
* especially for custom objects.
|
|
226
|
-
*
|
|
227
|
-
* @param {*} value - The object whose string tag is to be retrieved.
|
|
228
|
-
* @param {boolean} strict - if this is set to true, undefined will be
|
|
229
|
-
* returned whenever a supplied object does not have a
|
|
230
|
-
* `Symbol.toStringTag` defined, period. if false, the default,
|
|
231
|
-
* @returns {string} - The string tag of the object, indicating its type.
|
|
232
|
-
*/
|
|
233
|
-
getStringTag(strict = false) {
|
|
234
|
-
return staticPatches.getStringTag(this, strict)
|
|
235
|
-
},
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Strips an object down to only the keys specified. Optionally, any
|
|
239
|
-
* accessors can be made to retain their context on the source object.
|
|
240
|
-
* This is a passthrough to the static {@link Object.stripTo} function
|
|
241
|
-
*
|
|
242
|
-
* @param {Array<string|symbol>} keys the keys that should appear in the
|
|
243
|
-
* final reduced object
|
|
244
|
-
* @param {boolean} [bindAccessors = true] if this value is true then any
|
|
245
|
-
* accessors from the source object will continue to have their `this`
|
|
246
|
-
* value bound to the source. If the getter or setter on that object is
|
|
247
|
-
* defined using an arrow function, this will not work as intended.
|
|
248
|
-
* @returns {object} an object containing only the keys and symbols
|
|
249
|
-
* specified in the `keys` parameter.
|
|
250
|
-
*/
|
|
251
|
-
stripTo(keys, bindAccessors = true) {
|
|
252
|
-
return Object.stripTo(this, keys, bindAccessors)
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
},
|
|
256
|
-
})
|
package/src/reflectextensions.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { Patch } from '@nejs/extension'
|
|
2
|
-
import { ObjectExtensions } from './objectextensions.js'
|
|
3
|
-
|
|
4
|
-
const { isObject } = ObjectExtensions.patches
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The `ReflectExtensions` class is a patch applied to the built-in JavaScript
|
|
8
|
-
* `Reflect` object. It extends `Reflect` with additional utility methods that
|
|
9
|
-
* enhance its capabilities. These methods provide more advanced ways of
|
|
10
|
-
* interacting with object properties, such as checking for the presence of
|
|
11
|
-
* multiple keys at once (`hasAll`) or verifying if at least one specified key
|
|
12
|
-
* exists in an object (`hasSome`). This class is part of the `@nejs/extension`
|
|
13
|
-
* library and is designed to offer these extended functionalities in a way
|
|
14
|
-
* that is consistent with the existing `Reflect` API, making it intuitive for
|
|
15
|
-
* developers who are already familiar with standard reflection methods in
|
|
16
|
-
* JavaScript.
|
|
17
|
-
*/
|
|
18
|
-
export const ReflectExtensions = new Patch(Reflect, {
|
|
19
|
-
/**
|
|
20
|
-
* The function checks if an object has all the specified keys.
|
|
21
|
-
*
|
|
22
|
-
* @param object - The `object` parameter is the object that we want to
|
|
23
|
-
* check if it has all the specified keys.
|
|
24
|
-
* @param keys - The `keys` parameter is a rest parameter, which means
|
|
25
|
-
* it can accept any number of arguments. In this case, it is expected
|
|
26
|
-
* to receive multiple keys as arguments.
|
|
27
|
-
* @returns a boolean value.
|
|
28
|
-
*/
|
|
29
|
-
hasAll(object, ...keys) {
|
|
30
|
-
return Object.isObject(object) && (keys.flat(Infinity)
|
|
31
|
-
.map(key => Reflect.has(object, key))
|
|
32
|
-
.every(has => has)
|
|
33
|
-
)
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Fetches all descriptors of an object, including those mapped to a
|
|
38
|
-
* symbol descriptor value.
|
|
39
|
-
*
|
|
40
|
-
* @param {object} object the object from whose descriptors need to be
|
|
41
|
-
* retrieved.
|
|
42
|
-
* @returns {object} with keys mapped to object descriptors
|
|
43
|
-
* @throws {TypeError} if the supplied `object` is null or not an object
|
|
44
|
-
* a TypeError exception will be thrown
|
|
45
|
-
*/
|
|
46
|
-
ownDescriptors(object) {
|
|
47
|
-
if (!isObject(object)) {
|
|
48
|
-
throw new TypeError('The supplied object must be non-null and an object')
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const result = {}
|
|
52
|
-
|
|
53
|
-
const keys = Reflect.ownKeys(object)
|
|
54
|
-
|
|
55
|
-
for (const key of keys) {
|
|
56
|
-
result[key] = Object.getOwnPropertyDescriptor(key)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return result
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* The function checks if an object has at least one of the specified keys.
|
|
64
|
-
*
|
|
65
|
-
* @param object - The `object` parameter is the object that we want to check
|
|
66
|
-
* for the presence of certain keys.
|
|
67
|
-
* @param keys - The `keys` parameter is a rest parameter, which means it can
|
|
68
|
-
* accept any number of arguments. These arguments are the keys that we want
|
|
69
|
-
* to check if they exist in the `object`.
|
|
70
|
-
* @returns The function `hasSome` returns a boolean value indicating whether
|
|
71
|
-
* at least one of the keys provided as arguments exists in the given object.
|
|
72
|
-
*/
|
|
73
|
-
hasSome(object, ...keys) {
|
|
74
|
-
return isObject(object) && (keys.flat(Infinity)
|
|
75
|
-
.map(key => Reflect.has(object, key))
|
|
76
|
-
.some(has => has)
|
|
77
|
-
)
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Retrieves an array of [key, descriptor] pairs for each property of the
|
|
82
|
-
* provided object. This method is akin to `Object.entries` but includes
|
|
83
|
-
* property descriptors instead of the property values. It's useful for cases
|
|
84
|
-
* where you need detailed information about properties, including their
|
|
85
|
-
* configurability, enumerability, and accessors.
|
|
86
|
-
*
|
|
87
|
-
* @param {object} object - The object whose property entries are to be
|
|
88
|
-
* retrieved.
|
|
89
|
-
* @returns {Array} An array of [key, descriptor] pairs, where each pair
|
|
90
|
-
* consists of the property name (key) and its descriptor. Returns an empty
|
|
91
|
-
* array if the input is not a valid object.
|
|
92
|
-
*/
|
|
93
|
-
entries(object) {
|
|
94
|
-
if (!object || typeof object !== 'object') { return [] }
|
|
95
|
-
|
|
96
|
-
return Reflect.ownKeys(object).map(key => [
|
|
97
|
-
key, Object.getOwnPropertyDescriptor(object, key)
|
|
98
|
-
])
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Retrieves an array of values from the property descriptors of the given
|
|
103
|
-
* object. This method works similarly to `Object.values` but operates on
|
|
104
|
-
* property descriptors instead. It's useful when you need the values of
|
|
105
|
-
* properties including getters, setters, and other descriptor-specific
|
|
106
|
-
* attributes.
|
|
107
|
-
*
|
|
108
|
-
* @param {object} object - The object whose property values are to be
|
|
109
|
-
* retrieved.
|
|
110
|
-
* @returns {Array} An array of values extracted from the object's property
|
|
111
|
-
* descriptors. The values correspond to the `value` attribute in each
|
|
112
|
-
* property's descriptor. Returns an empty array if the input is not a valid
|
|
113
|
-
* object.
|
|
114
|
-
*/
|
|
115
|
-
values(object) {
|
|
116
|
-
return Reflect.entries.map(([,value]) => value)
|
|
117
|
-
}
|
|
118
|
-
})
|
package/src/stringextensions.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { Patch } from '@nejs/extension';
|
|
2
|
-
|
|
3
|
-
const parenthesisPair = ['(', ')'];
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* `StringExtensions` is a patch for the JavaScript built-in `String` class. It
|
|
7
|
-
* adds utility methods to the `String` class without modifying the global namespace
|
|
8
|
-
* directly. This patch includes methods for key validation, object type checking,
|
|
9
|
-
* and retrieving the string tag of an object. These methods are useful for
|
|
10
|
-
* enhancing the capabilities of the standard `String` class with additional
|
|
11
|
-
* utility functions.
|
|
12
|
-
*/
|
|
13
|
-
export const StringExtensions = new Patch(String, {
|
|
14
|
-
/**
|
|
15
|
-
* The `isString` method does exactly what one would it expect. It returns
|
|
16
|
-
* true if the string matches typeof or instanceof as a string.
|
|
17
|
-
*
|
|
18
|
-
* @param {*} value checks to see if the `value` is a string
|
|
19
|
-
* @returns {boolean} `true` if it is a `String`, `false` otherwise
|
|
20
|
-
*/
|
|
21
|
-
isString(value) {
|
|
22
|
-
if (value && (typeof value === 'string' || value instanceof String)) {
|
|
23
|
-
return value.length > 0
|
|
24
|
-
}
|
|
25
|
-
return false
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* A getter property that returns a pair of parentheses as an array.
|
|
30
|
-
* This property can be used when operations require a clear distinction
|
|
31
|
-
* between the opening and closing parentheses, such as parsing or
|
|
32
|
-
* matching balanced expressions in strings.
|
|
33
|
-
*
|
|
34
|
-
* @returns {[string, string]} An array containing a pair of strings: the
|
|
35
|
-
* opening parenthesis '(' as the first element, and the closing parenthesis
|
|
36
|
-
* ')' as the second element.
|
|
37
|
-
*/
|
|
38
|
-
get parenthesisPair() {
|
|
39
|
-
return ['(', ')'];
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* A getter property that returns a pair of square brackets as an array.
|
|
44
|
-
* This property is particularly useful for operations that require a clear
|
|
45
|
-
* distinction between the opening and closing square brackets, such as
|
|
46
|
-
* parsing arrays in strings or matching balanced expressions within
|
|
47
|
-
* square brackets.
|
|
48
|
-
*
|
|
49
|
-
* @returns {[string, string]} An array containing a pair of strings: the
|
|
50
|
-
* opening square bracket '[' as the first element, and the closing square
|
|
51
|
-
* bracket ']' as the second element.
|
|
52
|
-
*/
|
|
53
|
-
get squareBracketsPair() {
|
|
54
|
-
return ['[', ']'];
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* A getter property that returns a pair of curly brackets as an array.
|
|
59
|
-
* This property is particularly useful for operations that require a clear
|
|
60
|
-
* distinction between the opening and closing curly brackets, such as
|
|
61
|
-
* parsing objects in strings or matching balanced expressions within
|
|
62
|
-
* curly brackets. The returned array consists of the opening curly bracket
|
|
63
|
-
* '{' as the first element, and the closing curly bracket '}' as the
|
|
64
|
-
* second element.
|
|
65
|
-
*
|
|
66
|
-
* @returns {[string, string]} An array containing a pair of strings: the
|
|
67
|
-
* opening curly bracket '{' as the first element, and the closing curly
|
|
68
|
-
* bracket '}' as the second element.
|
|
69
|
-
*/
|
|
70
|
-
get curlyBracketsPair() {
|
|
71
|
-
return ['{', '}'];
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* `StringPrototypeExtensions` provides a set of utility methods that are
|
|
77
|
-
* added to the `String` prototype. This allows all string instances to
|
|
78
|
-
* access new functionality directly, enhancing their capabilities beyond
|
|
79
|
-
* the standard `String` class methods. These extensions are applied using
|
|
80
|
-
* the `Patch` class from '@nejs/extension', ensuring that they do not
|
|
81
|
-
* interfere with the global namespace or existing properties.
|
|
82
|
-
*
|
|
83
|
-
* The extensions include methods for extracting substrings based on
|
|
84
|
-
* specific tokens, checking the presence of certain patterns, and more,
|
|
85
|
-
* making string manipulation tasks more convenient and expressive.
|
|
86
|
-
*/
|
|
87
|
-
export const StringPrototypeExtensions = new Patch(String.prototype, {
|
|
88
|
-
[Patch.kMutablyHidden]: {
|
|
89
|
-
/**
|
|
90
|
-
* Extracts a substring from the current string, starting at a given offset
|
|
91
|
-
* and bounded by specified opening and closing tokens. This method is
|
|
92
|
-
* particularly useful for parsing nested structures or quoted strings,
|
|
93
|
-
* where the level of nesting or the presence of escape characters must
|
|
94
|
-
* be considered.
|
|
95
|
-
*
|
|
96
|
-
* @param {number} offset The position in the string from which to start the
|
|
97
|
-
* search for the substring.
|
|
98
|
-
* @param {[string, string]} tokens An array containing two strings: the
|
|
99
|
-
* opening and closing tokens that define the boundaries of the substring
|
|
100
|
-
* to be extracted.
|
|
101
|
-
* @returns {Object} An object with two properties: `extracted`, the
|
|
102
|
-
* extracted substring, and `newOffset`, the position in the original
|
|
103
|
-
* string immediately after the end of the extracted substring. If no
|
|
104
|
-
* substring is found, `extracted` is `null` and `newOffset` is the same
|
|
105
|
-
* as the input offset.
|
|
106
|
-
*/
|
|
107
|
-
extractSubstring(offset = 0, tokens = parenthesisPair) {
|
|
108
|
-
let [openToken, closeToken] = tokens;
|
|
109
|
-
let depth = 0;
|
|
110
|
-
let start = -1;
|
|
111
|
-
let end = -1;
|
|
112
|
-
let leadingToken = '';
|
|
113
|
-
let firstToken = 0;
|
|
114
|
-
|
|
115
|
-
for (let i = offset; i < this.length; i++) {
|
|
116
|
-
const char = this[i];
|
|
117
|
-
|
|
118
|
-
if (char === openToken) {
|
|
119
|
-
depth++;
|
|
120
|
-
if (start === -1)
|
|
121
|
-
start = i;
|
|
122
|
-
}
|
|
123
|
-
else if (char === closeToken) {
|
|
124
|
-
depth--;
|
|
125
|
-
if (depth === 0) {
|
|
126
|
-
end = i;
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
let lRange = [
|
|
133
|
-
Math.max(0, start - 100),
|
|
134
|
-
start
|
|
135
|
-
];
|
|
136
|
-
let leading = [...this.substring(lRange[0], lRange[1])].reverse().join('')
|
|
137
|
-
let reversedLeadingToken;
|
|
138
|
-
|
|
139
|
-
try {
|
|
140
|
-
reversedLeadingToken = /([^ \,\"\'\`]+)/.exec(leading)[1] ?? '';
|
|
141
|
-
leadingToken = [...reversedLeadingToken].reverse().join('');
|
|
142
|
-
}
|
|
143
|
-
catch(ignored) { }
|
|
144
|
-
|
|
145
|
-
if (start !== -1 && end !== -1) {
|
|
146
|
-
const sliceRange = [start, end + 1];
|
|
147
|
-
const extracted = this.slice(sliceRange[0], sliceRange[1]);
|
|
148
|
-
|
|
149
|
-
return {
|
|
150
|
-
extracted,
|
|
151
|
-
range: [start, end],
|
|
152
|
-
newOffset: end + 1,
|
|
153
|
-
leadingToken,
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
return {
|
|
158
|
-
extracted: null,
|
|
159
|
-
range: [start, end],
|
|
160
|
-
newOffset: offset,
|
|
161
|
-
leadingToken,
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
|
-
})
|
package/src/symbolextensions.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Patch } from '@nejs/extension';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* `SymbolExtensions` is a patch for the JavaScript built-in `Symbol` class. It
|
|
5
|
-
* adds utility methods to the `Symbol` class without modifying the global namespace
|
|
6
|
-
* directly. This patch includes methods for key validation, object type checking,
|
|
7
|
-
* and retrieving the string tag of an object. These methods are useful for
|
|
8
|
-
* enhancing the capabilities of the standard `Symbol` class with additional
|
|
9
|
-
* utility functions.
|
|
10
|
-
*/
|
|
11
|
-
export const SymbolExtensions = new Patch(Symbol, {
|
|
12
|
-
/**
|
|
13
|
-
* The `isSymbol` method does exactly what one would it expect. It returns
|
|
14
|
-
* true if the string matches typeof or instanceof as a symbol.
|
|
15
|
-
*
|
|
16
|
-
* @param {*} value checks to see if the `value` is a string
|
|
17
|
-
* @returns {boolean} `true` if it is a `Symbol`, `false` otherwise
|
|
18
|
-
*/
|
|
19
|
-
isSymbol(value) {
|
|
20
|
-
return value && (typeof value === 'symbol');
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Returns true if the supplied value is a Symbol created using
|
|
25
|
-
* `Symbol.for()`.
|
|
26
|
-
*
|
|
27
|
-
* @param {any} value assumption is that the supplied value is of type
|
|
28
|
-
* 'symbol' however, unless `allowOnlySymbols` is set to `true`, `false`
|
|
29
|
-
* will be returned for any non-symbol values.
|
|
30
|
-
* @param {boolean} allowOnlySymbols true if an error should be thrown
|
|
31
|
-
* if the supplied value is not of type 'symbol'
|
|
32
|
-
* @returns true if the symbol is registered, meaning, none of the spec
|
|
33
|
-
* static symbols (`toStringTag`, `iterator`, etc...), and no symbols
|
|
34
|
-
* created by passing a value directly to the Symbol function, such as
|
|
35
|
-
* `Symbol('name')`
|
|
36
|
-
*/
|
|
37
|
-
isRegistered(value, allowOnlySymbols = false) {
|
|
38
|
-
if (!Symbol.isSymbol(value)) {
|
|
39
|
-
if (allowOnlySymbols) {
|
|
40
|
-
throw new TypeError('allowOnlySymbols specified; value is not a symbol')
|
|
41
|
-
}
|
|
42
|
-
return false
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return Symbol.keyFor(value) !== undefined
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* A function that returns true if the symbol is not registered, meaning,
|
|
50
|
-
* any of the spec static symbols (`toStringTag`, `iterator`, etc...), and
|
|
51
|
-
* any symbols created by passing a value directly to the `Symbol` function,
|
|
52
|
-
* such as `Symbol('name')`.
|
|
53
|
-
*
|
|
54
|
-
* @param {any} value assumption is that the supplied value is of type
|
|
55
|
-
* 'symbol' however, unless allowOnlySymbols is set to true, false will
|
|
56
|
-
* be returned for any non-symbol values.
|
|
57
|
-
* @param {boolean} allowOnlySymbols true if an error should be thrown
|
|
58
|
-
* if the supplied value is not of type 'symbol'
|
|
59
|
-
* @returns true if the symbol is not registered, meaning, any of the
|
|
60
|
-
* spec static symbols (`toStringTag`, `iterator`, etc...), and any symbols
|
|
61
|
-
* created by passing a value directly to the `Symbol` function, such as
|
|
62
|
-
* `Symbol('name')`
|
|
63
|
-
* @returns true if the `value` in question is both a `symbol` and has
|
|
64
|
-
* returns `undefined` if passed to `Symbol.keyFor`
|
|
65
|
-
*/
|
|
66
|
-
isNonRegistered(value, allowOnlySymbols = false) {
|
|
67
|
-
return !Symbol.isRegistered(value, allowOnlySymbols)
|
|
68
|
-
},
|
|
69
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|