@nejs/basic-extensions 1.6.1 → 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} +4 -2
- 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} +3 -2
- 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} +2 -2
- 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.6.0.js +0 -2
- package/dist/@nejs/basic-extensions.bundle.1.6.0.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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor.js","sourceRoot":"","sources":["../../../src/newClasses/descriptor.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAE3D,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,gBAAgB,CA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B,CAAC;CACF;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,SAAS,CAAC,UAAU,CAAC,CAAA"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Iterable class is designed to provide a convenient way to create synchronous
|
|
3
|
+
* iterable objects. It can be initialized with either an array or individual elements.
|
|
4
|
+
* This class implements the iterable protocol, allowing instances to be used with
|
|
5
|
+
* `for...of` loops and other standard JavaScript iteration mechanisms.
|
|
6
|
+
*/
|
|
7
|
+
export class Iterable {
|
|
8
|
+
/**
|
|
9
|
+
* Checks if a given value is an iterable. This method determines if the
|
|
10
|
+
* provided value has a `Symbol.iterator` property that is a generator
|
|
11
|
+
* function. It's a precise way to identify if the value conforms to the
|
|
12
|
+
* iterable protocol using a generator function.
|
|
13
|
+
*
|
|
14
|
+
* Note: This method specifically checks for generator functions. Some
|
|
15
|
+
* iterables might use regular functions that return an iterator, which
|
|
16
|
+
* this method won't identify.
|
|
17
|
+
*
|
|
18
|
+
* @param {*} value - The value to be checked for iterability.
|
|
19
|
+
* @returns {boolean} - Returns true if the value is an iterable implemented
|
|
20
|
+
* using a generator function, false otherwise.
|
|
21
|
+
*/
|
|
22
|
+
static isIterable(value: any): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Constructs an instance of Iterable. It can be initialized with either an
|
|
25
|
+
* iterable object (such as an array, Set, Map, string, or any object
|
|
26
|
+
* implementing the iterable protocol) or individual elements. If the first
|
|
27
|
+
* argument is an iterable, the class instance is initialized with the
|
|
28
|
+
* elements from the iterable, followed by any additional arguments. If the
|
|
29
|
+
* first argument is not an iterable, all arguments are treated as individual
|
|
30
|
+
* elements.
|
|
31
|
+
*
|
|
32
|
+
* @param {Iterable|*} elementsOrFirstElement - An iterable object or the
|
|
33
|
+
* first element.
|
|
34
|
+
* @param {...*} moreElements - Additional elements if the first argument is
|
|
35
|
+
* not an iterable.
|
|
36
|
+
*/
|
|
37
|
+
constructor(elementsOrFirstElement: Iterable | any, ...moreElements: any[]);
|
|
38
|
+
/**
|
|
39
|
+
* Provides access to the elements as a standard array. Useful for scenarios
|
|
40
|
+
* where array methods and behaviors are needed.
|
|
41
|
+
*
|
|
42
|
+
* @returns {Array} An array containing all the elements of the iterable.
|
|
43
|
+
*/
|
|
44
|
+
get asArray(): any[];
|
|
45
|
+
/**
|
|
46
|
+
* Implements the iterable protocol. When an instance of Iterable is used
|
|
47
|
+
* in a `for...of` loop or spread syntax, this generator function is invoked
|
|
48
|
+
* to yield the elements one by one in a synchronous manner.
|
|
49
|
+
*
|
|
50
|
+
* @returns {Generator} A generator that yields each element of the iterable.
|
|
51
|
+
*/
|
|
52
|
+
[Symbol.iterator](): Generator;
|
|
53
|
+
/**
|
|
54
|
+
* Ensures that the constructor of this object instance's name
|
|
55
|
+
* is returned if the string tag for this instance is queried
|
|
56
|
+
*
|
|
57
|
+
* @returns {string} the name of the class
|
|
58
|
+
*/
|
|
59
|
+
get [Symbol.toStringTag](): string;
|
|
60
|
+
#private;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Being able to create a compliant `Iterator` around any type of iterable
|
|
64
|
+
* object. This can be wrapped around any type of object that has a
|
|
65
|
+
* `[Symbol.iterator]` property assigned to a generator function.
|
|
66
|
+
*/
|
|
67
|
+
export class Iterator {
|
|
68
|
+
/**
|
|
69
|
+
* Creates a new `Iterator` object instance.
|
|
70
|
+
*
|
|
71
|
+
* @param {object} iterable any object that has a `[Symbol.iterator]`
|
|
72
|
+
* property assigned to a generator function.
|
|
73
|
+
* @param {function} mapEach when provided `mapEach` is a callback that
|
|
74
|
+
* takes an entry as input and receives one as output.
|
|
75
|
+
*/
|
|
76
|
+
constructor(iterable: object, mapEach: Function);
|
|
77
|
+
/**
|
|
78
|
+
* Returns a new `Array` derived from the iterable this object
|
|
79
|
+
* wraps.
|
|
80
|
+
*
|
|
81
|
+
* @returns {array} a new `Array` generated from the wrapped
|
|
82
|
+
* iterable. The method is generated from `Array.from()`
|
|
83
|
+
*/
|
|
84
|
+
get asArray(): array;
|
|
85
|
+
/**
|
|
86
|
+
* Returns the actual iterable object passed to the constructor that
|
|
87
|
+
* created this instance.
|
|
88
|
+
*
|
|
89
|
+
* @returns {object} the object containing the `[Symbol.iterator]`
|
|
90
|
+
*/
|
|
91
|
+
get iterable(): object;
|
|
92
|
+
/**
|
|
93
|
+
* The function retrieves the next value in the iterator. If the
|
|
94
|
+
* the iterator has run its course, `reset()` can be invoked to
|
|
95
|
+
* reset the pointer to the beginning of the iteration.
|
|
96
|
+
*
|
|
97
|
+
* @returns {any} the next value
|
|
98
|
+
*/
|
|
99
|
+
next(): any;
|
|
100
|
+
/**
|
|
101
|
+
* Resets the iterator to the beginning allowing it to be
|
|
102
|
+
* iterated over again.
|
|
103
|
+
*/
|
|
104
|
+
reset(): void;
|
|
105
|
+
/**
|
|
106
|
+
* The existence of this symbol on the object instances, indicates that
|
|
107
|
+
* it can be used in `for(.. of ..)` loops and its values can be
|
|
108
|
+
* extracted from calls to `Array.from()`
|
|
109
|
+
*
|
|
110
|
+
* @returns {Iterator} this is returned since this object is already
|
|
111
|
+
* conforming to the expected JavaScript Iterator interface
|
|
112
|
+
*/
|
|
113
|
+
[Symbol.iterator](): Iterator;
|
|
114
|
+
/**
|
|
115
|
+
* Ensures that the constructor of this object instance's name
|
|
116
|
+
* is returned if the string tag for this instance is queried
|
|
117
|
+
*
|
|
118
|
+
* @returns {string} the name of the class
|
|
119
|
+
*/
|
|
120
|
+
get [Symbol.toStringTag](): string;
|
|
121
|
+
#private;
|
|
122
|
+
}
|
|
123
|
+
export const IterableExtensions: Extension;
|
|
124
|
+
export const IteratorExtensions: Extension;
|
|
125
|
+
import { Extension } from '@nejs/extension';
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { Extension } from '@nejs/extension';
|
|
2
|
+
/**
|
|
3
|
+
* The Iterable class is designed to provide a convenient way to create synchronous
|
|
4
|
+
* iterable objects. It can be initialized with either an array or individual elements.
|
|
5
|
+
* This class implements the iterable protocol, allowing instances to be used with
|
|
6
|
+
* `for...of` loops and other standard JavaScript iteration mechanisms.
|
|
7
|
+
*/
|
|
8
|
+
export class Iterable {
|
|
9
|
+
/**
|
|
10
|
+
* Private field to store the elements of the iterable.
|
|
11
|
+
* @private
|
|
12
|
+
*/
|
|
13
|
+
#elements = [];
|
|
14
|
+
/**
|
|
15
|
+
* Constructs an instance of Iterable. It can be initialized with either an
|
|
16
|
+
* iterable object (such as an array, Set, Map, string, or any object
|
|
17
|
+
* implementing the iterable protocol) or individual elements. If the first
|
|
18
|
+
* argument is an iterable, the class instance is initialized with the
|
|
19
|
+
* elements from the iterable, followed by any additional arguments. If the
|
|
20
|
+
* first argument is not an iterable, all arguments are treated as individual
|
|
21
|
+
* elements.
|
|
22
|
+
*
|
|
23
|
+
* @param {Iterable|*} elementsOrFirstElement - An iterable object or the
|
|
24
|
+
* first element.
|
|
25
|
+
* @param {...*} moreElements - Additional elements if the first argument is
|
|
26
|
+
* not an iterable.
|
|
27
|
+
*/
|
|
28
|
+
constructor(elementsOrFirstElement, ...moreElements) {
|
|
29
|
+
if (elementsOrFirstElement != null &&
|
|
30
|
+
typeof elementsOrFirstElement[Symbol.iterator] === 'function') {
|
|
31
|
+
this.#elements = [...elementsOrFirstElement, ...moreElements];
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this.#elements = [elementsOrFirstElement, ...moreElements];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Implements the iterable protocol. When an instance of Iterable is used
|
|
39
|
+
* in a `for...of` loop or spread syntax, this generator function is invoked
|
|
40
|
+
* to yield the elements one by one in a synchronous manner.
|
|
41
|
+
*
|
|
42
|
+
* @returns {Generator} A generator that yields each element of the iterable.
|
|
43
|
+
*/
|
|
44
|
+
*[Symbol.iterator]() {
|
|
45
|
+
for (const element of this.#elements) {
|
|
46
|
+
yield element;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Provides access to the elements as a standard array. Useful for scenarios
|
|
51
|
+
* where array methods and behaviors are needed.
|
|
52
|
+
*
|
|
53
|
+
* @returns {Array} An array containing all the elements of the iterable.
|
|
54
|
+
*/
|
|
55
|
+
get asArray() {
|
|
56
|
+
return this.#elements;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Ensures that the constructor of this object instance's name
|
|
60
|
+
* is returned if the string tag for this instance is queried
|
|
61
|
+
*
|
|
62
|
+
* @returns {string} the name of the class
|
|
63
|
+
*/
|
|
64
|
+
get [Symbol.toStringTag]() {
|
|
65
|
+
return this.constructor.name;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Checks if a given value is an iterable. This method determines if the
|
|
69
|
+
* provided value has a `Symbol.iterator` property that is a generator
|
|
70
|
+
* function. It's a precise way to identify if the value conforms to the
|
|
71
|
+
* iterable protocol using a generator function.
|
|
72
|
+
*
|
|
73
|
+
* Note: This method specifically checks for generator functions. Some
|
|
74
|
+
* iterables might use regular functions that return an iterator, which
|
|
75
|
+
* this method won't identify.
|
|
76
|
+
*
|
|
77
|
+
* @param {*} value - The value to be checked for iterability.
|
|
78
|
+
* @returns {boolean} - Returns true if the value is an iterable implemented
|
|
79
|
+
* using a generator function, false otherwise.
|
|
80
|
+
*/
|
|
81
|
+
static isIterable(value) {
|
|
82
|
+
const type = Object.prototype.toString.call(value?.[Symbol.iterator]);
|
|
83
|
+
return type === '[object GeneratorFunction]';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Being able to create a compliant `Iterator` around any type of iterable
|
|
88
|
+
* object. This can be wrapped around any type of object that has a
|
|
89
|
+
* `[Symbol.iterator]` property assigned to a generator function.
|
|
90
|
+
*/
|
|
91
|
+
export class Iterator {
|
|
92
|
+
/**
|
|
93
|
+
* A private function that when provided has the following signature:
|
|
94
|
+
* `function mapEach(entry) -> entry`. This allows any changes to be made
|
|
95
|
+
* to each element, conditionally and programmatically, as needed before
|
|
96
|
+
* they are returned to the called code.
|
|
97
|
+
*/
|
|
98
|
+
#mapEach = undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Creates a new `Iterator` object instance.
|
|
101
|
+
*
|
|
102
|
+
* @param {object} iterable any object that has a `[Symbol.iterator]`
|
|
103
|
+
* property assigned to a generator function.
|
|
104
|
+
* @param {function} mapEach when provided `mapEach` is a callback that
|
|
105
|
+
* takes an entry as input and receives one as output.
|
|
106
|
+
*/
|
|
107
|
+
constructor(iterable, mapEach) {
|
|
108
|
+
if (!iterable || !Reflect.has(iterable, Symbol.iterator)) {
|
|
109
|
+
throw new TypeError('Value used to instantiate Iterator is not iterable');
|
|
110
|
+
}
|
|
111
|
+
this.#iterable = iterable;
|
|
112
|
+
this.#iterator = iterable[Symbol.iterator]();
|
|
113
|
+
this.#mapEach = typeof mapEach === 'function' ? mapEach : undefined;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Returns a new `Array` derived from the iterable this object
|
|
117
|
+
* wraps.
|
|
118
|
+
*
|
|
119
|
+
* @returns {array} a new `Array` generated from the wrapped
|
|
120
|
+
* iterable. The method is generated from `Array.from()`
|
|
121
|
+
*/
|
|
122
|
+
get asArray() {
|
|
123
|
+
return Array.from(this.#iterable);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Returns the actual iterable object passed to the constructor that
|
|
127
|
+
* created this instance.
|
|
128
|
+
*
|
|
129
|
+
* @returns {object} the object containing the `[Symbol.iterator]`
|
|
130
|
+
*/
|
|
131
|
+
get iterable() {
|
|
132
|
+
return this.#iterable;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The function retrieves the next value in the iterator. If the
|
|
136
|
+
* the iterator has run its course, `reset()` can be invoked to
|
|
137
|
+
* reset the pointer to the beginning of the iteration.
|
|
138
|
+
*
|
|
139
|
+
* @returns {any} the next value
|
|
140
|
+
*/
|
|
141
|
+
next() {
|
|
142
|
+
const input = this.#iterator.next();
|
|
143
|
+
let output = input;
|
|
144
|
+
if (output.done) {
|
|
145
|
+
return { value: undefined, done: true };
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
if (this.#mapEach && typeof this.#mapEach === 'function') {
|
|
149
|
+
output.value = this.#mapEach(input.value);
|
|
150
|
+
}
|
|
151
|
+
return { value: output.value, done: false };
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Resets the iterator to the beginning allowing it to be
|
|
156
|
+
* iterated over again.
|
|
157
|
+
*/
|
|
158
|
+
reset() {
|
|
159
|
+
this.#iterator = this.#iterable[Symbol.iterator]();
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* The existence of this symbol on the object instances, indicates that
|
|
163
|
+
* it can be used in `for(.. of ..)` loops and its values can be
|
|
164
|
+
* extracted from calls to `Array.from()`
|
|
165
|
+
*
|
|
166
|
+
* @returns {Iterator} this is returned since this object is already
|
|
167
|
+
* conforming to the expected JavaScript Iterator interface
|
|
168
|
+
*/
|
|
169
|
+
[Symbol.iterator]() {
|
|
170
|
+
return this;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Ensures that the constructor of this object instance's name
|
|
174
|
+
* is returned if the string tag for this instance is queried
|
|
175
|
+
*
|
|
176
|
+
* @returns {string} the name of the class
|
|
177
|
+
*/
|
|
178
|
+
get [Symbol.toStringTag]() {
|
|
179
|
+
return this.constructor.name;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* The object from which its iterator functionality is derived.
|
|
183
|
+
*
|
|
184
|
+
* @type {object}
|
|
185
|
+
* @private
|
|
186
|
+
*/
|
|
187
|
+
#iterable = null;
|
|
188
|
+
/**
|
|
189
|
+
* The results of a call to the iterable's `[Symbol.iterator]`
|
|
190
|
+
* generator function.
|
|
191
|
+
*
|
|
192
|
+
* @type {object}
|
|
193
|
+
* @private
|
|
194
|
+
*/
|
|
195
|
+
#iterator = null;
|
|
196
|
+
}
|
|
197
|
+
export const IterableExtensions = new Extension(Iterable);
|
|
198
|
+
export const IteratorExtensions = new Extension(Iterator);
|
|
199
|
+
//# sourceMappingURL=iterable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iterable.js","sourceRoot":"","sources":["../../../src/newClasses/iterable.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C;;;;;GAKG;AACH,MAAM,OAAO,QAAQ;IACnB;;;OAGG;IACH,SAAS,GAAG,EAAE,CAAC;IAEf;;;;;;;;;;;;;OAaG;IACH,YAAY,sBAAsB,EAAE,GAAG,YAAY;QACjD,IACE,sBAAsB,IAAI,IAAI;YAC9B,OAAO,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,UAAU,EAC7D,CAAC;YACD,IAAI,CAAC,SAAS,GAAG,CAAC,GAAG,sBAAsB,EAAE,GAAG,YAAY,CAAC,CAAC;QAChE,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,SAAS,GAAG,CAAC,sBAAsB,EAAE,GAAG,YAAY,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACH,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;QAChB,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACrC,MAAM,OAAO,CAAC;QAChB,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAA;IAC9B,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,UAAU,CAAC,KAAK;QACrB,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,MAAM,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C,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;YAC3C,CAAC;YAED,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAC9C,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,KAAK;QACH,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IACrD,CAAC;IAED;;;;;;;OAOG;IACH,CAAC,MAAM,CAAC,QAAQ,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAA;IAC9B,CAAC;IAED;;;;;OAKG;IACH,SAAS,GAAG,IAAI,CAAC;IAEjB;;;;;;OAMG;IACH,SAAS,GAAG,IAAI,CAAC;CAClB;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,SAAS,CAAC,QAAQ,CAAC,CAAA;AACzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,SAAS,CAAC,QAAQ,CAAC,CAAA"}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RefMap class extends the standard Map object to manage a collection of
|
|
3
|
+
* WeakRef values mapped to strong keys. It provides additional functionality
|
|
4
|
+
* such as objectification of values and various utility methods.
|
|
5
|
+
*
|
|
6
|
+
* Unlike standard Maps or Objects, RefMap stores weak references to objects,
|
|
7
|
+
* allowing them to be garbage-collected if there are no other references to
|
|
8
|
+
* them. This behavior is different from Maps and standard Objects, which
|
|
9
|
+
* maintain strong references to their elements.
|
|
10
|
+
*
|
|
11
|
+
* @extends Map
|
|
12
|
+
*/
|
|
13
|
+
export class RefMap extends Map<any, any> {
|
|
14
|
+
constructor(...args: any[]);
|
|
15
|
+
/**
|
|
16
|
+
* Method to control whether the RefMap should objectify its values. When
|
|
17
|
+
* objectifying, primitive values (number, string, boolean, bigint) are
|
|
18
|
+
* converted to their respective object types, which allows them to be used as
|
|
19
|
+
* WeakRef targets.
|
|
20
|
+
*
|
|
21
|
+
* @param {boolean} setObjectification - Flag to enable or disable
|
|
22
|
+
* objectification.
|
|
23
|
+
* @returns {RefMap} - The current RefMap instance to allow method chaining.
|
|
24
|
+
*/
|
|
25
|
+
objectifying(setObjectification?: boolean): RefMap;
|
|
26
|
+
/**
|
|
27
|
+
* Setting this value to true, will cause all set values to the Map to
|
|
28
|
+
* be analyzed for validity as a candidate to be wrapped in a `WeakRef`
|
|
29
|
+
* object. If true, and if possible, the object will be turned into an
|
|
30
|
+
* `Object` variant first.
|
|
31
|
+
*
|
|
32
|
+
* @param {boolean} value - The new state to set for objectifyValues.
|
|
33
|
+
*/
|
|
34
|
+
set objectifyValues(value: boolean);
|
|
35
|
+
/**
|
|
36
|
+
* Returns the state indicating whether or not `RefMap` will attempt to
|
|
37
|
+
* convert non-valid primitives into targets that are valid input for
|
|
38
|
+
* new `WeakRef` object instances. If this value is `false` then no
|
|
39
|
+
* *objectification* will occur.
|
|
40
|
+
*
|
|
41
|
+
* @returns {boolean} The current state of objectifyValues.
|
|
42
|
+
*/
|
|
43
|
+
get objectifyValues(): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* The function converts a JavaScript Map object into a regular JavaScript
|
|
46
|
+
* object, handling invalid keys by converting them to strings.
|
|
47
|
+
*
|
|
48
|
+
* @returns {object} an object; keys that are not either a `String` or a
|
|
49
|
+
* `Symbol` will be converted to a string.
|
|
50
|
+
*/
|
|
51
|
+
asObject(): object;
|
|
52
|
+
/**
|
|
53
|
+
* The `get` function retrieves a value from a map and returns it, or returns a
|
|
54
|
+
* default value if the value is null or undefined. The actual retrieved value
|
|
55
|
+
* is a dereferenced `WeakRef`. If the result is `undefined` and this is not the
|
|
56
|
+
* expected response, it is likely the value has been garbage collected.
|
|
57
|
+
*
|
|
58
|
+
* @param {any} key - The key parameter is the key of the value you want to
|
|
59
|
+
* retrieve from the data structure.
|
|
60
|
+
* @param {any} defaultValue - The `defaultValue` parameter is the value that
|
|
61
|
+
* will be returned if the key does not exist in the map or if the value
|
|
62
|
+
* associated with the key has been garbage collected (i.e., it no longer
|
|
63
|
+
* exists).
|
|
64
|
+
* @returns The method is returning the value associated with the given key.
|
|
65
|
+
* If the value is not found or if it has been garbage collected (deref()
|
|
66
|
+
* returns null), then the defaultValue is returned.
|
|
67
|
+
*/
|
|
68
|
+
get(key: any, defaultValue: any): any;
|
|
69
|
+
/**
|
|
70
|
+
* Overrides the set method of `Map`. Adds a value to the `RefMap`,
|
|
71
|
+
* converting it to a `WeakRef`. Throws an error if the value is not a
|
|
72
|
+
* valid `WeakRef` target (e.g., `null`, `undefined`, or a registered
|
|
73
|
+
* `symbol`). If {@link objectifyValues} is enabled, an attempt to convert
|
|
74
|
+
* primitives to their object variants will be made. These are `numbers`,
|
|
75
|
+
* `strings`, `boolean` values and `bigint`s.
|
|
76
|
+
*
|
|
77
|
+
* @param {*} key - The `key` to be set on the `RefMap`
|
|
78
|
+
* @param {*} value - The value to be associated with the `key`
|
|
79
|
+
* @throws {TypeError} If the value is not a valid WeakRef target.
|
|
80
|
+
*/
|
|
81
|
+
set(key: any, value: any): void;
|
|
82
|
+
/**
|
|
83
|
+
* Sets multiple values at a single time. The format is an array of array
|
|
84
|
+
* or rather an array of {@link Object.entries} (for example,
|
|
85
|
+
* `[[key1,value1], [key2,value2]]`). For each entry pair, if the length
|
|
86
|
+
* is not 2, either missing a key or value, it will be skipped.
|
|
87
|
+
*
|
|
88
|
+
* @param {Iterable} values - An iterable of values to add to the RefMap.
|
|
89
|
+
* @throws {TypeError} If the supplied values are falsey or non-iterable.
|
|
90
|
+
* @returns {RepMap} returns `this` to allow for chaining
|
|
91
|
+
*/
|
|
92
|
+
setAll(entries: any): RepMap;
|
|
93
|
+
/**
|
|
94
|
+
* Removes all elements from the RefMap that have been garbage collected
|
|
95
|
+
* (i.e., their WeakRef no longer points to an object).
|
|
96
|
+
*
|
|
97
|
+
* @returns {RefMap} - The current RefMap instance to allow method chaining.
|
|
98
|
+
*/
|
|
99
|
+
clean(): RefMap;
|
|
100
|
+
/**
|
|
101
|
+
* Executes a provided function once for each value in the RefMap. The callback
|
|
102
|
+
* function receives the dereferenced value, the value again (as RefMap doesn't
|
|
103
|
+
* use keys), and the RefMap itself. This method provides a way to iterate over
|
|
104
|
+
* and apply operations to the values stored in the RefMap, taking into account
|
|
105
|
+
* that they are weak references and may have been garbage-collected.
|
|
106
|
+
*
|
|
107
|
+
* @param {Function} forEachFn - Function to execute for each element. It
|
|
108
|
+
* takes three arguments: element, element (again, as RefMap has no key), and
|
|
109
|
+
* the RefMap itself.
|
|
110
|
+
* @param {*} thisArg - Value to use as `this` when executing `forEachFn`.
|
|
111
|
+
*/
|
|
112
|
+
entries(): Iterator;
|
|
113
|
+
/**
|
|
114
|
+
* Iterate over the items in the map and pass them to the supplied
|
|
115
|
+
* function ala `Map.prototype.forEach`. Note however, there are no
|
|
116
|
+
* indexes on Maps and as such, the index parameter of the callback
|
|
117
|
+
* will always be the value's key. Subsequently the `array` or third
|
|
118
|
+
* parameter will receive the map instance rather than an array.
|
|
119
|
+
*
|
|
120
|
+
* @param {function} forEachFn the function to use for each element in
|
|
121
|
+
* the set.
|
|
122
|
+
* @param {object} thisArg the `this` argument to be applied to each
|
|
123
|
+
* invocation of the `forEachFn` callback. Note, this value is unable
|
|
124
|
+
* to be applied if the `forEachFn` is a big arrow function
|
|
125
|
+
*/
|
|
126
|
+
forEach(forEachFn: Function, thisArg: object): void;
|
|
127
|
+
/**
|
|
128
|
+
* Returns an iterator for the values in the RefMap. Each value is
|
|
129
|
+
* dereferenced from its WeakRef before being returned. This method allows
|
|
130
|
+
* iterating over he set's values, similar to how one would iterate over
|
|
131
|
+
* values in a standard Map or Array, but with the understanding that the
|
|
132
|
+
* values are weakly referenced and may no longer exist (in which case
|
|
133
|
+
* they are skipped).
|
|
134
|
+
*
|
|
135
|
+
* @returns {Iterator} An iterator for the values.
|
|
136
|
+
*/
|
|
137
|
+
values(): Iterator;
|
|
138
|
+
/**
|
|
139
|
+
* Determines whether an element with the specified value exists in the
|
|
140
|
+
* `RefMap`. For non-objectified sets, this method checks if the dereferenced
|
|
141
|
+
* values of the map include the specified value.
|
|
142
|
+
*
|
|
143
|
+
* For objectified sets, strict is set to false which uses loose
|
|
144
|
+
* equality to allow for things like `Object(5)` to equal `5`. This is important
|
|
145
|
+
* because otherwise primitives could not be weakly referenced. In the grand
|
|
146
|
+
* scheme of things, this is only useful if the objectified value is the
|
|
147
|
+
* one being referenced.
|
|
148
|
+
*
|
|
149
|
+
* @param {*} value - The value to check for presence in the RefMap.
|
|
150
|
+
* @param {boolean} strict - if `true`, the default, then the supplied value
|
|
151
|
+
* is hard compared to the dereferenced value (`===`). If `false`, then a
|
|
152
|
+
* loose comparison is used (`==`)
|
|
153
|
+
* @returns {boolean} - True if an element with the specified value exists
|
|
154
|
+
* in the RefMap, false otherwise.
|
|
155
|
+
*/
|
|
156
|
+
hasValue(value: any, strict?: boolean): boolean;
|
|
157
|
+
/**
|
|
158
|
+
* The `filter` function filters the entries of a `RefMap` object based on
|
|
159
|
+
* a given filter function. The dereferenced entries of the values of the map
|
|
160
|
+
* will be passed to the function rather than a `WeakRef` itself.
|
|
161
|
+
*
|
|
162
|
+
* A new resulting entry set will be generated and a new `RefMap` will be made
|
|
163
|
+
* from these entries and returned. Note that this function never returns
|
|
164
|
+
* `null`
|
|
165
|
+
*
|
|
166
|
+
* @param {function} filterFn - The `filterFn` parameter is a function that
|
|
167
|
+
* will be used to filter the entries in the `RefMap`. It will be called with
|
|
168
|
+
* three arguments: the value of the current entry, the key of the current
|
|
169
|
+
* entry, and the `RefMap` itself. The function should return `true`
|
|
170
|
+
* @param {object} thisArg - The `thisArg` parameter is an optional argument
|
|
171
|
+
* that specifies the value to be used as `this` when executing the
|
|
172
|
+
* `filterFn` function. It allows you to explicitly set the context in which
|
|
173
|
+
* the `filterFn` function is called. If `thisArg` is not provided, `this
|
|
174
|
+
* @returns {array} The `filter` method is returning an array of filtered map
|
|
175
|
+
* entries
|
|
176
|
+
*/
|
|
177
|
+
filter(filterFn: Function, thisArg: object): array;
|
|
178
|
+
/**
|
|
179
|
+
* The `find` function iterates over a map and calls a given function on
|
|
180
|
+
* each value, returning the first value for which the function returns
|
|
181
|
+
* a truthy value.
|
|
182
|
+
*
|
|
183
|
+
* The function signature of `findFn` is
|
|
184
|
+
* ```
|
|
185
|
+
* function findFn(value, key, map)
|
|
186
|
+
* ```
|
|
187
|
+
* 'value' is passed to findFn up to two times; first with the `WeakRef`
|
|
188
|
+
* value, second with the result of {@link WeakRef.deref}. If `findFn`
|
|
189
|
+
* returns true for either of these the dereferenced value will be
|
|
190
|
+
* returned from the call to {@link RefMap.find}.
|
|
191
|
+
* `key` represents the key object that the value is mapped to.
|
|
192
|
+
* `map` is simply a reference to `this` map.
|
|
193
|
+
*
|
|
194
|
+
* @param findFn - `findFn` is a function that will be called for each
|
|
195
|
+
* element in the map. It takes three arguments: `ref`, `key`, and `map`;
|
|
196
|
+
* where `ref` is the value of the current element in the map, `key` is
|
|
197
|
+
* the key of the current element, and `map` is a reference to the instance
|
|
198
|
+
* being searched.
|
|
199
|
+
* @param thisArg - The `thisArg` parameter is the value to be used as
|
|
200
|
+
* the `this` value when executing the `findFn` function. It allows you
|
|
201
|
+
* to specify the context in which the `findFn` function should be called.
|
|
202
|
+
* @returns the first dereferenced value that satisfies the condition
|
|
203
|
+
* specified by the `findFn` function. If no value satisfies the condition,
|
|
204
|
+
* it returns `null`.
|
|
205
|
+
*/
|
|
206
|
+
find(findFn: any, thisArg: any): any;
|
|
207
|
+
/**
|
|
208
|
+
* Creates a new array or `RefMap` with the results of calling a provided
|
|
209
|
+
* function on every element in the calling `RefMap`. This method dereferences
|
|
210
|
+
* each value, applies the `mapFn`, and collects the results. If `toRefMap` is
|
|
211
|
+
* `true`, a new `RefMap` is returned; otherwise, an array. This method
|
|
212
|
+
* differs from `Array.map` in handling weak references and the potential to
|
|
213
|
+
* return a new `RefMap` instead of an array.
|
|
214
|
+
*
|
|
215
|
+
* @param {Function} mapFn - Function that produces an element of the new
|
|
216
|
+
* array or `RefMap`, taking three arguments.
|
|
217
|
+
* @param {*} thisArg - Value to use as this when executing mapFn.
|
|
218
|
+
* @param {boolean} toRefMap - Determines if the output should be a new
|
|
219
|
+
* `RefMap` (`true`) or an array (`false`).
|
|
220
|
+
* @param {boolean} mirrorObjectification - If `true` and `toRefMap` is
|
|
221
|
+
* `true`, the new `RefMap` mirrors the objectification setting of the
|
|
222
|
+
* original.
|
|
223
|
+
* @returns {Array|RefMap} - A new array or `RefMap` with each element being
|
|
224
|
+
* the result of the `mapFn`.
|
|
225
|
+
*/
|
|
226
|
+
map(mapFn: Function, thisArg: any, toRefMap: boolean, mirrorObjectification: boolean): any[] | RefMap;
|
|
227
|
+
/**
|
|
228
|
+
* The function returns an iterator that iterates over the entries of an object,
|
|
229
|
+
* dereferencing any weak references.
|
|
230
|
+
*
|
|
231
|
+
* @returns {Iterator} A new iterator object is being returned.
|
|
232
|
+
*/
|
|
233
|
+
[Symbol.iterator](): Iterator;
|
|
234
|
+
#private;
|
|
235
|
+
}
|
|
236
|
+
export const RefMapExtensions: Extension;
|
|
237
|
+
import { Iterator } from './iterable.js';
|
|
238
|
+
import { Extension } from '@nejs/extension';
|