@nejs/basic-extensions 2.21.0 → 2.22.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/markdown.xml +8 -0
- package/.idea/modules.xml +8 -0
- package/.idea/ne-basic-extensions.iml +8 -0
- package/.idea/vcs.xml +6 -0
- package/CODE_STYLE.md +393 -0
- package/CODING_PHILOSOPHY.md +36 -0
- package/DOCUMENTATION_GUIDELINES.md +221 -0
- package/README.md +78 -4
- package/dist/@nejs/basic-extensions.bundle.2.22.6.js +25 -0
- package/dist/@nejs/basic-extensions.bundle.2.22.6.js.map +7 -0
- package/dist/cjs/classes/index.cjs +11129 -0
- package/dist/cjs/classes/index.cjs.map +7 -0
- package/dist/cjs/index.cjs +15191 -0
- package/dist/cjs/index.cjs.map +7 -0
- package/dist/cjs/utils/index.cjs +3954 -0
- package/dist/cjs/utils/index.cjs.map +7 -0
- package/dist/esm/basic-extensions.mjs +25 -0
- package/dist/esm/basic-extensions.mjs.map +7 -0
- package/package.json +16 -22
- package/repl.bootstrap.js +4 -7
- package/repl.history +30 -30
- package/src/big.int.extension.js +171 -45
- package/src/classes/enumeration.js +466 -0
- package/src/classes/index.js +5 -1
- package/src/index.js +5 -1
- package/src/math.extension.js +73 -0
- package/src/number.extension.js +18 -0
- package/src/regular.expression.extensions.js +0 -35
- package/src/utils/toolkit.js +699 -516
- package/tests/arrayextensions.test.js +3 -3
- package/tests/index.test.js +3 -1
- package/tests/newClasses/asyncIterable.test.js +3 -3
- package/tests/newClasses/deferred.test.js +3 -3
- package/tests/newClasses/descriptor.test.js +3 -3
- package/tests/newClasses/iterable.test.js +3 -3
- package/tests/newClasses/refmap.test.js +3 -3
- package/tests/newClasses/refset.test.js +3 -3
- package/tests/objectextensions.test.js +3 -3
- package/tests/setextensions.test.js +3 -3
- package/tests/stringextensions.test.js +3 -2
- package/tests/utils/descriptor.utils.test.js +1 -1
- package/tests/utils/toolkit.test.js +429 -163
- package/.esdoc.json +0 -9
- package/.vscode/settings.json +0 -5
- package/bin/build +0 -27
- package/bin/clean +0 -14
- package/bin/esbuild +0 -91
- package/bin/fixup +0 -13
- package/bin/repl.basics.js +0 -584
- package/bin/repl.signature.js +0 -63
- package/bin/version +0 -100
- package/dist/@nejs/basic-extensions.bundle.2.21.0.js +0 -25
- package/dist/@nejs/basic-extensions.bundle.2.21.0.js.map +0 -7
- package/dist/cjs/array.extensions.d.ts +0 -39
- package/dist/cjs/array.extensions.js +0 -477
- package/dist/cjs/array.extensions.js.map +0 -1
- package/dist/cjs/big.int.extension.d.ts +0 -31
- package/dist/cjs/big.int.extension.js +0 -165
- package/dist/cjs/big.int.extension.js.map +0 -1
- package/dist/cjs/classes/asyncIterable.d.ts +0 -126
- package/dist/cjs/classes/asyncIterable.js +0 -209
- package/dist/cjs/classes/asyncIterable.js.map +0 -1
- package/dist/cjs/classes/deferred.d.ts +0 -146
- package/dist/cjs/classes/deferred.js +0 -291
- package/dist/cjs/classes/deferred.js.map +0 -1
- package/dist/cjs/classes/descriptor.d.ts +0 -334
- package/dist/cjs/classes/descriptor.js +0 -537
- package/dist/cjs/classes/descriptor.js.map +0 -1
- package/dist/cjs/classes/enum.d.ts +0 -50
- package/dist/cjs/classes/enum.js +0 -405
- package/dist/cjs/classes/enum.js.map +0 -1
- package/dist/cjs/classes/index.d.ts +0 -15
- package/dist/cjs/classes/index.js +0 -63
- package/dist/cjs/classes/index.js.map +0 -1
- package/dist/cjs/classes/introspector.d.ts +0 -20
- package/dist/cjs/classes/introspector.js +0 -130
- package/dist/cjs/classes/introspector.js.map +0 -1
- package/dist/cjs/classes/iterable.d.ts +0 -169
- package/dist/cjs/classes/iterable.js +0 -268
- package/dist/cjs/classes/iterable.js.map +0 -1
- package/dist/cjs/classes/param.parser.d.ts +0 -221
- package/dist/cjs/classes/param.parser.js +0 -242
- package/dist/cjs/classes/param.parser.js.map +0 -1
- package/dist/cjs/classes/pluggable.proxy.d.ts +0 -153
- package/dist/cjs/classes/pluggable.proxy.js +0 -444
- package/dist/cjs/classes/pluggable.proxy.js.map +0 -1
- package/dist/cjs/classes/property.d.ts +0 -79
- package/dist/cjs/classes/property.js +0 -284
- package/dist/cjs/classes/property.js.map +0 -1
- package/dist/cjs/classes/refmap.d.ts +0 -238
- package/dist/cjs/classes/refmap.js +0 -421
- package/dist/cjs/classes/refmap.js.map +0 -1
- package/dist/cjs/classes/refset.d.ts +0 -186
- package/dist/cjs/classes/refset.js +0 -370
- package/dist/cjs/classes/refset.js.map +0 -1
- package/dist/cjs/classes/symkeys.d.ts +0 -349
- package/dist/cjs/classes/symkeys.js +0 -510
- package/dist/cjs/classes/symkeys.js.map +0 -1
- package/dist/cjs/classes/type.d.ts +0 -56
- package/dist/cjs/classes/type.js +0 -405
- package/dist/cjs/classes/type.js.map +0 -1
- package/dist/cjs/function.extensions.d.ts +0 -12
- package/dist/cjs/function.extensions.js +0 -758
- package/dist/cjs/function.extensions.js.map +0 -1
- package/dist/cjs/global.this.d.ts +0 -2
- package/dist/cjs/global.this.js +0 -300
- package/dist/cjs/global.this.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -31
- package/dist/cjs/index.js +0 -226
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/json.extensions.d.ts +0 -2
- package/dist/cjs/json.extensions.js +0 -109
- package/dist/cjs/json.extensions.js.map +0 -1
- package/dist/cjs/map.extensions.d.ts +0 -3
- package/dist/cjs/map.extensions.js +0 -143
- package/dist/cjs/map.extensions.js.map +0 -1
- package/dist/cjs/number.extension.d.ts +0 -44
- package/dist/cjs/number.extension.js +0 -261
- package/dist/cjs/number.extension.js.map +0 -1
- package/dist/cjs/object.extensions.d.ts +0 -33
- package/dist/cjs/object.extensions.js +0 -1091
- package/dist/cjs/object.extensions.js.map +0 -1
- package/dist/cjs/package.json +0 -3
- package/dist/cjs/proxy.extensions.d.ts +0 -2
- package/dist/cjs/proxy.extensions.js +0 -207
- package/dist/cjs/proxy.extensions.js.map +0 -1
- package/dist/cjs/reflect.extensions.d.ts +0 -14
- package/dist/cjs/reflect.extensions.js +0 -316
- package/dist/cjs/reflect.extensions.js.map +0 -1
- package/dist/cjs/regular.expression.extensions.d.ts +0 -2
- package/dist/cjs/regular.expression.extensions.js +0 -423
- package/dist/cjs/regular.expression.extensions.js.map +0 -1
- package/dist/cjs/set.extensions.d.ts +0 -40
- package/dist/cjs/set.extensions.js +0 -355
- package/dist/cjs/set.extensions.js.map +0 -1
- package/dist/cjs/string.extensions.d.ts +0 -23
- package/dist/cjs/string.extensions.js +0 -704
- package/dist/cjs/string.extensions.js.map +0 -1
- package/dist/cjs/symbol.extensions.d.ts +0 -11
- package/dist/cjs/symbol.extensions.js +0 -735
- package/dist/cjs/symbol.extensions.js.map +0 -1
- package/dist/cjs/utils/copy.object.d.ts +0 -408
- package/dist/cjs/utils/copy.object.js +0 -720
- package/dist/cjs/utils/copy.object.js.map +0 -1
- package/dist/cjs/utils/descriptor.utils.d.ts +0 -298
- package/dist/cjs/utils/descriptor.utils.js +0 -889
- package/dist/cjs/utils/descriptor.utils.js.map +0 -1
- package/dist/cjs/utils/index.d.ts +0 -75
- package/dist/cjs/utils/index.js +0 -61
- package/dist/cjs/utils/index.js.map +0 -1
- package/dist/cjs/utils/stdout.d.ts +0 -742
- package/dist/cjs/utils/stdout.js +0 -1042
- package/dist/cjs/utils/stdout.js.map +0 -1
- package/dist/cjs/utils/toolkit.d.ts +0 -1898
- package/dist/cjs/utils/toolkit.js +0 -1378
- package/dist/cjs/utils/toolkit.js.map +0 -1
- package/dist/cjs/weakref.extensions.d.ts +0 -2
- package/dist/cjs/weakref.extensions.js +0 -19
- package/dist/cjs/weakref.extensions.js.map +0 -1
- package/dist/mjs/array.extensions.d.ts +0 -39
- package/dist/mjs/array.extensions.js +0 -474
- package/dist/mjs/array.extensions.js.map +0 -1
- package/dist/mjs/big.int.extension.d.ts +0 -31
- package/dist/mjs/big.int.extension.js +0 -162
- package/dist/mjs/big.int.extension.js.map +0 -1
- package/dist/mjs/classes/asyncIterable.d.ts +0 -126
- package/dist/mjs/classes/asyncIterable.js +0 -204
- package/dist/mjs/classes/asyncIterable.js.map +0 -1
- package/dist/mjs/classes/deferred.d.ts +0 -146
- package/dist/mjs/classes/deferred.js +0 -287
- package/dist/mjs/classes/deferred.js.map +0 -1
- package/dist/mjs/classes/descriptor.d.ts +0 -334
- package/dist/mjs/classes/descriptor.js +0 -533
- package/dist/mjs/classes/descriptor.js.map +0 -1
- package/dist/mjs/classes/enum.d.ts +0 -50
- package/dist/mjs/classes/enum.js +0 -400
- package/dist/mjs/classes/enum.js.map +0 -1
- package/dist/mjs/classes/index.d.ts +0 -15
- package/dist/mjs/classes/index.js +0 -46
- package/dist/mjs/classes/index.js.map +0 -1
- package/dist/mjs/classes/introspector.d.ts +0 -20
- package/dist/mjs/classes/introspector.js +0 -126
- package/dist/mjs/classes/introspector.js.map +0 -1
- package/dist/mjs/classes/iterable.d.ts +0 -169
- package/dist/mjs/classes/iterable.js +0 -263
- package/dist/mjs/classes/iterable.js.map +0 -1
- package/dist/mjs/classes/param.parser.d.ts +0 -221
- package/dist/mjs/classes/param.parser.js +0 -238
- package/dist/mjs/classes/param.parser.js.map +0 -1
- package/dist/mjs/classes/pluggable.proxy.d.ts +0 -153
- package/dist/mjs/classes/pluggable.proxy.js +0 -438
- package/dist/mjs/classes/pluggable.proxy.js.map +0 -1
- package/dist/mjs/classes/property.d.ts +0 -79
- package/dist/mjs/classes/property.js +0 -280
- package/dist/mjs/classes/property.js.map +0 -1
- package/dist/mjs/classes/refmap.d.ts +0 -238
- package/dist/mjs/classes/refmap.js +0 -417
- package/dist/mjs/classes/refmap.js.map +0 -1
- package/dist/mjs/classes/refset.d.ts +0 -186
- package/dist/mjs/classes/refset.js +0 -366
- package/dist/mjs/classes/refset.js.map +0 -1
- package/dist/mjs/classes/symkeys.d.ts +0 -349
- package/dist/mjs/classes/symkeys.js +0 -506
- package/dist/mjs/classes/symkeys.js.map +0 -1
- package/dist/mjs/classes/type.d.ts +0 -56
- package/dist/mjs/classes/type.js +0 -401
- package/dist/mjs/classes/type.js.map +0 -1
- package/dist/mjs/function.extensions.d.ts +0 -12
- package/dist/mjs/function.extensions.js +0 -755
- package/dist/mjs/function.extensions.js.map +0 -1
- package/dist/mjs/global.this.d.ts +0 -2
- package/dist/mjs/global.this.js +0 -264
- package/dist/mjs/global.this.js.map +0 -1
- package/dist/mjs/index.d.ts +0 -31
- package/dist/mjs/index.js +0 -204
- package/dist/mjs/index.js.map +0 -1
- package/dist/mjs/json.extensions.d.ts +0 -2
- package/dist/mjs/json.extensions.js +0 -106
- package/dist/mjs/json.extensions.js.map +0 -1
- package/dist/mjs/map.extensions.d.ts +0 -3
- package/dist/mjs/map.extensions.js +0 -140
- package/dist/mjs/map.extensions.js.map +0 -1
- package/dist/mjs/number.extension.d.ts +0 -44
- package/dist/mjs/number.extension.js +0 -258
- package/dist/mjs/number.extension.js.map +0 -1
- package/dist/mjs/object.extensions.d.ts +0 -33
- package/dist/mjs/object.extensions.js +0 -1088
- package/dist/mjs/object.extensions.js.map +0 -1
- package/dist/mjs/package.json +0 -3
- package/dist/mjs/proxy.extensions.d.ts +0 -2
- package/dist/mjs/proxy.extensions.js +0 -204
- package/dist/mjs/proxy.extensions.js.map +0 -1
- package/dist/mjs/reflect.extensions.d.ts +0 -14
- package/dist/mjs/reflect.extensions.js +0 -313
- package/dist/mjs/reflect.extensions.js.map +0 -1
- package/dist/mjs/regular.expression.extensions.d.ts +0 -2
- package/dist/mjs/regular.expression.extensions.js +0 -420
- package/dist/mjs/regular.expression.extensions.js.map +0 -1
- package/dist/mjs/set.extensions.d.ts +0 -40
- package/dist/mjs/set.extensions.js +0 -352
- package/dist/mjs/set.extensions.js.map +0 -1
- package/dist/mjs/string.extensions.d.ts +0 -23
- package/dist/mjs/string.extensions.js +0 -701
- package/dist/mjs/string.extensions.js.map +0 -1
- package/dist/mjs/symbol.extensions.d.ts +0 -11
- package/dist/mjs/symbol.extensions.js +0 -732
- package/dist/mjs/symbol.extensions.js.map +0 -1
- package/dist/mjs/utils/copy.object.d.ts +0 -408
- package/dist/mjs/utils/copy.object.js +0 -702
- package/dist/mjs/utils/copy.object.js.map +0 -1
- package/dist/mjs/utils/descriptor.utils.d.ts +0 -298
- package/dist/mjs/utils/descriptor.utils.js +0 -875
- package/dist/mjs/utils/descriptor.utils.js.map +0 -1
- package/dist/mjs/utils/index.d.ts +0 -75
- package/dist/mjs/utils/index.js +0 -45
- package/dist/mjs/utils/index.js.map +0 -1
- package/dist/mjs/utils/stdout.d.ts +0 -742
- package/dist/mjs/utils/stdout.js +0 -1037
- package/dist/mjs/utils/stdout.js.map +0 -1
- package/dist/mjs/utils/toolkit.d.ts +0 -1898
- package/dist/mjs/utils/toolkit.js +0 -1373
- package/dist/mjs/utils/toolkit.js.map +0 -1
- package/dist/mjs/weakref.extensions.d.ts +0 -2
- package/dist/mjs/weakref.extensions.js +0 -16
- package/dist/mjs/weakref.extensions.js.map +0 -1
- package/jsdoc-config.json +0 -31
- package/tsconfig.base.json +0 -28
- package/tsconfig.cjs.json +0 -8
- package/tsconfig.esm.json +0 -8
- package/vitest.config.js +0 -7
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"introspector.js","sourceRoot":"","sources":["../../../src/classes/introspector.js"],"names":[],"mappings":";;;AAAA,+CAA2C;AAE3C,MAAa,YAAY;IACvB,MAAM,CAAC,YAAY,CAAC,KAAK;QACvB,MAAM,aAAa,GAAG,CAAC,KAAK,GAAG,UAAU,EAAE,EAAE;YAC3C,OAAO,CAAC,WAAW,EAAE,GAAG,EAAE,EAAE;gBAC1B,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC;gBAEjC,IAAI,CAAC;oBACH,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAA;oBACxB,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAA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YACJ,CAAC;SACF,CAAC,CAED,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAClB,QAAQ,CAAA;YACR,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;QAC9D,CAAC,CAAC,CACH,CAAA;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAlKD,oCAkKC;AAEY,QAAA,sBAAsB,GAAG,IAAI,qBAAS,CAAC,YAAY,CAAC,CAAC"}
|
|
@@ -1,169 +0,0 @@
|
|
|
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 an Iterator for the keys of the given object.
|
|
70
|
-
*
|
|
71
|
-
* @note alternatives to keyFetcher might be `Reflect.ownKeys` or even
|
|
72
|
-
* `Object.keys`. Each type of fetcher has their own requirements but
|
|
73
|
-
* any function that takes an object and returns keys will suffice.
|
|
74
|
-
*
|
|
75
|
-
* @param {Object} object - The object whose keys will be iterated.
|
|
76
|
-
* @param {Function} [mapEach] - Optional function to map each key.
|
|
77
|
-
* @param {Function} [keyFetcher=Object.getOwnPropertyNames] - Function to
|
|
78
|
-
* fetch keys from the object. Defaults to Object.getOwnPropertyNames.
|
|
79
|
-
* @returns {Iterator} An Iterator instance containing the object's keys.
|
|
80
|
-
*/
|
|
81
|
-
static keys(object: Object, mapEach?: Function, keyFetcher?: Function): Iterator;
|
|
82
|
-
/**
|
|
83
|
-
* Creates an Iterator for the entries of the given object.
|
|
84
|
-
*
|
|
85
|
-
* @note alternatives to keyFetcher might be `Reflect.ownKeys` or even
|
|
86
|
-
* `Object.keys`. Each type of fetcher has their own requirements but
|
|
87
|
-
* any function that takes an object and returns keys will suffice.
|
|
88
|
-
*
|
|
89
|
-
* @param {Object} object - The object whose entries will be iterated.
|
|
90
|
-
* @param {Function} [mapEach] - Optional function to map each entry.
|
|
91
|
-
* @param {Function} [keyFetcher=Object.getOwnPropertyNames] - Function to
|
|
92
|
-
* fetch keys from the object. Defaults to Object.getOwnPropertyNames.
|
|
93
|
-
* @returns {Iterator} An Iterator instance containing the object's entries.
|
|
94
|
-
*/
|
|
95
|
-
static entries(object: Object, mapEach?: Function, keyFetcher?: Function): Iterator;
|
|
96
|
-
/**
|
|
97
|
-
* Creates an Iterator for the property descriptors of the given object.
|
|
98
|
-
*
|
|
99
|
-
* @note alternatives to keyFetcher might be `Reflect.ownKeys` or even
|
|
100
|
-
* `Object.keys`. Each type of fetcher has their own requirements but
|
|
101
|
-
* any function that takes an object and returns keys will suffice.
|
|
102
|
-
*
|
|
103
|
-
* @param {Object} object - The object whose descriptors will be iterated.
|
|
104
|
-
* @param {Function} [mapEach] - Optional function to map each descriptor
|
|
105
|
-
* entry.
|
|
106
|
-
* @param {Function} [keyFetcher=Object.getOwnPropertyNames] - Function to
|
|
107
|
-
* fetch keys from the object. Defaults to Object.getOwnPropertyNames.
|
|
108
|
-
* @returns {Iterator} An Iterator instance containing entries of [key,
|
|
109
|
-
* descriptor] pairs.
|
|
110
|
-
*/
|
|
111
|
-
static descriptors(object: Object, mapEach?: Function, keyFetcher?: Function): Iterator;
|
|
112
|
-
/**
|
|
113
|
-
* Creates a new `Iterator` object instance.
|
|
114
|
-
*
|
|
115
|
-
* @param {object} iterable any object that has a `[Symbol.iterator]`
|
|
116
|
-
* property assigned to a generator function.
|
|
117
|
-
* @param {function} mapEach when provided `mapEach` is a callback that
|
|
118
|
-
* takes an entry as input and receives one as output.
|
|
119
|
-
*/
|
|
120
|
-
constructor(iterable: object, mapEach: Function);
|
|
121
|
-
/**
|
|
122
|
-
* Returns a new `Array` derived from the iterable this object
|
|
123
|
-
* wraps.
|
|
124
|
-
*
|
|
125
|
-
* @returns {array} a new `Array` generated from the wrapped
|
|
126
|
-
* iterable. The method is generated from `Array.from()`
|
|
127
|
-
*/
|
|
128
|
-
get asArray(): array;
|
|
129
|
-
/**
|
|
130
|
-
* Returns the actual iterable object passed to the constructor that
|
|
131
|
-
* created this instance.
|
|
132
|
-
*
|
|
133
|
-
* @returns {object} the object containing the `[Symbol.iterator]`
|
|
134
|
-
*/
|
|
135
|
-
get iterable(): object;
|
|
136
|
-
/**
|
|
137
|
-
* The function retrieves the next value in the iterator. If the
|
|
138
|
-
* the iterator has run its course, `reset()` can be invoked to
|
|
139
|
-
* reset the pointer to the beginning of the iteration.
|
|
140
|
-
*
|
|
141
|
-
* @returns {any} the next value
|
|
142
|
-
*/
|
|
143
|
-
next(): any;
|
|
144
|
-
/**
|
|
145
|
-
* Resets the iterator to the beginning allowing it to be
|
|
146
|
-
* iterated over again.
|
|
147
|
-
*/
|
|
148
|
-
reset(): void;
|
|
149
|
-
/**
|
|
150
|
-
* The existence of this symbol on the object instances, indicates that
|
|
151
|
-
* it can be used in `for(.. of ..)` loops and its values can be
|
|
152
|
-
* extracted from calls to `Array.from()`
|
|
153
|
-
*
|
|
154
|
-
* @returns {Iterator} this is returned since this object is already
|
|
155
|
-
* conforming to the expected JavaScript Iterator interface
|
|
156
|
-
*/
|
|
157
|
-
[Symbol.iterator](): Iterator;
|
|
158
|
-
/**
|
|
159
|
-
* Ensures that the constructor of this object instance's name
|
|
160
|
-
* is returned if the string tag for this instance is queried
|
|
161
|
-
*
|
|
162
|
-
* @returns {string} the name of the class
|
|
163
|
-
*/
|
|
164
|
-
get [Symbol.toStringTag](): string;
|
|
165
|
-
#private;
|
|
166
|
-
}
|
|
167
|
-
export const IterableExtensions: Extension;
|
|
168
|
-
export const IteratorExtensions: Extension;
|
|
169
|
-
import { Extension } from '@nejs/extension';
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IteratorExtensions = exports.IterableExtensions = exports.Iterator = exports.Iterable = void 0;
|
|
4
|
-
const extension_1 = require("@nejs/extension");
|
|
5
|
-
/**
|
|
6
|
-
* The Iterable class is designed to provide a convenient way to create synchronous
|
|
7
|
-
* iterable objects. It can be initialized with either an array or individual elements.
|
|
8
|
-
* This class implements the iterable protocol, allowing instances to be used with
|
|
9
|
-
* `for...of` loops and other standard JavaScript iteration mechanisms.
|
|
10
|
-
*/
|
|
11
|
-
class Iterable {
|
|
12
|
-
/**
|
|
13
|
-
* Private field to store the elements of the iterable.
|
|
14
|
-
* @private
|
|
15
|
-
*/
|
|
16
|
-
#elements = [];
|
|
17
|
-
/**
|
|
18
|
-
* Constructs an instance of Iterable. It can be initialized with either an
|
|
19
|
-
* iterable object (such as an array, Set, Map, string, or any object
|
|
20
|
-
* implementing the iterable protocol) or individual elements. If the first
|
|
21
|
-
* argument is an iterable, the class instance is initialized with the
|
|
22
|
-
* elements from the iterable, followed by any additional arguments. If the
|
|
23
|
-
* first argument is not an iterable, all arguments are treated as individual
|
|
24
|
-
* elements.
|
|
25
|
-
*
|
|
26
|
-
* @param {Iterable|*} elementsOrFirstElement - An iterable object or the
|
|
27
|
-
* first element.
|
|
28
|
-
* @param {...*} moreElements - Additional elements if the first argument is
|
|
29
|
-
* not an iterable.
|
|
30
|
-
*/
|
|
31
|
-
constructor(elementsOrFirstElement, ...moreElements) {
|
|
32
|
-
if (elementsOrFirstElement != null &&
|
|
33
|
-
typeof elementsOrFirstElement[Symbol.iterator] === 'function') {
|
|
34
|
-
this.#elements = [...elementsOrFirstElement, ...moreElements];
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
this.#elements = [elementsOrFirstElement, ...moreElements];
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Implements the iterable protocol. When an instance of Iterable is used
|
|
42
|
-
* in a `for...of` loop or spread syntax, this generator function is invoked
|
|
43
|
-
* to yield the elements one by one in a synchronous manner.
|
|
44
|
-
*
|
|
45
|
-
* @returns {Generator} A generator that yields each element of the iterable.
|
|
46
|
-
*/
|
|
47
|
-
*[Symbol.iterator]() {
|
|
48
|
-
for (const element of this.#elements) {
|
|
49
|
-
yield element;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Provides access to the elements as a standard array. Useful for scenarios
|
|
54
|
-
* where array methods and behaviors are needed.
|
|
55
|
-
*
|
|
56
|
-
* @returns {Array} An array containing all the elements of the iterable.
|
|
57
|
-
*/
|
|
58
|
-
get asArray() {
|
|
59
|
-
return this.#elements;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Ensures that the constructor of this object instance's name
|
|
63
|
-
* is returned if the string tag for this instance is queried
|
|
64
|
-
*
|
|
65
|
-
* @returns {string} the name of the class
|
|
66
|
-
*/
|
|
67
|
-
get [Symbol.toStringTag]() {
|
|
68
|
-
return this.constructor.name;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Checks if a given value is an iterable. This method determines if the
|
|
72
|
-
* provided value has a `Symbol.iterator` property that is a generator
|
|
73
|
-
* function. It's a precise way to identify if the value conforms to the
|
|
74
|
-
* iterable protocol using a generator function.
|
|
75
|
-
*
|
|
76
|
-
* Note: This method specifically checks for generator functions. Some
|
|
77
|
-
* iterables might use regular functions that return an iterator, which
|
|
78
|
-
* this method won't identify.
|
|
79
|
-
*
|
|
80
|
-
* @param {*} value - The value to be checked for iterability.
|
|
81
|
-
* @returns {boolean} - Returns true if the value is an iterable implemented
|
|
82
|
-
* using a generator function, false otherwise.
|
|
83
|
-
*/
|
|
84
|
-
static isIterable(value) {
|
|
85
|
-
const type = Object.prototype.toString.call(value?.[Symbol.iterator]);
|
|
86
|
-
return type === '[object GeneratorFunction]';
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
exports.Iterable = Iterable;
|
|
90
|
-
/**
|
|
91
|
-
* Being able to create a compliant `Iterator` around any type of iterable
|
|
92
|
-
* object. This can be wrapped around any type of object that has a
|
|
93
|
-
* `[Symbol.iterator]` property assigned to a generator function.
|
|
94
|
-
*/
|
|
95
|
-
class Iterator {
|
|
96
|
-
/**
|
|
97
|
-
* A private function that when provided has the following signature:
|
|
98
|
-
* `function mapEach(entry) -> entry`. This allows any changes to be made
|
|
99
|
-
* to each element, conditionally and programmatically, as needed before
|
|
100
|
-
* they are returned to the called code.
|
|
101
|
-
*/
|
|
102
|
-
#mapEach = undefined;
|
|
103
|
-
/**
|
|
104
|
-
* Creates a new `Iterator` object instance.
|
|
105
|
-
*
|
|
106
|
-
* @param {object} iterable any object that has a `[Symbol.iterator]`
|
|
107
|
-
* property assigned to a generator function.
|
|
108
|
-
* @param {function} mapEach when provided `mapEach` is a callback that
|
|
109
|
-
* takes an entry as input and receives one as output.
|
|
110
|
-
*/
|
|
111
|
-
constructor(iterable, mapEach) {
|
|
112
|
-
if (!iterable || !Reflect.has(iterable, Symbol.iterator)) {
|
|
113
|
-
throw new TypeError('Value used to instantiate Iterator is not iterable');
|
|
114
|
-
}
|
|
115
|
-
this.#iterable = iterable;
|
|
116
|
-
this.#iterator = iterable[Symbol.iterator]();
|
|
117
|
-
this.#mapEach = typeof mapEach === 'function' ? mapEach : undefined;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Returns a new `Array` derived from the iterable this object
|
|
121
|
-
* wraps.
|
|
122
|
-
*
|
|
123
|
-
* @returns {array} a new `Array` generated from the wrapped
|
|
124
|
-
* iterable. The method is generated from `Array.from()`
|
|
125
|
-
*/
|
|
126
|
-
get asArray() {
|
|
127
|
-
return Array.from(this.#iterable);
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Returns the actual iterable object passed to the constructor that
|
|
131
|
-
* created this instance.
|
|
132
|
-
*
|
|
133
|
-
* @returns {object} the object containing the `[Symbol.iterator]`
|
|
134
|
-
*/
|
|
135
|
-
get iterable() {
|
|
136
|
-
return this.#iterable;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* The function retrieves the next value in the iterator. If the
|
|
140
|
-
* the iterator has run its course, `reset()` can be invoked to
|
|
141
|
-
* reset the pointer to the beginning of the iteration.
|
|
142
|
-
*
|
|
143
|
-
* @returns {any} the next value
|
|
144
|
-
*/
|
|
145
|
-
next() {
|
|
146
|
-
const input = this.#iterator.next();
|
|
147
|
-
let output = input;
|
|
148
|
-
if (output.done) {
|
|
149
|
-
return { value: undefined, done: true };
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
if (this.#mapEach && typeof this.#mapEach === 'function') {
|
|
153
|
-
output.value = this.#mapEach(input.value);
|
|
154
|
-
}
|
|
155
|
-
return { value: output.value, done: false };
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Resets the iterator to the beginning allowing it to be
|
|
160
|
-
* iterated over again.
|
|
161
|
-
*/
|
|
162
|
-
reset() {
|
|
163
|
-
this.#iterator = this.#iterable[Symbol.iterator]();
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* The existence of this symbol on the object instances, indicates that
|
|
167
|
-
* it can be used in `for(.. of ..)` loops and its values can be
|
|
168
|
-
* extracted from calls to `Array.from()`
|
|
169
|
-
*
|
|
170
|
-
* @returns {Iterator} this is returned since this object is already
|
|
171
|
-
* conforming to the expected JavaScript Iterator interface
|
|
172
|
-
*/
|
|
173
|
-
[Symbol.iterator]() {
|
|
174
|
-
return this;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Ensures that the constructor of this object instance's name
|
|
178
|
-
* is returned if the string tag for this instance is queried
|
|
179
|
-
*
|
|
180
|
-
* @returns {string} the name of the class
|
|
181
|
-
*/
|
|
182
|
-
get [Symbol.toStringTag]() {
|
|
183
|
-
return this.constructor.name;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* The object from which its iterator functionality is derived.
|
|
187
|
-
*
|
|
188
|
-
* @type {object}
|
|
189
|
-
* @private
|
|
190
|
-
*/
|
|
191
|
-
#iterable = null;
|
|
192
|
-
/**
|
|
193
|
-
* The results of a call to the iterable's `[Symbol.iterator]`
|
|
194
|
-
* generator function.
|
|
195
|
-
*
|
|
196
|
-
* @type {object}
|
|
197
|
-
* @private
|
|
198
|
-
*/
|
|
199
|
-
#iterator = null;
|
|
200
|
-
/**
|
|
201
|
-
* Creates an Iterator for the keys of the given object.
|
|
202
|
-
*
|
|
203
|
-
* @note alternatives to keyFetcher might be `Reflect.ownKeys` or even
|
|
204
|
-
* `Object.keys`. Each type of fetcher has their own requirements but
|
|
205
|
-
* any function that takes an object and returns keys will suffice.
|
|
206
|
-
*
|
|
207
|
-
* @param {Object} object - The object whose keys will be iterated.
|
|
208
|
-
* @param {Function} [mapEach] - Optional function to map each key.
|
|
209
|
-
* @param {Function} [keyFetcher=Object.getOwnPropertyNames] - Function to
|
|
210
|
-
* fetch keys from the object. Defaults to Object.getOwnPropertyNames.
|
|
211
|
-
* @returns {Iterator} An Iterator instance containing the object's keys.
|
|
212
|
-
*/
|
|
213
|
-
static keys(object, mapEach, keyFetcher) {
|
|
214
|
-
keyFetcher ??= Object.getOwnPropertyNames;
|
|
215
|
-
const keys = keyFetcher(object);
|
|
216
|
-
return new Iterator(keys, mapEach);
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Creates an Iterator for the entries of the given object.
|
|
220
|
-
*
|
|
221
|
-
* @note alternatives to keyFetcher might be `Reflect.ownKeys` or even
|
|
222
|
-
* `Object.keys`. Each type of fetcher has their own requirements but
|
|
223
|
-
* any function that takes an object and returns keys will suffice.
|
|
224
|
-
*
|
|
225
|
-
* @param {Object} object - The object whose entries will be iterated.
|
|
226
|
-
* @param {Function} [mapEach] - Optional function to map each entry.
|
|
227
|
-
* @param {Function} [keyFetcher=Object.getOwnPropertyNames] - Function to
|
|
228
|
-
* fetch keys from the object. Defaults to Object.getOwnPropertyNames.
|
|
229
|
-
* @returns {Iterator} An Iterator instance containing the object's entries.
|
|
230
|
-
*/
|
|
231
|
-
static entries(object, mapEach, keyFetcher) {
|
|
232
|
-
keyFetcher ??= Object.getOwnPropertyNames;
|
|
233
|
-
const keys = keyFetcher(object);
|
|
234
|
-
const entries = [];
|
|
235
|
-
for (const key of keys) {
|
|
236
|
-
entries.push([key, object[key]]);
|
|
237
|
-
}
|
|
238
|
-
return new Iterator(entries, mapEach);
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Creates an Iterator for the property descriptors of the given object.
|
|
242
|
-
*
|
|
243
|
-
* @note alternatives to keyFetcher might be `Reflect.ownKeys` or even
|
|
244
|
-
* `Object.keys`. Each type of fetcher has their own requirements but
|
|
245
|
-
* any function that takes an object and returns keys will suffice.
|
|
246
|
-
*
|
|
247
|
-
* @param {Object} object - The object whose descriptors will be iterated.
|
|
248
|
-
* @param {Function} [mapEach] - Optional function to map each descriptor
|
|
249
|
-
* entry.
|
|
250
|
-
* @param {Function} [keyFetcher=Object.getOwnPropertyNames] - Function to
|
|
251
|
-
* fetch keys from the object. Defaults to Object.getOwnPropertyNames.
|
|
252
|
-
* @returns {Iterator} An Iterator instance containing entries of [key,
|
|
253
|
-
* descriptor] pairs.
|
|
254
|
-
*/
|
|
255
|
-
static descriptors(object, mapEach, keyFetcher) {
|
|
256
|
-
keyFetcher ??= Object.getOwnPropertyNames;
|
|
257
|
-
const keys = keyFetcher(object);
|
|
258
|
-
const entries = [];
|
|
259
|
-
for (const key of keys) {
|
|
260
|
-
entries.push([key, Object.getOwnPropertyDescriptor(object, key)]);
|
|
261
|
-
}
|
|
262
|
-
return new Iterator(entries, mapEach);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
exports.Iterator = Iterator;
|
|
266
|
-
exports.IterableExtensions = new extension_1.Extension(Iterable);
|
|
267
|
-
exports.IteratorExtensions = new extension_1.Extension(Iterator);
|
|
268
|
-
//# sourceMappingURL=iterable.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"iterable.js","sourceRoot":"","sources":["../../../src/classes/iterable.js"],"names":[],"mappings":";;;AAAA,+CAA2C;AAE3C;;;;;GAKG;AACH,MAAa,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,I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E,OAAO,EAAE,UAAU;QACxC,UAAU,KAAK,MAAM,CAAC,mBAAmB,CAAC;QAE1C,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;QAChC,MAAM,OAAO,GAAG,EAAE,CAAC;QAEnB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACnC,CAAC;QAED,OAAO,IAAI,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACvC,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU;QAC5C,UAAU,KAAK,MAAM,CAAC,mBAAmB,CAAC;QAE1C,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;QAChC,MAAM,OAAO,GAAG,EAAE,CAAC;QAEnB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAA;QACnE,CAAC;QAED,OAAO,IAAI,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;CACF;AAjMD,4BAiMC;AAEY,QAAA,kBAAkB,GAAG,IAAI,qBAAS,CAAC,QAAQ,CAAC,CAAA;AAC5C,QAAA,kBAAkB,GAAG,IAAI,qBAAS,CAAC,QAAQ,CAAC,CAAA"}
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
export class ParamParser {
|
|
2
|
-
/**
|
|
3
|
-
* Attempts to parse the given parameters using the provided parsers, throwing an
|
|
4
|
-
* error if no valid parser is found. This method serves as a convenience wrapper
|
|
5
|
-
* around `safeTryParsers`, enforcing strict parsing by automatically enabling
|
|
6
|
-
* error throwing on failure.
|
|
7
|
-
*
|
|
8
|
-
* @param {any[]} parameters - The parameters to be parsed.
|
|
9
|
-
* @param {Function[]} parsers - An array of `ParamParser` subclasses to attempt
|
|
10
|
-
* parsing with.
|
|
11
|
-
* @returns {Object} An object containing the parsing result, with a `success`
|
|
12
|
-
* property indicating if parsing was successful, and a `data` property containing
|
|
13
|
-
* the parsed data if successful.
|
|
14
|
-
* @example
|
|
15
|
-
* const parameters = ['param1', 'param2'];
|
|
16
|
-
* const parsers = [Parser1, Parser2];
|
|
17
|
-
* const result = ParamParser.tryParsers(parameters, parsers);
|
|
18
|
-
* if (result.success) {
|
|
19
|
-
* console.log('Parsing successful:', result.data);
|
|
20
|
-
* } else {
|
|
21
|
-
* console.error('Parsing failed.');
|
|
22
|
-
* }
|
|
23
|
-
*/
|
|
24
|
-
static tryParsers(parameters: any[], parsers: Function[]): Object;
|
|
25
|
-
/**
|
|
26
|
-
* Tries parsing `parameters` with each parser in `parsers`. If
|
|
27
|
-
* `throwOnFail` is true, throws an error when validation fails or
|
|
28
|
-
* no valid parser is found.
|
|
29
|
-
*
|
|
30
|
-
* This method attempts to parse the given parameters using the
|
|
31
|
-
* provided list of parsers. It validates the input to ensure both
|
|
32
|
-
* `parameters` and `parsers` are arrays and that `parsers`
|
|
33
|
-
* contains at least one valid `ParamParser` subclass. If
|
|
34
|
-
* `throwOnFail` is set to true, it will throw specific errors for
|
|
35
|
-
* invalid inputs or when no parser succeeds. Otherwise, it returns
|
|
36
|
-
* an object indicating the success status and the result of
|
|
37
|
-
* parsing, if successful.
|
|
38
|
-
*
|
|
39
|
-
* @param {any[]} parameters - The parameters to be parsed.
|
|
40
|
-
* @param {Function[]} parsers - An array of `ParamParser`
|
|
41
|
-
* subclasses to attempt parsing with.
|
|
42
|
-
* @param {boolean} [throwOnFail=false] - Whether to throw an
|
|
43
|
-
* error on failure.
|
|
44
|
-
* @returns {{success: boolean, data: any}} An object with a
|
|
45
|
-
* `success` flag and `data` containing the parsing result, if
|
|
46
|
-
* successful.
|
|
47
|
-
* @throws {ParametersMustBeArrayError} If `parameters` or
|
|
48
|
-
* `parsers` are not arrays when `throwOnFail` is true.
|
|
49
|
-
* @throws {ParsersArrayMustContainParsersError} If `parsers`
|
|
50
|
-
* does not contain at least one valid `ParamParser` subclass
|
|
51
|
-
* when `throwOnFail` is true.
|
|
52
|
-
* @throws {NoValidParsersFound} If no valid parser is found
|
|
53
|
-
* and `throwOnFail` is true.
|
|
54
|
-
* @example
|
|
55
|
-
* const parameters = ['param1', 'param2'];
|
|
56
|
-
* const parsers = [Parser1, Parser2];
|
|
57
|
-
* const result = ParamParser.safeTryParsers(
|
|
58
|
-
* parameters, parsers, true
|
|
59
|
-
* );
|
|
60
|
-
*
|
|
61
|
-
* if (result.success) {
|
|
62
|
-
* console.log('Parsing successful:', result.data);
|
|
63
|
-
* } else {
|
|
64
|
-
* console.error('Parsing failed.');
|
|
65
|
-
* }
|
|
66
|
-
*/
|
|
67
|
-
static safeTryParsers(parameters: any[], parsers: Function[], throwOnFail?: boolean): {
|
|
68
|
-
success: boolean;
|
|
69
|
-
data: any;
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* A custom error class that signifies no valid parsers were found
|
|
73
|
-
* during the parsing process. This error is thrown when all
|
|
74
|
-
* parsers fail to parse the given parameters and the `throwOnFail`
|
|
75
|
-
* flag is set to true in the `safeTryParsers` method.
|
|
76
|
-
*
|
|
77
|
-
* @returns {Function} A class extending Error, representing a
|
|
78
|
-
* specific error when no valid parsers are found.ound.
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* try {
|
|
82
|
-
* const result = ParamParser.safeTryParsers(
|
|
83
|
-
* parameters, parsers, true
|
|
84
|
-
* );
|
|
85
|
-
* } catch (error) {
|
|
86
|
-
* if (error instanceof ParamParser.NoValidParsersFound) {
|
|
87
|
-
* console.error(
|
|
88
|
-
* 'No valid parsers could process the parameters.'
|
|
89
|
-
* );
|
|
90
|
-
* }
|
|
91
|
-
* }
|
|
92
|
-
*/
|
|
93
|
-
static get NoValidParsersFound(): Function;
|
|
94
|
-
/**
|
|
95
|
-
* Represents an error thrown when the parameters provided to a method
|
|
96
|
-
* are not in an array format as expected. This class extends the
|
|
97
|
-
* native JavaScript `Error` class, allowing for instances of this
|
|
98
|
-
* error to be thrown and caught using standard error handling
|
|
99
|
-
* mechanisms in JavaScript.
|
|
100
|
-
*
|
|
101
|
-
* This error is specifically used in scenarios where a method
|
|
102
|
-
* expects its arguments to be provided as an array, and the
|
|
103
|
-
* validation of those arguments fails because they were not
|
|
104
|
-
* provided in an array format. It serves as a clear indicator
|
|
105
|
-
* of the nature of the error to developers, enabling them to
|
|
106
|
-
* quickly identify and rectify the issue in their code.
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* try {
|
|
110
|
-
* ParamParser.safeTryParsers(nonArrayParameters, parsers, true);
|
|
111
|
-
* } catch (error) {
|
|
112
|
-
* if (error instanceof ParamParser.ParametersMustBeArrayError) {
|
|
113
|
-
* console.error('Parameters must be provided as an array.');
|
|
114
|
-
* }
|
|
115
|
-
* }
|
|
116
|
-
*/
|
|
117
|
-
static get ParametersMustBeArrayError(): {
|
|
118
|
-
new (message?: string): {
|
|
119
|
-
name: string;
|
|
120
|
-
message: string;
|
|
121
|
-
stack?: string;
|
|
122
|
-
cause?: unknown;
|
|
123
|
-
};
|
|
124
|
-
new (message?: string, options?: ErrorOptions): {
|
|
125
|
-
name: string;
|
|
126
|
-
message: string;
|
|
127
|
-
stack?: string;
|
|
128
|
-
cause?: unknown;
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
* A custom error class indicating that the parsers array does not
|
|
133
|
-
* contain valid parser functions. This error is thrown when the
|
|
134
|
-
* validation of parsers within `ParamParser.safeTryParsers` fails
|
|
135
|
-
* to find any instance that is a subclass of `ParamParser`. It
|
|
136
|
-
* extends the native JavaScript `Error` class, allowing it to be
|
|
137
|
-
* thrown and caught using standard error handling mechanisms.
|
|
138
|
-
*
|
|
139
|
-
* This error serves as a clear indicator to developers that the
|
|
140
|
-
* provided array of parsers does not meet the expected criteria,
|
|
141
|
-
* specifically that it must contain at least one valid parser
|
|
142
|
-
* that extends `ParamParser`. This ensures that the parsing
|
|
143
|
-
* process can be executed with at least one valid parser function.
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
* try {
|
|
147
|
-
* ParamParser.safeTryParsers(parameters, [], true);
|
|
148
|
-
* } catch (error) {
|
|
149
|
-
* const { ParsersArrayMustContainParsersError } = ParamParser
|
|
150
|
-
* if (error instanceof ParsersArrayMustContainParsersError) {
|
|
151
|
-
* console.error(
|
|
152
|
-
* 'The parsers array must contain at least one valid parser.'
|
|
153
|
-
* );
|
|
154
|
-
* }
|
|
155
|
-
* }
|
|
156
|
-
*/
|
|
157
|
-
static get ParsersArrayMustContainParsersError(): {
|
|
158
|
-
new (message?: string): {
|
|
159
|
-
name: string;
|
|
160
|
-
message: string;
|
|
161
|
-
stack?: string;
|
|
162
|
-
cause?: unknown;
|
|
163
|
-
};
|
|
164
|
-
new (message?: string, options?: ErrorOptions): {
|
|
165
|
-
name: string;
|
|
166
|
-
message: string;
|
|
167
|
-
stack?: string;
|
|
168
|
-
cause?: unknown;
|
|
169
|
-
};
|
|
170
|
-
};
|
|
171
|
-
/**
|
|
172
|
-
* Constructs an instance of ParamParser. It takes in parameters, an optional
|
|
173
|
-
* validator function, and an optional parser function. The parameters are
|
|
174
|
-
* validated and if successful, parsed.
|
|
175
|
-
*
|
|
176
|
-
* @param {any[]} parameters - Arguments passed in by the process.
|
|
177
|
-
* @param {((any[]) => boolean)?} [validator=() => {}] - An optional function
|
|
178
|
-
* to specify a validator without subclassing ParamParser. It should return
|
|
179
|
-
* a boolean indicating the validity of the parameters.
|
|
180
|
-
* @param {((any[]) => object)?} [parser=() => {}] - An optional function to
|
|
181
|
-
* specify a parser without subclassing ParamParser. It should return an
|
|
182
|
-
* object after parsing the input parameters.
|
|
183
|
-
*
|
|
184
|
-
* @example
|
|
185
|
-
* const parameters = ['param1', 'param2']
|
|
186
|
-
* const validator = params => params.every(param => typeof param === 'string')
|
|
187
|
-
* const parser = params => ({ params })
|
|
188
|
-
* const paramParser = new ParamParser(parameters, validator, parser)
|
|
189
|
-
* if (paramParser.success) {
|
|
190
|
-
* console.log('Parsing successful:', paramParser.results)
|
|
191
|
-
* } else {
|
|
192
|
-
* console.error('Parsing failed.')
|
|
193
|
-
* }
|
|
194
|
-
*/
|
|
195
|
-
constructor(parameters: any[], validator?: () => void, parser?: () => void);
|
|
196
|
-
args: any[];
|
|
197
|
-
parser: () => void;
|
|
198
|
-
validator: () => void;
|
|
199
|
-
result: any;
|
|
200
|
-
success: boolean;
|
|
201
|
-
results: object | undefined;
|
|
202
|
-
/**
|
|
203
|
-
* @param {object} args arguments that were previously validated
|
|
204
|
-
* by either the overloaded validate() method or the supplied
|
|
205
|
-
* validator closure.
|
|
206
|
-
* @returns {object} returns the output object, or an empty
|
|
207
|
-
* object, after parsing the input arguments or parameters.
|
|
208
|
-
*/
|
|
209
|
-
parse(args: object): object;
|
|
210
|
-
/**
|
|
211
|
-
* Walk the arguments and determine if the supplied input is
|
|
212
|
-
* a valid parsing.
|
|
213
|
-
*
|
|
214
|
-
* @param {any[]} args arguments supplied by the process.
|
|
215
|
-
* @returns {boolean} `true` if the validation is successful,
|
|
216
|
-
* `false` otherwise.
|
|
217
|
-
*/
|
|
218
|
-
validate(args: any[]): boolean;
|
|
219
|
-
}
|
|
220
|
-
export const ParamParserExtensions: Extension;
|
|
221
|
-
import { Extension } from '@nejs/extension';
|