@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,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `ArrayExtensions` is a constant that applies a patch to the global
|
|
3
|
-
* `Array` constructor. This patch extends the `Array` with additional
|
|
4
|
-
* methods and properties, enhancing its functionality.
|
|
5
|
-
*
|
|
6
|
-
* The `Patch` function takes two arguments: the target object to be patched
|
|
7
|
-
* (in this case, `Array`), and an object containing the methods and
|
|
8
|
-
* properties to be added to the target object.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* // Using a method added by ArrayExtensions
|
|
12
|
-
* const arr = [1, 2, 3];
|
|
13
|
-
* console.log(Array.ifArray(arr, 'Array', 'Not Array')); // Output: 'Array'
|
|
14
|
-
*
|
|
15
|
-
* @const
|
|
16
|
-
* @type {Patch}
|
|
17
|
-
* @memberof module:array.extensions
|
|
18
|
-
*/
|
|
19
|
-
export const ArrayExtensions: Patch;
|
|
20
|
-
/**
|
|
21
|
-
* `ArrayPrototypeExtensions` is a constant that applies a patch to the
|
|
22
|
-
* Array prototype. This patch extends the Array prototype with additional
|
|
23
|
-
* methods and properties, enhancing its functionality.
|
|
24
|
-
*
|
|
25
|
-
* The `Patch` function takes two arguments: the target object to be patched
|
|
26
|
-
* (in this case, `Array.prototype`), and an object containing the methods
|
|
27
|
-
* and properties to be added to the target object.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* // Using a method added by ArrayPrototypeExtensions
|
|
31
|
-
* const arr = [1, 2, 3];
|
|
32
|
-
* console.log(arr.ifArray('Array', 'Not Array')); // Output: 'Array'
|
|
33
|
-
*
|
|
34
|
-
* @const
|
|
35
|
-
* @type {Patch}
|
|
36
|
-
* @memberof module:array.extensions
|
|
37
|
-
*/
|
|
38
|
-
export const ArrayPrototypeExtensions: Patch;
|
|
39
|
-
import { Patch } from '@nejs/extension';
|
|
@@ -1,477 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ArrayPrototypeExtensions = exports.ArrayExtensions = void 0;
|
|
4
|
-
const extension_1 = require("@nejs/extension");
|
|
5
|
-
/**
|
|
6
|
-
* `ArrayExtensions` is a constant that applies a patch to the global
|
|
7
|
-
* `Array` constructor. This patch extends the `Array` with additional
|
|
8
|
-
* methods and properties, enhancing its functionality.
|
|
9
|
-
*
|
|
10
|
-
* The `Patch` function takes two arguments: the target object to be patched
|
|
11
|
-
* (in this case, `Array`), and an object containing the methods and
|
|
12
|
-
* properties to be added to the target object.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* // Using a method added by ArrayExtensions
|
|
16
|
-
* const arr = [1, 2, 3];
|
|
17
|
-
* console.log(Array.ifArray(arr, 'Array', 'Not Array')); // Output: 'Array'
|
|
18
|
-
*
|
|
19
|
-
* @const
|
|
20
|
-
* @type {Patch}
|
|
21
|
-
* @memberof module:array.extensions
|
|
22
|
-
*/
|
|
23
|
-
exports.ArrayExtensions = new extension_1.Patch(Array, {
|
|
24
|
-
/**
|
|
25
|
-
* Checks if the provided value is an array and returns one of two
|
|
26
|
-
* provided values based on the result. This function is a convenience
|
|
27
|
-
* method for performing conditional operations based on the type of
|
|
28
|
-
* the provided value.
|
|
29
|
-
*
|
|
30
|
-
* @name ifArray
|
|
31
|
-
* @type {function}
|
|
32
|
-
* @memberof ArrayExtensions
|
|
33
|
-
* @param {any} value - The value to be checked.
|
|
34
|
-
* @param {function | any} thenValue - The value to be returned if the
|
|
35
|
-
* provided value is an array.
|
|
36
|
-
* @param {function | any} elseValue - The value to be returned if the
|
|
37
|
-
* provided value is not an array.
|
|
38
|
-
* @returns {any} Returns `thenValue` if the provided value is an array,
|
|
39
|
-
* otherwise returns `elseValue`.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* const arr = [1, 2, 3];
|
|
43
|
-
* console.log(ArrayExtensions.ifArray(arr, 'Array', 'Not Array'));
|
|
44
|
-
* // Output: 'Array'
|
|
45
|
-
*
|
|
46
|
-
* const notArr = "I'm not an array";
|
|
47
|
-
* console.log(ArrayExtensions.ifArray(notArr, 'Array', 'Not Array'));
|
|
48
|
-
* // Output: 'Not Array'
|
|
49
|
-
*/
|
|
50
|
-
ifArray(value, thenValue, elseValue) {
|
|
51
|
-
return isThenElse(Array.isArray(value), thenValue, elseValue);
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
const { ifArray: pIfArray } = exports.ArrayExtensions.patches;
|
|
55
|
-
// todo: everyOfType(type), someOfType(type)
|
|
56
|
-
// todo: everyWithTag(stringTag), someWithTag(stringTag),
|
|
57
|
-
// todo: everyOfInstance(Class), someOfInstance(Class)
|
|
58
|
-
/**
|
|
59
|
-
* `ArrayPrototypeExtensions` is a constant that applies a patch to the
|
|
60
|
-
* Array prototype. This patch extends the Array prototype with additional
|
|
61
|
-
* methods and properties, enhancing its functionality.
|
|
62
|
-
*
|
|
63
|
-
* The `Patch` function takes two arguments: the target object to be patched
|
|
64
|
-
* (in this case, `Array.prototype`), and an object containing the methods
|
|
65
|
-
* and properties to be added to the target object.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* // Using a method added by ArrayPrototypeExtensions
|
|
69
|
-
* const arr = [1, 2, 3];
|
|
70
|
-
* console.log(arr.ifArray('Array', 'Not Array')); // Output: 'Array'
|
|
71
|
-
*
|
|
72
|
-
* @const
|
|
73
|
-
* @type {Patch}
|
|
74
|
-
* @memberof module:array.extensions
|
|
75
|
-
*/
|
|
76
|
-
exports.ArrayPrototypeExtensions = new extension_1.Patch(Array.prototype, {
|
|
77
|
-
[extension_1.Patch.kMutablyHidden]: {
|
|
78
|
-
/**
|
|
79
|
-
* Sometimes defining even a short function for the invocation of `find`
|
|
80
|
-
* can be troublesome. This helper function performs that job for you. If
|
|
81
|
-
* the specified element is in the array, `true` will be returned.
|
|
82
|
-
*
|
|
83
|
-
* @param {*} value the value to search for. This value must triple equals
|
|
84
|
-
* the array element in order to return true.
|
|
85
|
-
* @returns true if the exact element exists in the array, false otherwise
|
|
86
|
-
*/
|
|
87
|
-
contains(value) {
|
|
88
|
-
return !!this.find(entry => entry === value);
|
|
89
|
-
},
|
|
90
|
-
/**
|
|
91
|
-
* The `findEntry` function searches the entries of the object and returns
|
|
92
|
-
* the `[index, value]` entry array for the first matching value found.
|
|
93
|
-
*
|
|
94
|
-
* @param {function} findFn a function that takes the element to be checked
|
|
95
|
-
* and returns a boolean value
|
|
96
|
-
* @returns if `findFn` returns `true`, an array with two elements, the first
|
|
97
|
-
* being the index, the second being the value, is returned.
|
|
98
|
-
*/
|
|
99
|
-
findEntry(findFn) {
|
|
100
|
-
const entries = this.entries();
|
|
101
|
-
const VALUE = 1;
|
|
102
|
-
for (let entry of entries) {
|
|
103
|
-
if (findFn(entry[VALUE])) {
|
|
104
|
-
return entry;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return undefined;
|
|
108
|
-
},
|
|
109
|
-
/**
|
|
110
|
-
* A getter property that returns the first element of the array. If the
|
|
111
|
-
* array is empty, it returns `undefined`. This property is useful for
|
|
112
|
-
* scenarios where you need to quickly access the first item of an array
|
|
113
|
-
* without the need for additional checks or method calls.
|
|
114
|
-
*
|
|
115
|
-
* @returns {*} The first element of the array or `undefined` if the array
|
|
116
|
-
* is empty.
|
|
117
|
-
*/
|
|
118
|
-
get first() {
|
|
119
|
-
return this[0];
|
|
120
|
-
},
|
|
121
|
-
/**
|
|
122
|
-
* A getter property that checks if the current context (`this`) is an
|
|
123
|
-
* array. This is a convenience method that wraps the native
|
|
124
|
-
* `Array.isArray` function.
|
|
125
|
-
*
|
|
126
|
-
* @name isArray
|
|
127
|
-
* @type {function}
|
|
128
|
-
* @memberof Array.prototype
|
|
129
|
-
* @returns {boolean} `true` if the current context is an array,
|
|
130
|
-
* `false` otherwise.
|
|
131
|
-
*
|
|
132
|
-
* @example
|
|
133
|
-
* const arr = [1, 2, 3];
|
|
134
|
-
* console.log(arr.isArray); // Output: true
|
|
135
|
-
*
|
|
136
|
-
* const notArr = "I'm not an array";
|
|
137
|
-
* console.log(notArr.isArray); // Output: false
|
|
138
|
-
*/
|
|
139
|
-
get isArray() {
|
|
140
|
-
return Array.isArray(this);
|
|
141
|
-
},
|
|
142
|
-
/**
|
|
143
|
-
* Checks if the current context (`this`) is an array and returns one of
|
|
144
|
-
* two provided values based on the result. This function is a convenience
|
|
145
|
-
* method for performing conditional operations based on the type of
|
|
146
|
-
* the current context.
|
|
147
|
-
*
|
|
148
|
-
* @name ifArray
|
|
149
|
-
* @type {function}
|
|
150
|
-
* @memberof Array.prototype
|
|
151
|
-
* @param {function | any} thenValue - The value to be returned if the
|
|
152
|
-
* current context is an array.
|
|
153
|
-
* @param {function | any} elseValue - The value to be returned if the
|
|
154
|
-
* current context is not an array.
|
|
155
|
-
* @returns {*} Returns `thenValue` if the current context is an array,
|
|
156
|
-
* otherwise returns `elseValue`.
|
|
157
|
-
*
|
|
158
|
-
* @example
|
|
159
|
-
* const arr = [1, 2, 3];
|
|
160
|
-
* console.log(arr.ifArray('Array', 'Not Array')); // Output: 'Array'
|
|
161
|
-
*
|
|
162
|
-
* const notArr = "I'm not an array";
|
|
163
|
-
* console.log(notArr.ifArray('Array', 'Not Array')); // Output: 'Not Array'
|
|
164
|
-
*/
|
|
165
|
-
ifArray(thenValue, elseValue) {
|
|
166
|
-
return pIfArray(this, thenValue, elseValue);
|
|
167
|
-
},
|
|
168
|
-
/**
|
|
169
|
-
* Checks if at least one element in the array is equal to the provided
|
|
170
|
-
* value. This method uses the `Array.prototype.some` function to iterate
|
|
171
|
-
* over the array and compare each element with the provided value.
|
|
172
|
-
*
|
|
173
|
-
* @name oneIs
|
|
174
|
-
* @type {function}
|
|
175
|
-
* @memberof Array.prototype
|
|
176
|
-
* @param {*} value - The value to be compared with the array elements.
|
|
177
|
-
* @param {boolean} [doubleEqualsOkay=true] - A flag indicating whether to
|
|
178
|
-
* use loose equality (`==`) or strict equality (`===`) for the comparison.
|
|
179
|
-
* If `true`, loose equality is used. If `false`, strict equality is used.
|
|
180
|
-
* @returns {boolean} Returns `true` if at least one element in the array
|
|
181
|
-
* is equal to the provided value, otherwise `false`.
|
|
182
|
-
*
|
|
183
|
-
* @example
|
|
184
|
-
* const arr = [1, 2, 3];
|
|
185
|
-
* console.log(arr.oneIs(2)); // Output: true
|
|
186
|
-
*
|
|
187
|
-
* const arr2 = ['1', '2', '3'];
|
|
188
|
-
* console.log(arr2.oneIs(2, false)); // Output: false
|
|
189
|
-
*/
|
|
190
|
-
oneIs(value, doubleEqualsOkay = true) {
|
|
191
|
-
return this.some(element => (doubleEqualsOkay ? element == value : element === value));
|
|
192
|
-
},
|
|
193
|
-
/**
|
|
194
|
-
* Checks if some elements in the array are included in the provided values.
|
|
195
|
-
* This method uses the `Array.prototype.some` function to iterate over the
|
|
196
|
-
* array and checks if any of the elements are included in the provided values.
|
|
197
|
-
*
|
|
198
|
-
* @name someAre
|
|
199
|
-
* @type {function}
|
|
200
|
-
* @memberof Array.prototype
|
|
201
|
-
* @param {...*} values - The values to be checked against the array elements.
|
|
202
|
-
* @returns {boolean} Returns `true` if at least one element in the array
|
|
203
|
-
* is included in the provided values, otherwise `false`.
|
|
204
|
-
*
|
|
205
|
-
* @example
|
|
206
|
-
* const arr = [1, 2, 3];
|
|
207
|
-
* console.log(arr.someAre(2, 4)); // Output: true
|
|
208
|
-
*
|
|
209
|
-
* const arr2 = ['1', '2', '3'];
|
|
210
|
-
* console.log(arr2.someAre(4, 5)); // Output: false
|
|
211
|
-
*/
|
|
212
|
-
someAre(...values) {
|
|
213
|
-
return this.some(element => !!~values.indexOf(element));
|
|
214
|
-
},
|
|
215
|
-
/**
|
|
216
|
-
* Checks if all elements in the array are equal to the provided value.
|
|
217
|
-
* This method uses the `Array.prototype.every` function to iterate over
|
|
218
|
-
* the array and compare each element with the provided value.
|
|
219
|
-
*
|
|
220
|
-
* @name allAre
|
|
221
|
-
* @type {function}
|
|
222
|
-
* @memberof Array.prototype
|
|
223
|
-
* @param {*} value - The value to be compared with the array elements.
|
|
224
|
-
* @param {boolean} [doubleEqualsOkay=true] - A flag indicating whether to
|
|
225
|
-
* use loose equality (`==`) or strict equality (`===`) for the comparison.
|
|
226
|
-
* If `true`, loose equality is used. If `false`, strict equality is used.
|
|
227
|
-
* @returns {boolean} Returns `true` if all elements in the array are equal
|
|
228
|
-
* to the provided value, otherwise `false`.
|
|
229
|
-
*
|
|
230
|
-
* @example
|
|
231
|
-
* const arr = [2, 2, 2];
|
|
232
|
-
* console.log(arr.allAre(2)); // Output: true
|
|
233
|
-
*
|
|
234
|
-
* const arr2 = ['2', '2', '2'];
|
|
235
|
-
* console.log(arr2.allAre(2, false)); // Output: false
|
|
236
|
-
*/
|
|
237
|
-
allAre(value, doubleEqualsOkay = true) {
|
|
238
|
-
return this.every(element => (doubleEqualsOkay ? element == value : element === value));
|
|
239
|
-
},
|
|
240
|
-
/**
|
|
241
|
-
* A getter property that returns the last element of the array. It
|
|
242
|
-
* calculates the last index based on the array's length. If the array is
|
|
243
|
-
* empty, it returns `undefined`. This property is beneficial when you need
|
|
244
|
-
* to access the last item in an array, improving code readability and
|
|
245
|
-
* avoiding manual index calculation.
|
|
246
|
-
*
|
|
247
|
-
* @returns {*} The last element of the array or `undefined` if the
|
|
248
|
-
* array is empty.
|
|
249
|
-
*/
|
|
250
|
-
get last() {
|
|
251
|
-
return this[this.length - 1];
|
|
252
|
-
},
|
|
253
|
-
/**
|
|
254
|
-
* A getter that returns a new array containing only truthy elements.
|
|
255
|
-
* Filters out falsy values like null, undefined, 0, false, NaN, and ''.
|
|
256
|
-
* Useful for quickly removing falsy values from an array.
|
|
257
|
-
*
|
|
258
|
-
* @returns {Array} A new array with only truthy elements.
|
|
259
|
-
*/
|
|
260
|
-
get onlyTruthy() {
|
|
261
|
-
return this.filter(truthy => !!truthy);
|
|
262
|
-
},
|
|
263
|
-
/**
|
|
264
|
-
* A getter that returns a new array containing only falsy elements.
|
|
265
|
-
* Keeps falsy values like null, undefined, 0, false, NaN, and ''.
|
|
266
|
-
* Useful for isolating falsy values in an array for further processing.
|
|
267
|
-
*
|
|
268
|
-
* @returns {Array} A new array with only falsy elements.
|
|
269
|
-
*/
|
|
270
|
-
get onlyFalsy() {
|
|
271
|
-
return this.filter(falsy => !!!falsy);
|
|
272
|
-
},
|
|
273
|
-
// expected usage:
|
|
274
|
-
// function example(name, age) {
|
|
275
|
-
// const variants = [{name}, {age}].variants()
|
|
276
|
-
// if (typeof name === 'object')
|
|
277
|
-
// }
|
|
278
|
-
variants() {
|
|
279
|
-
const keys = this.map(o => Object.keys(o)?.[0]);
|
|
280
|
-
const entries = this.map(o => Object.entries(o)?.[0]);
|
|
281
|
-
const object = entries.reduce((acc, [key, value]) => {
|
|
282
|
-
acc[key] = value;
|
|
283
|
-
return acc;
|
|
284
|
-
}, {});
|
|
285
|
-
const result = {
|
|
286
|
-
order: keys,
|
|
287
|
-
entries: entries,
|
|
288
|
-
object: object,
|
|
289
|
-
};
|
|
290
|
-
Object.defineProperty(result, 'check', {
|
|
291
|
-
value(position) {
|
|
292
|
-
if (typeof position !== 'number' &&
|
|
293
|
-
position >= 0 &&
|
|
294
|
-
position < this.order.length) {
|
|
295
|
-
return false;
|
|
296
|
-
}
|
|
297
|
-
const value = this.entries[position][1];
|
|
298
|
-
if (typeof value === 'object' && value) {
|
|
299
|
-
if (Object.keys(value).every(key => ~this.order.indexOf(key))) {
|
|
300
|
-
return true;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
return false;
|
|
304
|
-
},
|
|
305
|
-
enumerable: false,
|
|
306
|
-
configurable: true
|
|
307
|
-
});
|
|
308
|
-
return result;
|
|
309
|
-
},
|
|
310
|
-
/**
|
|
311
|
-
* Weaves together an array of keys and an array of values into an
|
|
312
|
-
* object, using the provided default value for missing values and
|
|
313
|
-
* the specified base descriptor for defining properties. This can
|
|
314
|
-
* be used to quickly generate empty models if a list of keys from
|
|
315
|
-
* a preset or other object.
|
|
316
|
-
*
|
|
317
|
-
* @param {Array} arrayOfKeys - An array of keys to be used as
|
|
318
|
-
* property names in the resulting object.
|
|
319
|
-
* @param {Array} [arrayOfValues] - An optional array of values to
|
|
320
|
-
* be assigned to the corresponding keys. If not provided or not an
|
|
321
|
-
* array, the `defaultValue` will be used for all properties.
|
|
322
|
-
* @param {*} [defaultValue] - The default value to be used for
|
|
323
|
-
* missing values or when `arrayOfValues` is not an array or when
|
|
324
|
-
* there are not enough values for the number of keys.
|
|
325
|
-
* @param {Object|string} [baseDescriptor] - The base property
|
|
326
|
-
* descriptor to be used for defining properties. If not provided,
|
|
327
|
-
* default descriptor values will be used. Special string values
|
|
328
|
-
* `'hidden'` and `'immutable'` can be used for predefined
|
|
329
|
-
* descriptors.
|
|
330
|
-
* @returns {Object} - The resulting object with the woven
|
|
331
|
-
* properties.
|
|
332
|
-
*
|
|
333
|
-
* @example
|
|
334
|
-
* const employee134 = { name: 'Jane Doe', yearsOfService: 3 }
|
|
335
|
-
* const employee135 = Array.weave(Object.keys(employee134))
|
|
336
|
-
* // employee135 = { name: undefined, yearsOfService: undefined }
|
|
337
|
-
*
|
|
338
|
-
* @example
|
|
339
|
-
* const keys = ['a', 'b', 'c']
|
|
340
|
-
* const values = [1, 2, 3]
|
|
341
|
-
* const obj = Array.weave(keys, values)
|
|
342
|
-
* console.log(obj) // { a: 1, b: 2, c: 3 }
|
|
343
|
-
*
|
|
344
|
-
* @example
|
|
345
|
-
* const keys = ['x', 'y', 'z']
|
|
346
|
-
* const obj = Array.weave(keys, 42, 0, 'immutable')
|
|
347
|
-
* console.log(obj) // { x: 42, y: 42, z: 42 } (immutable)
|
|
348
|
-
*/
|
|
349
|
-
weave(arrayOfKeys, arrayOfValues, defaultValue, baseDescriptor) {
|
|
350
|
-
if (!Array.isArray(arrayOfKeys)) {
|
|
351
|
-
return {};
|
|
352
|
-
}
|
|
353
|
-
if (arrayOfValues && !Array.isArray(arrayOfValues)) {
|
|
354
|
-
const repeatedValue = arrayOfValues;
|
|
355
|
-
arrayOfValues = [];
|
|
356
|
-
for (const _ of arrayOfKeys) {
|
|
357
|
-
arrayOfValues.push(repeatedValue);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
const descKeys = ['configurable', 'enumerable', 'writable'];
|
|
361
|
-
let object = {};
|
|
362
|
-
let descriptor;
|
|
363
|
-
let keys = arrayOfKeys;
|
|
364
|
-
let values = arrayOfValues;
|
|
365
|
-
let useGetter = false;
|
|
366
|
-
// Ensure we have a descriptor
|
|
367
|
-
if (!baseDescriptor) {
|
|
368
|
-
descriptor = descKeys.reduce((acc, key) => { acc[key] = true; return acc; }, {});
|
|
369
|
-
}
|
|
370
|
-
else if (baseDescriptor === 'hidden') {
|
|
371
|
-
baseDescriptor = { configurable: true, enumerable: false };
|
|
372
|
-
}
|
|
373
|
-
else if (baseDescriptor === 'immutable') {
|
|
374
|
-
useGetter = true;
|
|
375
|
-
baseDescriptor = { configurable: false, enumerable: false };
|
|
376
|
-
}
|
|
377
|
-
else if (baseDescriptor && typeof baseDescriptor === 'object') {
|
|
378
|
-
descriptor = descKeys.reduce((acc, key) => {
|
|
379
|
-
acc[key] = baseDescriptor?.[key] ?? true;
|
|
380
|
-
return acc;
|
|
381
|
-
}, {});
|
|
382
|
-
}
|
|
383
|
-
for (const [index, key] of Object.entries(keys)) {
|
|
384
|
-
if (useGetter) {
|
|
385
|
-
Object.defineProperty(object, key, {
|
|
386
|
-
...descriptor,
|
|
387
|
-
get() { return values?.[index] ?? defaultValue; },
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
else {
|
|
391
|
-
Object.defineProperty(object, key, {
|
|
392
|
-
...descriptor,
|
|
393
|
-
value: values?.[index] ?? defaultValue,
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
return object;
|
|
398
|
-
},
|
|
399
|
-
/**
|
|
400
|
-
* @property {object} kTypeDefaults
|
|
401
|
-
* @description
|
|
402
|
-
* An object that maps JavaScript types to their default values.
|
|
403
|
-
* This is useful for initializing variables or properties with
|
|
404
|
-
* a default value based on their expected type.
|
|
405
|
-
*
|
|
406
|
-
* Note that `symbol` types are initialized with `undefined`
|
|
407
|
-
* due to the fact that their usage is by definition, unique;
|
|
408
|
-
* or at the very least deliberately reused.
|
|
409
|
-
*
|
|
410
|
-
* The default values for each type are:
|
|
411
|
-
* - `undefined`: `undefined`
|
|
412
|
-
* - `symbol`: `undefined`
|
|
413
|
-
* - `string`: `""`
|
|
414
|
-
* - `object`: `{}`
|
|
415
|
-
* - `number`: `0`
|
|
416
|
-
* - `boolean`: `true`
|
|
417
|
-
* - `bigint`: `0n`
|
|
418
|
-
* - `function`: an empty function
|
|
419
|
-
*
|
|
420
|
-
* @example
|
|
421
|
-
* const defaultString = Array.kTypeDefaults.string
|
|
422
|
-
* console.log(defaultString) // Output: ""
|
|
423
|
-
*
|
|
424
|
-
* const defaultNumber = Array.kTypeDefaults.number
|
|
425
|
-
* console.log(defaultNumber) // Output: 0
|
|
426
|
-
*/
|
|
427
|
-
get [Symbol.for('@nejs.defaults.by.type')]() {
|
|
428
|
-
return {
|
|
429
|
-
undefined: undefined,
|
|
430
|
-
symbol: undefined,
|
|
431
|
-
string: "",
|
|
432
|
-
object: {},
|
|
433
|
-
number: 0,
|
|
434
|
-
boolean: true,
|
|
435
|
-
bigint: 0n,
|
|
436
|
-
function() { },
|
|
437
|
-
};
|
|
438
|
-
},
|
|
439
|
-
/**
|
|
440
|
-
* @property {symbol} kDefaultsByType
|
|
441
|
-
* @description
|
|
442
|
-
* A unique symbol that represents the key for accessing
|
|
443
|
-
* the default values for different types.
|
|
444
|
-
*
|
|
445
|
-
* This symbol is created using `Symbol.for()` with the key
|
|
446
|
-
* `'@nejs.defaults.by.type'`. It can be used to retrieve
|
|
447
|
-
* the default values object from other parts of the code.
|
|
448
|
-
*
|
|
449
|
-
* @example
|
|
450
|
-
* const defaultsByType = Array[Array.kDefaultsByType]
|
|
451
|
-
* console.log(defaultsByType.string) // Output: ""
|
|
452
|
-
* console.log(defaultsByType.number) // Output: 0
|
|
453
|
-
*
|
|
454
|
-
* @returns {symbol} The unique symbol for accessing the
|
|
455
|
-
* default values by type.
|
|
456
|
-
*/
|
|
457
|
-
get kDefaultsByType() {
|
|
458
|
-
return Symbol.for('@nejs.defaults.by.type');
|
|
459
|
-
},
|
|
460
|
-
},
|
|
461
|
-
});
|
|
462
|
-
// NOTE to self; this is repeated here otherwise a circular reference from
|
|
463
|
-
// Object<->Function<->Global occurs. See original source in global.this.js
|
|
464
|
-
// {@see globalThis.isThenElse}
|
|
465
|
-
function isThenElse(bv, tv, ev) {
|
|
466
|
-
function isFunction(value) { typeof value === 'function'; }
|
|
467
|
-
if (arguments.length > 1) {
|
|
468
|
-
var _then = isFunction(tv) ? tv(bv) : tv;
|
|
469
|
-
if (arguments.length > 2) {
|
|
470
|
-
var _else = isFunction(ev) ? tv(bv) : ev;
|
|
471
|
-
return bv ? _then : _else;
|
|
472
|
-
}
|
|
473
|
-
return bv || _then;
|
|
474
|
-
}
|
|
475
|
-
return bv;
|
|
476
|
-
}
|
|
477
|
-
//# sourceMappingURL=array.extensions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array.extensions.js","sourceRoot":"","sources":["../../src/array.extensions.js"],"names":[],"mappings":";;;AAAA,+CAAuC;AAEvC;;;;;;;;;;;;;;;;;GAiBG;AACU,QAAA,eAAe,GAAG,IAAI,iBAAK,CAAC,KAAK,EAAE;IAC9C;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS;QACjC,OAAO,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,CAAA;IAC/D,CAAC;CACF,CAAC,CAAA;AAEF,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,uBAAe,CAAC,OAAO,CAAA;AAErD,4CAA4C;AAC5C,yDAAyD;AACzD,sDAAsD;AAEtD;;;;;;;;;;;;;;;;;GAiBG;AACU,QAAA,wBAAwB,GAAG,IAAI,iBAAK,CAAC,KAAK,CAAC,SAAS,EAAE;IACjE,CAAC,iBAAK,CAAC,cAAc,CAAC,EAAE;QACtB;;;;;;;;WAQG;QACH,QAAQ,CAAC,KAAK;YACZ,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,CAAA;QAC9C,CAAC;QAED;;;;;;;;WAQG;QACH,SAAS,CAAC,MAAM;YACd,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAA;YAC9B,MAAM,KAAK,GAAG,CAAC,CAAA;YAEf,KAAK,IAAI,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC1B,IAAI,MAAM,CAAC,KAAK,CAAC,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CAAC;YAAC,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAA;QACrE,CAAC;QAAC,OAAO,EAAE,IAAI,KAAK,CAAC;IACvB,CAAC;IAAC,OAAO,EAAE,CAAA;AACb,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `BigIntExtensions` is a patch for the JavaScript built-in `BigInt` class.
|
|
3
|
-
* It adds utility methods to the `BigInt` class without modifying the global
|
|
4
|
-
* namespace directly. This patch includes methods for checking if a value is
|
|
5
|
-
* a `BigInt` and conditionally returning a value based on whether the supplied
|
|
6
|
-
* value is a `BigInt` or not.
|
|
7
|
-
*
|
|
8
|
-
* @type {Patch}
|
|
9
|
-
* @example
|
|
10
|
-
* import { BigIntExtensions } from 'big.int.extension.js'
|
|
11
|
-
*
|
|
12
|
-
* BigIntExtensions.apply()
|
|
13
|
-
* // Now the `BigInt` class has additional methods available
|
|
14
|
-
*/
|
|
15
|
-
export const BigIntExtensions: Patch;
|
|
16
|
-
/**
|
|
17
|
-
* `BigIntPrototypeExtensions` is a patch for the JavaScript built-in
|
|
18
|
-
* `BigInt.prototype`. It adds utility methods to the `BigInt` prototype
|
|
19
|
-
* without modifying the global namespace directly. This patch includes
|
|
20
|
-
* methods for checking if a value is a BigInt and conditionally returning
|
|
21
|
-
* a value based on whether the supplied value is a BigInt or not.
|
|
22
|
-
*
|
|
23
|
-
* @type {Patch}
|
|
24
|
-
* @example
|
|
25
|
-
* import { BigIntPrototypeExtensions } from 'big.int.extension.js'
|
|
26
|
-
*
|
|
27
|
-
* BigIntPrototypeExtensions.apply()
|
|
28
|
-
* // Now the `BigInt` prototype has additional methods available
|
|
29
|
-
*/
|
|
30
|
-
export const BigIntPrototypeExtensions: Patch;
|
|
31
|
-
import { Patch } from '@nejs/extension';
|