@nejs/basic-extensions 1.6.0 → 1.7.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/.esdoc.json +9 -0
- package/README.md +2025 -11
- package/bin/clean +6 -0
- package/dist/@nejs/basic-extensions.bundle.1.6.1.js +4 -0
- package/dist/@nejs/basic-extensions.bundle.1.6.1.js.map +7 -0
- package/dist/cjs/arrayextensions.js +1 -0
- package/dist/cjs/arrayextensions.js.map +1 -0
- package/dist/cjs/functionextensions.js +1 -0
- package/dist/cjs/functionextensions.js.map +1 -0
- package/dist/cjs/globals.js +2 -1
- package/dist/cjs/globals.js.map +1 -0
- package/dist/cjs/index.d.ts +10 -19
- package/dist/cjs/index.js +69 -76
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/mapextensions.d.ts +2 -0
- package/dist/cjs/mapextensions.js +30 -0
- package/dist/cjs/mapextensions.js.map +1 -0
- package/dist/cjs/newClasses/asyncIterable.d.ts +123 -0
- package/dist/cjs/{asyncIterable.js → newClasses/asyncIterable.js} +7 -4
- package/dist/cjs/newClasses/asyncIterable.js.map +1 -0
- package/dist/cjs/newClasses/descriptor.d.ts +401 -0
- package/dist/cjs/{descriptor.js → newClasses/descriptor.js} +150 -80
- package/dist/cjs/newClasses/descriptor.js.map +1 -0
- package/dist/cjs/newClasses/iterable.d.ts +125 -0
- package/dist/cjs/{iterable.js → newClasses/iterable.js} +36 -10
- package/dist/cjs/newClasses/iterable.js.map +1 -0
- package/dist/cjs/newClasses/refmap.d.ts +238 -0
- package/dist/cjs/newClasses/refmap.js +433 -0
- package/dist/cjs/newClasses/refmap.js.map +1 -0
- package/dist/cjs/newClasses/refset.d.ts +186 -0
- package/dist/cjs/{refset.js → newClasses/refset.js} +18 -3
- package/dist/cjs/newClasses/refset.js.map +1 -0
- package/dist/cjs/objectextensions.d.ts +7 -6
- package/dist/cjs/objectextensions.js +85 -43
- package/dist/cjs/objectextensions.js.map +1 -0
- package/dist/cjs/reflectextensions.js +16 -12
- package/dist/cjs/reflectextensions.js.map +1 -0
- package/dist/cjs/stringextensions.js +1 -0
- package/dist/cjs/stringextensions.js.map +1 -0
- package/dist/cjs/symbolextensions.js +3 -1
- package/dist/cjs/symbolextensions.js.map +1 -0
- package/dist/cjs/weakrefextensions.js +1 -0
- package/dist/cjs/weakrefextensions.js.map +1 -0
- package/dist/mjs/arrayextensions.js +1 -0
- package/dist/mjs/arrayextensions.js.map +1 -0
- package/dist/mjs/functionextensions.js +1 -0
- package/dist/mjs/functionextensions.js.map +1 -0
- package/dist/mjs/globals.js +2 -1
- package/dist/mjs/globals.js.map +1 -0
- package/dist/mjs/index.d.ts +10 -19
- package/dist/mjs/index.js +67 -60
- package/dist/mjs/index.js.map +1 -0
- package/dist/mjs/mapextensions.d.ts +2 -0
- package/dist/mjs/mapextensions.js +27 -0
- package/dist/mjs/mapextensions.js.map +1 -0
- package/dist/mjs/newClasses/asyncIterable.d.ts +123 -0
- package/dist/mjs/{asyncIterable.js → newClasses/asyncIterable.js} +106 -105
- package/dist/mjs/newClasses/asyncIterable.js.map +1 -0
- package/dist/mjs/newClasses/descriptor.d.ts +401 -0
- package/dist/mjs/{descriptor.js → newClasses/descriptor.js} +129 -67
- package/dist/mjs/newClasses/descriptor.js.map +1 -0
- package/dist/mjs/newClasses/iterable.d.ts +125 -0
- package/dist/mjs/newClasses/iterable.js +199 -0
- package/dist/mjs/newClasses/iterable.js.map +1 -0
- package/dist/mjs/newClasses/refmap.d.ts +238 -0
- package/dist/mjs/newClasses/refmap.js +417 -0
- package/dist/mjs/newClasses/refmap.js.map +1 -0
- package/dist/mjs/newClasses/refset.d.ts +186 -0
- package/dist/mjs/{refset.js → newClasses/refset.js} +17 -3
- package/dist/mjs/newClasses/refset.js.map +1 -0
- package/dist/mjs/objectextensions.d.ts +7 -6
- package/dist/mjs/objectextensions.js +84 -42
- package/dist/mjs/objectextensions.js.map +1 -0
- package/dist/mjs/reflectextensions.js +16 -12
- package/dist/mjs/reflectextensions.js.map +1 -0
- package/dist/mjs/stringextensions.js +1 -0
- package/dist/mjs/stringextensions.js.map +1 -0
- package/dist/mjs/symbolextensions.js +3 -1
- package/dist/mjs/symbolextensions.js.map +1 -0
- package/dist/mjs/weakrefextensions.js +1 -0
- package/dist/mjs/weakrefextensions.js.map +1 -0
- package/docs/assets/anchor.js +350 -0
- package/docs/assets/bass-addons.css +12 -0
- package/docs/assets/bass.css +544 -0
- package/docs/assets/fonts/EOT/SourceCodePro-Bold.eot +0 -0
- package/docs/assets/fonts/EOT/SourceCodePro-Regular.eot +0 -0
- package/docs/assets/fonts/LICENSE.txt +93 -0
- package/docs/assets/fonts/OTF/SourceCodePro-Bold.otf +0 -0
- package/docs/assets/fonts/OTF/SourceCodePro-Regular.otf +0 -0
- package/docs/assets/fonts/TTF/SourceCodePro-Bold.ttf +0 -0
- package/docs/assets/fonts/TTF/SourceCodePro-Regular.ttf +0 -0
- package/docs/assets/fonts/WOFF/OTF/SourceCodePro-Bold.otf.woff +0 -0
- package/docs/assets/fonts/WOFF/OTF/SourceCodePro-Regular.otf.woff +0 -0
- package/docs/assets/fonts/WOFF/TTF/SourceCodePro-Bold.ttf.woff +0 -0
- package/docs/assets/fonts/WOFF/TTF/SourceCodePro-Regular.ttf.woff +0 -0
- package/docs/assets/fonts/WOFF2/OTF/SourceCodePro-Bold.otf.woff2 +0 -0
- package/docs/assets/fonts/WOFF2/OTF/SourceCodePro-Regular.otf.woff2 +0 -0
- package/docs/assets/fonts/WOFF2/TTF/SourceCodePro-Bold.ttf.woff2 +0 -0
- package/docs/assets/fonts/WOFF2/TTF/SourceCodePro-Regular.ttf.woff2 +0 -0
- package/docs/assets/fonts/source-code-pro.css +23 -0
- package/docs/assets/github.css +123 -0
- package/docs/assets/site.js +168 -0
- package/docs/assets/split.css +15 -0
- package/docs/assets/split.js +782 -0
- package/docs/assets/style.css +147 -0
- package/docs/index.html +13060 -0
- package/jsdoc-config.json +31 -0
- package/package.json +12 -3
- package/src/globals.js +1 -1
- package/src/index.js +75 -82
- package/src/mapextensions.js +30 -0
- package/src/{asyncIterable.js → newClasses/asyncIterable.js} +117 -117
- package/src/{descriptor.js → newClasses/descriptor.js} +137 -74
- package/src/newClasses/iterable.js +221 -0
- package/src/newClasses/refmap.js +483 -0
- package/src/{refset.js → newClasses/refset.js} +29 -16
- package/src/objectextensions.js +97 -46
- package/src/reflectextensions.js +16 -14
- package/src/symbolextensions.js +2 -1
- package/tests/index.test.js +1 -1
- package/tests/{asyncIterable.test.js → newClasses/asyncIterable.test.js} +3 -4
- package/tests/newClasses/descriptor.test.js +252 -0
- package/tests/{iterable.test.js → newClasses/iterable.test.js} +2 -4
- package/tests/newClasses/refmap.test.js +69 -0
- package/tests/{refset.test.js → newClasses/refset.test.js} +2 -4
- package/tests/objectextensions.test.js +128 -0
- package/tsconfig.base.json +2 -1
- package/dist/@nejs/basic-extensions.bundle.1.5.1.js +0 -2
- package/dist/@nejs/basic-extensions.bundle.1.5.1.js.map +0 -7
- package/dist/cjs/asyncIterable.d.ts +0 -3
- package/dist/cjs/descriptor.d.ts +0 -2
- package/dist/cjs/iterable.d.ts +0 -3
- package/dist/cjs/refset.d.ts +0 -2
- package/dist/mjs/asyncIterable.d.ts +0 -3
- package/dist/mjs/descriptor.d.ts +0 -2
- package/dist/mjs/iterable.d.ts +0 -3
- package/dist/mjs/iterable.js +0 -184
- package/dist/mjs/refset.d.ts +0 -2
- package/src/iterable.js +0 -203
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `ObjectExtensions` is a patch for the JavaScript built-in `Object` class.
|
|
3
|
-
* adds utility methods to the `Object` class without modifying the global
|
|
4
|
-
* directly. This patch includes methods for key validation, object
|
|
5
|
-
* and retrieving the string tag of an object. These methods
|
|
6
|
-
* enhancing the capabilities of the standard `Object` class
|
|
7
|
-
* utility functions.
|
|
2
|
+
* `ObjectExtensions` is a patch for the JavaScript built-in `Object` class.
|
|
3
|
+
* It adds utility methods to the `Object` class without modifying the global
|
|
4
|
+
* namespace directly. This patch includes methods for key validation, object
|
|
5
|
+
* type checking, and retrieving the string tag of an object. These methods
|
|
6
|
+
* are useful for enhancing the capabilities of the standard `Object` class
|
|
7
|
+
* with additional utility functions.
|
|
8
8
|
*/
|
|
9
9
|
export const ObjectExtensions: Patch;
|
|
10
|
+
export const ObjectPrototypeExtensions: Patch;
|
|
10
11
|
import { Patch } from '@nejs/extension';
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import { Patch } from '@nejs/extension';
|
|
2
2
|
/**
|
|
3
|
-
* `ObjectExtensions` is a patch for the JavaScript built-in `Object` class.
|
|
4
|
-
* adds utility methods to the `Object` class without modifying the global
|
|
5
|
-
* directly. This patch includes methods for key validation, object
|
|
6
|
-
* and retrieving the string tag of an object. These methods
|
|
7
|
-
* enhancing the capabilities of the standard `Object` class
|
|
8
|
-
* utility functions.
|
|
3
|
+
* `ObjectExtensions` is a patch for the JavaScript built-in `Object` class.
|
|
4
|
+
* It adds utility methods to the `Object` class without modifying the global
|
|
5
|
+
* namespace directly. This patch includes methods for key validation, object
|
|
6
|
+
* type checking, and retrieving the string tag of an object. These methods
|
|
7
|
+
* are useful for enhancing the capabilities of the standard `Object` class
|
|
8
|
+
* with additional utility functions.
|
|
9
9
|
*/
|
|
10
10
|
export const ObjectExtensions = new Patch(Object, {
|
|
11
|
+
/**
|
|
12
|
+
* The function checks if a value is either `undefined` or `null`.
|
|
13
|
+
*
|
|
14
|
+
* @param {any} value - The parameter "value" is a variable that can hold
|
|
15
|
+
* any value.
|
|
16
|
+
* @returns {boolean} `true` if the value is either `undefined` or `null`,
|
|
17
|
+
* and `false` otherwise.
|
|
18
|
+
*/
|
|
19
|
+
isNullDefined(value) {
|
|
20
|
+
return value === undefined || value === null;
|
|
21
|
+
},
|
|
11
22
|
/**
|
|
12
23
|
* Checks to see if the supplied `value` is both an object, and has the
|
|
13
24
|
* appropriate symbol defined.
|
|
@@ -20,18 +31,25 @@ export const ObjectExtensions = new Patch(Object, {
|
|
|
20
31
|
return Object.isObject(value) && Reflect.has(value, Symbol.toStringTag);
|
|
21
32
|
},
|
|
22
33
|
/**
|
|
23
|
-
* Retrieves the string tag of an object. The string tag is a representation
|
|
24
|
-
* the object's type, as defined by its `Object.prototype.toString`
|
|
25
|
-
* utility method is helpful for getting a more descriptive
|
|
26
|
-
* what is returned by the `typeof` operator,
|
|
34
|
+
* Retrieves the string tag of an object. The string tag is a representation
|
|
35
|
+
* of the object's type, as defined by its `Object.prototype.toString`
|
|
36
|
+
* method. This utility method is helpful for getting a more descriptive
|
|
37
|
+
* type of an object than what is returned by the `typeof` operator,
|
|
38
|
+
* especially for custom objects.
|
|
27
39
|
*
|
|
28
40
|
* @param {*} value - The object whose string tag is to be retrieved.
|
|
41
|
+
* @param {boolean} strict - if this is set to true, undefined will be
|
|
42
|
+
* returned whenever a supplied object does not have a
|
|
43
|
+
* `Symbol.toStringTag` defined, period. if false, the default,
|
|
29
44
|
* @returns {string} - The string tag of the object, indicating its type.
|
|
30
45
|
*/
|
|
31
|
-
getStringTag(value) {
|
|
46
|
+
getStringTag(value, strict = false) {
|
|
32
47
|
if (Object.hasStringTag(value)) {
|
|
33
48
|
return value[Symbol.toStringTag];
|
|
34
49
|
}
|
|
50
|
+
if (strict) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
35
53
|
if (value && (typeof value === 'function')) {
|
|
36
54
|
return value.name;
|
|
37
55
|
}
|
|
@@ -49,13 +67,13 @@ export const ObjectExtensions = new Patch(Object, {
|
|
|
49
67
|
*
|
|
50
68
|
* @param {any} value - The value whose type is to be determined.
|
|
51
69
|
* @param {object} [owner=globalThis] - The object in which to look up the
|
|
52
|
-
* constructor corresponding to the string tag. Defaults to `globalThis`,
|
|
53
|
-
* covers global constructors like `Array`, `Object`, etc.
|
|
54
|
-
* @returns {Function|object|null|undefined} - Returns the constructor or
|
|
55
|
-
* of the value based on its string tag. For 'Null' and 'Undefined',
|
|
56
|
-
* `null` and `undefined`, respectively. For other types, it
|
|
57
|
-
* corresponding constructor (e.g., `Array` for arrays) if
|
|
58
|
-
* `owner` object.
|
|
70
|
+
* constructor corresponding to the string tag. Defaults to `globalThis`,
|
|
71
|
+
* which covers global constructors like `Array`, `Object`, etc.
|
|
72
|
+
* @returns {Function|object|null|undefined} - Returns the constructor or
|
|
73
|
+
* type of the value based on its string tag. For 'Null' and 'Undefined',
|
|
74
|
+
* it returns `null` and `undefined`, respectively. For other types, it
|
|
75
|
+
* returns the corresponding constructor (e.g., `Array` for arrays) if
|
|
76
|
+
* available in the `owner` object.
|
|
59
77
|
*/
|
|
60
78
|
getType(value, owner = globalThis) {
|
|
61
79
|
const stringTag = Object.getStringTag(value);
|
|
@@ -67,13 +85,14 @@ export const ObjectExtensions = new Patch(Object, {
|
|
|
67
85
|
}
|
|
68
86
|
},
|
|
69
87
|
/**
|
|
70
|
-
* Determines if the provided value is an object. This method checks whether
|
|
71
|
-
* value is an instance of `Object` or if its type is 'object'. It's a
|
|
72
|
-
* method for type-checking, ensuring that a value is an object
|
|
73
|
-
* operations that are specific to objects.
|
|
88
|
+
* Determines if the provided value is an object. This method checks whether
|
|
89
|
+
* the value is an instance of `Object` or if its type is 'object'. It's a
|
|
90
|
+
* utility method for type-checking, ensuring that a value is an object
|
|
91
|
+
* before performing operations that are specific to objects.
|
|
74
92
|
*
|
|
75
93
|
* @param {*} value - The value to be checked.
|
|
76
|
-
* @returns {boolean} - Returns `true` if the value is an object,
|
|
94
|
+
* @returns {boolean} - Returns `true` if the value is an object,
|
|
95
|
+
* otherwise `false`.
|
|
77
96
|
*/
|
|
78
97
|
isObject(value) {
|
|
79
98
|
return value && (value instanceof Object || typeof value === 'object');
|
|
@@ -105,13 +124,14 @@ export const ObjectExtensions = new Patch(Object, {
|
|
|
105
124
|
}
|
|
106
125
|
},
|
|
107
126
|
/**
|
|
108
|
-
* Checks if the given value is a valid key for an object. In JavaScript, a
|
|
109
|
-
* key can be either a string or a symbol. This method is useful for
|
|
110
|
-
* object keys before using them in operations like setting or
|
|
127
|
+
* Checks if the given value is a valid key for an object. In JavaScript, a
|
|
128
|
+
* valid key can be either a string or a symbol. This method is useful for
|
|
129
|
+
* validating object keys before using them in operations like setting or
|
|
130
|
+
* getting object properties.
|
|
111
131
|
*
|
|
112
132
|
* @param {*} value - The value to be checked.
|
|
113
|
-
* @returns {boolean} - Returns `true` if the value is a valid object key
|
|
114
|
-
*
|
|
133
|
+
* @returns {boolean} - Returns `true` if the value is a valid object key
|
|
134
|
+
* (string or symbol), otherwise `false`.
|
|
115
135
|
*/
|
|
116
136
|
isValidKey(value) {
|
|
117
137
|
return (typeof value === 'string' || typeof value === 'symbol');
|
|
@@ -123,33 +143,55 @@ export const ObjectExtensions = new Patch(Object, {
|
|
|
123
143
|
* @param {object} object the object to pare down
|
|
124
144
|
* @param {Array<string|symbol>} keys the keys that should appear in the
|
|
125
145
|
* final reduced object
|
|
126
|
-
* @param {boolean} [bindAccessors = true] if this value is true
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
* @returns {object} an object containing only the keys and symbols
|
|
131
|
-
* in the `keys` parameter.
|
|
146
|
+
* @param {boolean} [bindAccessors = true] if this value is true then any
|
|
147
|
+
* accessors from the source object will continue to have their `this`
|
|
148
|
+
* value bound to the source. If the getter or setter on that object is
|
|
149
|
+
* defined using an arrow function, this will not work as intended.
|
|
150
|
+
* @returns {object} an object containing only the keys and symbols
|
|
151
|
+
* specified in the `keys` parameter.
|
|
132
152
|
*/
|
|
133
153
|
stripTo(object, keys, bindAccessors = true) {
|
|
154
|
+
if (!object || typeof object !== 'object') {
|
|
155
|
+
throw new TypeError('Object.stripTo requires an object to strip. Received', object);
|
|
156
|
+
}
|
|
134
157
|
const result = {};
|
|
135
158
|
if (!Array.isArray(keys)) {
|
|
136
159
|
return result;
|
|
137
160
|
}
|
|
138
161
|
for (let key of keys) {
|
|
139
162
|
if (Reflect.has(object, key)) {
|
|
140
|
-
const
|
|
141
|
-
|
|
163
|
+
const originalDescriptor = Object.getOwnPropertyDescriptor(object, key);
|
|
164
|
+
const descriptor = { ...originalDescriptor };
|
|
165
|
+
if (typeof descriptor.get === 'function' ||
|
|
166
|
+
typeof descriptor.set === 'function') {
|
|
142
167
|
if (bindAccessors) {
|
|
143
|
-
descriptor.get = descriptor
|
|
144
|
-
descriptor.set = descriptor
|
|
168
|
+
descriptor.get = descriptor.get?.bind(object);
|
|
169
|
+
descriptor.set = descriptor.set?.bind(object);
|
|
145
170
|
}
|
|
146
|
-
Object.defineProperty(result, descriptor);
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
Object.defineProperty(result, descriptor);
|
|
150
171
|
}
|
|
172
|
+
Object.defineProperty(result, key, descriptor);
|
|
151
173
|
}
|
|
152
174
|
}
|
|
153
175
|
return result;
|
|
154
176
|
},
|
|
155
177
|
});
|
|
178
|
+
export const ObjectPrototypeExtensions = new Patch(Object.prototype, {
|
|
179
|
+
/**
|
|
180
|
+
* Strips an object down to only the keys specified. Optionally, any
|
|
181
|
+
* accessors can be made to retain their context on the source object.
|
|
182
|
+
* This is a passthrough to the static {@link Object.stripTo} function
|
|
183
|
+
*
|
|
184
|
+
* @param {Array<string|symbol>} keys the keys that should appear in the
|
|
185
|
+
* final reduced object
|
|
186
|
+
* @param {boolean} [bindAccessors = true] if this value is true then any
|
|
187
|
+
* accessors from the source object will continue to have their `this`
|
|
188
|
+
* value bound to the source. If the getter or setter on that object is
|
|
189
|
+
* defined using an arrow function, this will not work as intended.
|
|
190
|
+
* @returns {object} an object containing only the keys and symbols
|
|
191
|
+
* specified in the `keys` parameter.
|
|
192
|
+
*/
|
|
193
|
+
stripTo(keys, bindAccessors = true) {
|
|
194
|
+
return Object.stripTo(this, keys, bindAccessors);
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
//# sourceMappingURL=objectextensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectextensions.js","sourceR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GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;gBAC7B,MAAM,kBAAkB,GAAG,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;gBACxE,MAAM,UAAU,GAAG,EAAE,GAAG,kBAAkB,EAAE,CAAC;gBAE7C,IACE,OAAO,UAAU,CAAC,GAAG,KAAK,UAAU;oBACpC,OAAO,UAAU,CAAC,GAAG,KAAK,UAAU,EACpC,CAAC;oBACD,IAAI,aAAa,EAAE,CAAC;wBAClB,UAAU,CAAC,GAAG,GAAG,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;wBAC9C,UAAU,CAAC,GAAG,GAAG,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;oBAChD,CAAC;gBACH,CAAC;gBAED,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE;IACnE;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;QAChC,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,CAAA;IAClD,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Patch } from '@nejs/extension';
|
|
2
2
|
import { ObjectExtensions } from './objectextensions.js';
|
|
3
|
+
const { isObject } = ObjectExtensions.patches;
|
|
3
4
|
/**
|
|
4
5
|
* The `ReflectExtensions` class is a patch applied to the built-in JavaScript
|
|
5
6
|
* `Reflect` object. It extends `Reflect` with additional utility methods that
|
|
@@ -28,23 +29,25 @@ export const ReflectExtensions = new Patch(Reflect, {
|
|
|
28
29
|
.map(key => Reflect.has(object, key))
|
|
29
30
|
.every(has => has));
|
|
30
31
|
},
|
|
32
|
+
/**
|
|
33
|
+
* Fetches all descriptors of an object, including those mapped to a
|
|
34
|
+
* symbol descriptor value.
|
|
35
|
+
*
|
|
36
|
+
* @param {object} object the object from whose descriptors need to be
|
|
37
|
+
* retrieved.
|
|
38
|
+
* @returns {object} with keys mapped to object descriptors
|
|
39
|
+
* @throws {TypeError} if the supplied `object` is null or not an object
|
|
40
|
+
* a TypeError exception will be thrown
|
|
41
|
+
*/
|
|
31
42
|
ownDescriptors(object) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
revertOnDone.doIt = false;
|
|
35
|
-
if (!Object.isObject) {
|
|
36
|
-
revertOnDone.doIt = true;
|
|
37
|
-
ObjectExtensions.apply();
|
|
38
|
-
}
|
|
39
|
-
if (!Object.isObject(object)) {
|
|
40
|
-
revertOnDone();
|
|
41
|
-
return {};
|
|
43
|
+
if (!isObject(object)) {
|
|
44
|
+
throw new TypeError('The supplied object must be non-null and an object');
|
|
42
45
|
}
|
|
46
|
+
const result = {};
|
|
43
47
|
const keys = Reflect.ownKeys(object);
|
|
44
48
|
for (const key of keys) {
|
|
45
49
|
result[key] = Object.getOwnPropertyDescriptor(key);
|
|
46
50
|
}
|
|
47
|
-
revertOnDone();
|
|
48
51
|
return result;
|
|
49
52
|
},
|
|
50
53
|
/**
|
|
@@ -59,7 +62,7 @@ export const ReflectExtensions = new Patch(Reflect, {
|
|
|
59
62
|
* at least one of the keys provided as arguments exists in the given object.
|
|
60
63
|
*/
|
|
61
64
|
hasSome(object, ...keys) {
|
|
62
|
-
return
|
|
65
|
+
return isObject(object) && (keys.flat(Infinity)
|
|
63
66
|
.map(key => Reflect.has(object, key))
|
|
64
67
|
.some(has => has));
|
|
65
68
|
},
|
|
@@ -102,3 +105,4 @@ export const ReflectExtensions = new Patch(Reflect, {
|
|
|
102
105
|
return Reflect.entries.map(([, value]) => value);
|
|
103
106
|
}
|
|
104
107
|
});
|
|
108
|
+
//# sourceMappingURL=reflectextensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflectextensions.js","sourceRoot":"","sources":["../../src/reflectextensions.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAExD,MAAM,EAAE,QAAQ,EAAE,GAAG,gBAAgB,CAAC,OAAO,CAAA;AAE7C;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE;IAClD;;;;;;;;;OASG;IACH,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI;QACpB,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;aACnD,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;aACpC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CACnB,CAAA;IACH,CAAC;IAED;;;;;;;;;OASG;IACH,cAAc,CAAC,MAAM;QACnB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,SAAS,CAAC,oDAAoD,CAAC,CAAA;QAC3E,CAAC;QAED,MAAM,MAAM,GAAG,EAAE,CAAA;QAEjB,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAEpC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAA;QACpD,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;IAED;;;;;;;;;;OAUG;IACH,OAAO,CAAC,MAAM,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CAAA;QACzB,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -56,9 +56,11 @@ export const SymbolExtensions = new Patch(Symbol, {
|
|
|
56
56
|
* spec static symbols (`toStringTag`, `iterator`, etc...), and any symbols
|
|
57
57
|
* created by passing a value directly to the `Symbol` function, such as
|
|
58
58
|
* `Symbol('name')`
|
|
59
|
-
* @returns
|
|
59
|
+
* @returns true if the `value` in question is both a `symbol` and has
|
|
60
|
+
* returns `undefined` if passed to `Symbol.keyFor`
|
|
60
61
|
*/
|
|
61
62
|
isNonRegistered(value, allowOnlySymbols = false) {
|
|
62
63
|
return !Symbol.isRegistered(value, allowOnlySymbols);
|
|
63
64
|
},
|
|
64
65
|
});
|
|
66
|
+
//# sourceMappingURL=symbolextensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"symbolextensions.js","sourceRoot":"","sources":["../../src/symbolextensions.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,KAAK,CAAC,MAAM,EAAE;IAChD;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK;QACZ,OAAO,KAAK,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK;QAC1C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5B,IAAI,gBAAgB,EAAE,CAAC;gBACrB,MAAM,IAAI,SAAS,CAAC,mDAAmD,CAAC,CAAA;YAC1E,CAAC;YACD,OAAO,KAAK,CAAA;QACd,CAAC;QAED,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,SAAS,CAAA;IAC3C,CAAC;IAED;;;;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