es-toolkit 1.9.0 → 1.10.0-dev.204
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/CHANGELOG.md +22 -1
- package/README.md +1 -1
- package/dist/array/chunk.mjs +1 -1
- package/dist/array/compact.mjs +1 -1
- package/dist/array/countBy.mjs +1 -1
- package/dist/array/difference.mjs +1 -1
- package/dist/array/differenceBy.mjs +1 -1
- package/dist/array/differenceWith.mjs +1 -1
- package/dist/array/drop.mjs +1 -1
- package/dist/array/dropRight.mjs +1 -1
- package/dist/array/dropRightWhile.mjs +1 -1
- package/dist/array/dropWhile.mjs +1 -1
- package/dist/array/fill.mjs +1 -1
- package/dist/array/flatten.mjs +1 -1
- package/dist/array/flattenDeep.d.mts +25 -0
- package/dist/array/flattenDeep.d.ts +25 -0
- package/dist/array/flattenDeep.js +52 -0
- package/dist/array/flattenDeep.js.map +1 -0
- package/dist/array/flattenDeep.mjs +9 -0
- package/dist/array/forEachRight.mjs +1 -1
- package/dist/array/groupBy.mjs +1 -1
- package/dist/array/head.mjs +1 -1
- package/dist/array/index.d.mts +4 -0
- package/dist/array/index.d.ts +4 -0
- package/dist/array/index.js +38 -0
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +45 -29
- package/dist/array/initial.d.mts +26 -0
- package/dist/array/initial.d.ts +26 -0
- package/dist/array/initial.js +36 -0
- package/dist/array/initial.js.map +1 -0
- package/dist/array/initial.mjs +8 -0
- package/dist/array/intersection.mjs +1 -1
- package/dist/array/intersectionBy.mjs +1 -1
- package/dist/array/intersectionWith.mjs +1 -1
- package/dist/array/keyBy.mjs +1 -1
- package/dist/array/last.d.mts +25 -0
- package/dist/array/last.d.ts +25 -0
- package/dist/array/last.js +33 -0
- package/dist/array/last.js.map +1 -0
- package/dist/array/last.mjs +8 -0
- package/dist/array/maxBy.mjs +1 -1
- package/dist/array/minBy.mjs +1 -1
- package/dist/array/orderBy.mjs +1 -1
- package/dist/array/partition.mjs +1 -1
- package/dist/array/sample.mjs +1 -1
- package/dist/array/sampleSize.mjs +1 -1
- package/dist/array/shuffle.mjs +1 -1
- package/dist/array/tail.mjs +1 -1
- package/dist/array/take.mjs +1 -1
- package/dist/array/takeRight.mjs +1 -1
- package/dist/array/takeRightWhile.mjs +1 -1
- package/dist/array/takeWhile.mjs +1 -1
- package/dist/array/toFilled.d.mts +33 -0
- package/dist/array/toFilled.d.ts +33 -0
- package/dist/array/toFilled.js +40 -0
- package/dist/array/toFilled.js.map +1 -0
- package/dist/array/toFilled.mjs +8 -0
- package/dist/array/union.mjs +1 -1
- package/dist/array/unionBy.mjs +1 -1
- package/dist/array/unionWith.mjs +1 -1
- package/dist/array/uniq.mjs +1 -1
- package/dist/array/uniqBy.mjs +1 -1
- package/dist/array/uniqWith.mjs +1 -1
- package/dist/array/unzip.mjs +1 -1
- package/dist/array/unzipWith.mjs +1 -1
- package/dist/array/without.mjs +1 -1
- package/dist/array/xor.mjs +1 -1
- package/dist/array/xorBy.mjs +1 -1
- package/dist/array/xorWith.mjs +1 -1
- package/dist/array/zip.mjs +1 -1
- package/dist/array/zipObject.mjs +1 -1
- package/dist/array/zipWith.mjs +1 -1
- package/dist/chunk-236H5JZJ.mjs +1 -0
- package/dist/chunk-2HIMLZE3.mjs +46 -0
- package/dist/chunk-2HIMLZE3.mjs.map +1 -0
- package/dist/chunk-2MRZANXZ.mjs +1 -0
- package/dist/chunk-2MRZANXZ.mjs.map +1 -0
- package/dist/chunk-2SLTL4KL.mjs +13 -0
- package/dist/{chunk-NOFHNJ5C.mjs.map → chunk-2SLTL4KL.mjs.map} +1 -1
- package/dist/{chunk-QZITBKWX.mjs → chunk-4E4D3BMI.mjs} +2 -2
- package/dist/chunk-5IKVJGHO.mjs +14 -0
- package/dist/chunk-5IKVJGHO.mjs.map +1 -0
- package/dist/chunk-ASJF5D6C.mjs +1 -0
- package/dist/chunk-ASJF5D6C.mjs.map +1 -0
- package/dist/chunk-BOOQBJN2.mjs +9 -0
- package/dist/chunk-BOOQBJN2.mjs.map +1 -0
- package/dist/chunk-EYYZQFOP.mjs +14 -0
- package/dist/chunk-EYYZQFOP.mjs.map +1 -0
- package/dist/chunk-F3WCQQET.mjs +14 -0
- package/dist/chunk-F3WCQQET.mjs.map +1 -0
- package/dist/{chunk-LT6E4Y4Z.mjs → chunk-GDC64SYJ.mjs} +2 -2
- package/dist/{chunk-SDIMTYZW.mjs → chunk-IZAD2S7R.mjs} +2 -2
- package/dist/chunk-JYSV56US.mjs +41 -0
- package/dist/chunk-JYSV56US.mjs.map +1 -0
- package/dist/chunk-KPBQ7OUY.mjs +9 -0
- package/dist/chunk-KPBQ7OUY.mjs.map +1 -0
- package/dist/chunk-ML727RRJ.mjs +13 -0
- package/dist/chunk-ML727RRJ.mjs.map +1 -0
- package/dist/chunk-NKLIE2OI.mjs +1 -0
- package/dist/chunk-NKLIE2OI.mjs.map +1 -0
- package/dist/chunk-OP4OAKQJ.mjs +16 -0
- package/dist/chunk-OP4OAKQJ.mjs.map +1 -0
- package/dist/chunk-OSOLEQLZ.mjs +1 -0
- package/dist/chunk-OSOLEQLZ.mjs.map +1 -0
- package/dist/chunk-QKYYOLJ6.mjs +1 -0
- package/dist/chunk-QKYYOLJ6.mjs.map +1 -0
- package/dist/chunk-U4JGKZ56.mjs +41 -0
- package/dist/chunk-U4JGKZ56.mjs.map +1 -0
- package/dist/chunk-U56ZOM7L.mjs +9 -0
- package/dist/chunk-U56ZOM7L.mjs.map +1 -0
- package/dist/chunk-WMM7TZLG.mjs +9 -0
- package/dist/{chunk-OHQAR5AU.mjs.map → chunk-WMM7TZLG.mjs.map} +1 -1
- package/dist/chunk-WVQ7YVRK.mjs +11 -0
- package/dist/chunk-WVQ7YVRK.mjs.map +1 -0
- package/dist/chunk-XGCYC4YA.mjs +5516 -0
- package/dist/chunk-XGCYC4YA.mjs.map +1 -0
- package/dist/chunk-XPSOKBRZ.mjs +12 -0
- package/dist/chunk-XPSOKBRZ.mjs.map +1 -0
- package/dist/compat/index.d.mts +108 -0
- package/dist/compat/index.d.ts +108 -0
- package/dist/compat/index.js +6578 -0
- package/dist/compat/index.js.map +1 -0
- package/dist/compat/index.mjs +351 -0
- package/dist/compat/index.mjs.map +1 -0
- package/dist/error/AbortError.mjs +1 -1
- package/dist/error/index.mjs +1 -1
- package/dist/function/debounce.mjs +1 -1
- package/dist/function/index.d.mts +1 -0
- package/dist/function/index.d.ts +1 -0
- package/dist/function/index.js +7 -0
- package/dist/function/index.js.map +1 -1
- package/dist/function/index.mjs +8 -4
- package/dist/function/negate.d.mts +10 -0
- package/dist/function/negate.d.ts +10 -0
- package/dist/function/negate.js +33 -0
- package/dist/function/negate.js.map +1 -0
- package/dist/function/negate.mjs +8 -0
- package/dist/function/negate.mjs.map +1 -0
- package/dist/function/noop.mjs +1 -1
- package/dist/function/once.mjs +1 -1
- package/dist/function/throttle.mjs +1 -1
- package/dist/index.d.mts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +5681 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +101 -50
- package/dist/math/clamp.mjs +1 -1
- package/dist/math/inRange.mjs +1 -1
- package/dist/math/index.js +2 -2
- package/dist/math/index.js.map +1 -1
- package/dist/math/index.mjs +9 -9
- package/dist/math/mean.js +2 -2
- package/dist/math/mean.js.map +1 -1
- package/dist/math/mean.mjs +3 -3
- package/dist/math/meanBy.js +2 -2
- package/dist/math/meanBy.js.map +1 -1
- package/dist/math/meanBy.mjs +4 -4
- package/dist/math/random.mjs +1 -1
- package/dist/math/randomInt.mjs +1 -1
- package/dist/math/range.mjs +1 -1
- package/dist/math/round.mjs +1 -1
- package/dist/math/sum.js +2 -2
- package/dist/math/sum.js.map +1 -1
- package/dist/math/sum.mjs +2 -2
- package/dist/object/clone.d.mts +31 -0
- package/dist/object/clone.d.ts +31 -0
- package/dist/object/clone.js +65 -0
- package/dist/object/clone.js.map +1 -0
- package/dist/object/clone.mjs +8 -0
- package/dist/object/clone.mjs.map +1 -0
- package/dist/object/index.d.mts +1 -0
- package/dist/object/index.d.ts +1 -0
- package/dist/object/index.js +39 -0
- package/dist/object/index.js.map +1 -1
- package/dist/object/index.mjs +7 -3
- package/dist/object/invert.mjs +1 -1
- package/dist/object/omit.mjs +2 -2
- package/dist/object/omitBy.mjs +1 -1
- package/dist/object/pick.mjs +1 -1
- package/dist/object/pickBy.mjs +1 -1
- package/dist/predicate/index.d.mts +1 -0
- package/dist/predicate/index.d.ts +1 -0
- package/dist/predicate/index.js +46 -1
- package/dist/predicate/index.js.map +1 -1
- package/dist/predicate/index.mjs +9 -3
- package/dist/predicate/isEqual.d.mts +17 -0
- package/dist/predicate/isEqual.d.ts +17 -0
- package/dist/predicate/isEqual.js +73 -0
- package/dist/predicate/isEqual.js.map +1 -0
- package/dist/predicate/isEqual.mjs +10 -0
- package/dist/predicate/isEqual.mjs.map +1 -0
- package/dist/predicate/isNil.js +1 -1
- package/dist/predicate/isNil.js.map +1 -1
- package/dist/predicate/isNil.mjs +2 -2
- package/dist/predicate/isNotNil.mjs +1 -1
- package/dist/predicate/isNull.mjs +1 -1
- package/dist/predicate/isUndefined.mjs +1 -1
- package/dist/promise/delay.mjs +1 -1
- package/dist/promise/index.mjs +1 -1
- package/dist/string/camelCase.d.mts +17 -0
- package/dist/string/camelCase.d.ts +17 -0
- package/dist/string/camelCase.js +5554 -0
- package/dist/string/camelCase.js.map +1 -0
- package/dist/string/camelCase.mjs +9 -0
- package/dist/string/camelCase.mjs.map +1 -0
- package/dist/string/capitalize.d.mts +14 -0
- package/dist/string/capitalize.d.ts +14 -0
- package/dist/string/capitalize.js +33 -0
- package/dist/string/capitalize.js.map +1 -0
- package/dist/string/capitalize.mjs +8 -0
- package/dist/string/capitalize.mjs.map +1 -0
- package/dist/string/index.d.mts +5 -0
- package/dist/string/index.d.ts +5 -0
- package/dist/string/index.js +5587 -0
- package/dist/string/index.js.map +1 -0
- package/dist/string/index.mjs +26 -0
- package/dist/string/index.mjs.map +1 -0
- package/dist/string/kebabCase.d.mts +17 -0
- package/dist/string/kebabCase.d.ts +17 -0
- package/dist/string/kebabCase.js +43 -0
- package/dist/string/kebabCase.js.map +1 -0
- package/dist/string/kebabCase.mjs +9 -0
- package/dist/string/kebabCase.mjs.map +1 -0
- package/dist/string/lowerCase.d.mts +17 -0
- package/dist/string/lowerCase.d.ts +17 -0
- package/dist/string/lowerCase.js +43 -0
- package/dist/string/lowerCase.js.map +1 -0
- package/dist/string/lowerCase.mjs +9 -0
- package/dist/string/lowerCase.mjs.map +1 -0
- package/dist/string/snakeCase.d.mts +17 -0
- package/dist/string/snakeCase.d.ts +17 -0
- package/dist/string/snakeCase.js +43 -0
- package/dist/string/snakeCase.js.map +1 -0
- package/dist/string/snakeCase.mjs +9 -0
- package/dist/string/snakeCase.mjs.map +1 -0
- package/package.json +21 -1
- package/string.d.ts +1 -0
- package/dist/chunk-2MM5EJJX.mjs +0 -21
- package/dist/chunk-LOY6PATI.mjs +0 -1
- package/dist/chunk-MAJSPFA6.mjs +0 -1
- package/dist/chunk-N6EM6ETS.mjs +0 -1
- package/dist/chunk-NOFHNJ5C.mjs +0 -13
- package/dist/chunk-OHQAR5AU.mjs +0 -9
- package/dist/chunk-PMHULJNL.mjs +0 -1
- /package/dist/{chunk-2MM5EJJX.mjs.map → array/flattenDeep.mjs.map} +0 -0
- /package/dist/{chunk-LOY6PATI.mjs.map → array/initial.mjs.map} +0 -0
- /package/dist/{chunk-MAJSPFA6.mjs.map → array/last.mjs.map} +0 -0
- /package/dist/{chunk-N6EM6ETS.mjs.map → array/toFilled.mjs.map} +0 -0
- /package/dist/{chunk-PMHULJNL.mjs.map → chunk-236H5JZJ.mjs.map} +0 -0
- /package/dist/{chunk-QZITBKWX.mjs.map → chunk-4E4D3BMI.mjs.map} +0 -0
- /package/dist/{chunk-LT6E4Y4Z.mjs.map → chunk-GDC64SYJ.mjs.map} +0 -0
- /package/dist/{chunk-SDIMTYZW.mjs.map → chunk-IZAD2S7R.mjs.map} +0 -0
package/dist/array/keyBy.mjs
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the last element of an array.
|
|
3
|
+
*
|
|
4
|
+
* This function takes an array and returns the last element of the array.
|
|
5
|
+
* If the array is empty, the function returns `undefined`.
|
|
6
|
+
*
|
|
7
|
+
* Unlike some implementations, this function is optimized for performance
|
|
8
|
+
* by directly accessing the last index of the array.
|
|
9
|
+
*
|
|
10
|
+
* @param {T[]} arr - The array from which to get the last element.
|
|
11
|
+
* @returns {T | undefined} The last element of the array, or `undefined` if the array is empty.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const arr = [1, 2, 3];
|
|
15
|
+
* const lastElement = last(arr);
|
|
16
|
+
* // lastElement will be 3
|
|
17
|
+
*
|
|
18
|
+
* const emptyArr: number[] = [];
|
|
19
|
+
* const noElement = last(emptyArr);
|
|
20
|
+
* // noElement will be undefined
|
|
21
|
+
*/
|
|
22
|
+
declare function last<T>(arr: readonly [...T[], T]): T;
|
|
23
|
+
declare function last<T>(arr: readonly T[]): T | undefined;
|
|
24
|
+
|
|
25
|
+
export { last };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the last element of an array.
|
|
3
|
+
*
|
|
4
|
+
* This function takes an array and returns the last element of the array.
|
|
5
|
+
* If the array is empty, the function returns `undefined`.
|
|
6
|
+
*
|
|
7
|
+
* Unlike some implementations, this function is optimized for performance
|
|
8
|
+
* by directly accessing the last index of the array.
|
|
9
|
+
*
|
|
10
|
+
* @param {T[]} arr - The array from which to get the last element.
|
|
11
|
+
* @returns {T | undefined} The last element of the array, or `undefined` if the array is empty.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const arr = [1, 2, 3];
|
|
15
|
+
* const lastElement = last(arr);
|
|
16
|
+
* // lastElement will be 3
|
|
17
|
+
*
|
|
18
|
+
* const emptyArr: number[] = [];
|
|
19
|
+
* const noElement = last(emptyArr);
|
|
20
|
+
* // noElement will be undefined
|
|
21
|
+
*/
|
|
22
|
+
declare function last<T>(arr: readonly [...T[], T]): T;
|
|
23
|
+
declare function last<T>(arr: readonly T[]): T | undefined;
|
|
24
|
+
|
|
25
|
+
export { last };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/array/last.ts
|
|
21
|
+
var last_exports = {};
|
|
22
|
+
__export(last_exports, {
|
|
23
|
+
last: () => last
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(last_exports);
|
|
26
|
+
function last(arr) {
|
|
27
|
+
return arr[arr.length - 1];
|
|
28
|
+
}
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
last
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=last.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/array/last.ts"],"sourcesContent":["/**\n * Returns the last element of an array.\n *\n * This function takes an array and returns the last element of the array.\n * If the array is empty, the function returns `undefined`.\n *\n * Unlike some implementations, this function is optimized for performance\n * by directly accessing the last index of the array.\n *\n * @param {T[]} arr - The array from which to get the last element.\n * @returns {T | undefined} The last element of the array, or `undefined` if the array is empty.\n *\n * @example\n * const arr = [1, 2, 3];\n * const lastElement = last(arr);\n * // lastElement will be 3\n *\n * const emptyArr: number[] = [];\n * const noElement = last(emptyArr);\n * // noElement will be undefined\n */\n\nexport function last<T>(arr: readonly [...T[], T]): T;\nexport function last<T>(arr: readonly T[]): T | undefined;\nexport function last<T>(arr: readonly T[]): T | undefined {\n return arr[arr.length - 1];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAwBO,SAAS,KAAQ,KAAkC;AACxD,SAAO,IAAI,IAAI,SAAS,CAAC;AAC3B;","names":[]}
|
package/dist/array/maxBy.mjs
CHANGED
package/dist/array/minBy.mjs
CHANGED
package/dist/array/orderBy.mjs
CHANGED
package/dist/array/partition.mjs
CHANGED
package/dist/array/sample.mjs
CHANGED
package/dist/array/shuffle.mjs
CHANGED
package/dist/array/tail.mjs
CHANGED
package/dist/array/take.mjs
CHANGED
package/dist/array/takeRight.mjs
CHANGED
package/dist/array/takeWhile.mjs
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new array filled with the specified value from the start position up to, but not including, the end position.
|
|
3
|
+
* This function does not mutate the original array.
|
|
4
|
+
*
|
|
5
|
+
* @param {Array<T>} arr - The array to base the new array on.
|
|
6
|
+
* @param {U} value - The value to fill the new array with.
|
|
7
|
+
* @param {number} [start=0] - The start position. Defaults to 0.
|
|
8
|
+
* @param {number} [end=arr.length] - The end position. Defaults to the array's length.
|
|
9
|
+
* @returns {Array<T | U>} The new array with the filled values.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const array = [1, 2, 3, 4, 5];
|
|
13
|
+
* let result = toFilled(array, '*', 2);
|
|
14
|
+
* console.log(result); // [1, 2, '*', '*', '*']
|
|
15
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
16
|
+
*
|
|
17
|
+
* result = toFilled(array, '*', 1, 4);
|
|
18
|
+
* console.log(result); // [1, '*', '*', '*', 5]
|
|
19
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
20
|
+
*
|
|
21
|
+
* result = toFilled(array, '*');
|
|
22
|
+
* console.log(result); // ['*', '*', '*', '*', '*']
|
|
23
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
24
|
+
*
|
|
25
|
+
* result = toFilled(array, '*', -4, -1);
|
|
26
|
+
* console.log(result); // [1, '*', '*', '*', 5]
|
|
27
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
28
|
+
*/
|
|
29
|
+
declare function toFilled<T, U>(arr: T[], value: U): Array<T | U>;
|
|
30
|
+
declare function toFilled<T, U>(arr: T[], value: U, start: number): Array<T | U>;
|
|
31
|
+
declare function toFilled<T, U>(arr: T[], value: U, start: number, end: number): Array<T | U>;
|
|
32
|
+
|
|
33
|
+
export { toFilled };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new array filled with the specified value from the start position up to, but not including, the end position.
|
|
3
|
+
* This function does not mutate the original array.
|
|
4
|
+
*
|
|
5
|
+
* @param {Array<T>} arr - The array to base the new array on.
|
|
6
|
+
* @param {U} value - The value to fill the new array with.
|
|
7
|
+
* @param {number} [start=0] - The start position. Defaults to 0.
|
|
8
|
+
* @param {number} [end=arr.length] - The end position. Defaults to the array's length.
|
|
9
|
+
* @returns {Array<T | U>} The new array with the filled values.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const array = [1, 2, 3, 4, 5];
|
|
13
|
+
* let result = toFilled(array, '*', 2);
|
|
14
|
+
* console.log(result); // [1, 2, '*', '*', '*']
|
|
15
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
16
|
+
*
|
|
17
|
+
* result = toFilled(array, '*', 1, 4);
|
|
18
|
+
* console.log(result); // [1, '*', '*', '*', 5]
|
|
19
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
20
|
+
*
|
|
21
|
+
* result = toFilled(array, '*');
|
|
22
|
+
* console.log(result); // ['*', '*', '*', '*', '*']
|
|
23
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
24
|
+
*
|
|
25
|
+
* result = toFilled(array, '*', -4, -1);
|
|
26
|
+
* console.log(result); // [1, '*', '*', '*', 5]
|
|
27
|
+
* console.log(array); // [1, 2, 3, 4, 5]
|
|
28
|
+
*/
|
|
29
|
+
declare function toFilled<T, U>(arr: T[], value: U): Array<T | U>;
|
|
30
|
+
declare function toFilled<T, U>(arr: T[], value: U, start: number): Array<T | U>;
|
|
31
|
+
declare function toFilled<T, U>(arr: T[], value: U, start: number, end: number): Array<T | U>;
|
|
32
|
+
|
|
33
|
+
export { toFilled };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/array/toFilled.ts
|
|
21
|
+
var toFilled_exports = {};
|
|
22
|
+
__export(toFilled_exports, {
|
|
23
|
+
toFilled: () => toFilled
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(toFilled_exports);
|
|
26
|
+
function toFilled(arr, value, start = 0, end = arr.length) {
|
|
27
|
+
const length = arr.length;
|
|
28
|
+
const finalStart = Math.max(start >= 0 ? start : length + start, 0);
|
|
29
|
+
const finalEnd = Math.min(end >= 0 ? end : length + end, length);
|
|
30
|
+
const newArr = arr.slice();
|
|
31
|
+
for (let i = finalStart; i < finalEnd; i++) {
|
|
32
|
+
newArr[i] = value;
|
|
33
|
+
}
|
|
34
|
+
return newArr;
|
|
35
|
+
}
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
toFilled
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=toFilled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/array/toFilled.ts"],"sourcesContent":["/**\n * Creates a new array filled with the specified value from the start position up to, but not including, the end position.\n * This function does not mutate the original array.\n *\n * @param {Array<T>} arr - The array to base the new array on.\n * @param {U} value - The value to fill the new array with.\n * @param {number} [start=0] - The start position. Defaults to 0.\n * @param {number} [end=arr.length] - The end position. Defaults to the array's length.\n * @returns {Array<T | U>} The new array with the filled values.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * let result = toFilled(array, '*', 2);\n * console.log(result); // [1, 2, '*', '*', '*']\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*', 1, 4);\n * console.log(result); // [1, '*', '*', '*', 5]\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*');\n * console.log(result); // ['*', '*', '*', '*', '*']\n * console.log(array); // [1, 2, 3, 4, 5]\n *\n * result = toFilled(array, '*', -4, -1);\n * console.log(result); // [1, '*', '*', '*', 5]\n * console.log(array); // [1, 2, 3, 4, 5]\n */\n\nexport function toFilled<T, U>(arr: T[], value: U): Array<T | U>;\nexport function toFilled<T, U>(arr: T[], value: U, start: number): Array<T | U>;\nexport function toFilled<T, U>(arr: T[], value: U, start: number, end: number): Array<T | U>;\nexport function toFilled<T, U>(arr: T[], value: U, start = 0, end = arr.length): Array<T | U> {\n const length = arr.length;\n const finalStart = Math.max(start >= 0 ? start : length + start, 0);\n const finalEnd = Math.min(end >= 0 ? end : length + end, length);\n\n const newArr: Array<T | U> = arr.slice();\n\n for (let i = finalStart; i < finalEnd; i++) {\n newArr[i] = value;\n }\n\n return newArr;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgCO,SAAS,SAAe,KAAU,OAAU,QAAQ,GAAG,MAAM,IAAI,QAAsB;AAC5F,QAAM,SAAS,IAAI;AACnB,QAAM,aAAa,KAAK,IAAI,SAAS,IAAI,QAAQ,SAAS,OAAO,CAAC;AAClE,QAAM,WAAW,KAAK,IAAI,OAAO,IAAI,MAAM,SAAS,KAAK,MAAM;AAE/D,QAAM,SAAuB,IAAI,MAAM;AAEvC,WAAS,IAAI,YAAY,IAAI,UAAU,KAAK;AAC1C,WAAO,CAAC,IAAI;AAAA,EACd;AAEA,SAAO;AACT;","names":[]}
|
package/dist/array/union.mjs
CHANGED
package/dist/array/unionBy.mjs
CHANGED
package/dist/array/unionWith.mjs
CHANGED
package/dist/array/uniq.mjs
CHANGED
package/dist/array/uniqBy.mjs
CHANGED
package/dist/array/uniqWith.mjs
CHANGED
package/dist/array/unzip.mjs
CHANGED
package/dist/array/unzipWith.mjs
CHANGED
package/dist/array/without.mjs
CHANGED
package/dist/array/xor.mjs
CHANGED
package/dist/array/xorBy.mjs
CHANGED
package/dist/array/xorWith.mjs
CHANGED
package/dist/array/zip.mjs
CHANGED
package/dist/array/zipObject.mjs
CHANGED
package/dist/array/zipWith.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-236H5JZJ.mjs.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
22
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
23
|
+
};
|
|
24
|
+
var __copyProps = (to, from, except, desc) => {
|
|
25
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
26
|
+
for (let key of __getOwnPropNames(from))
|
|
27
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
28
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
29
|
+
}
|
|
30
|
+
return to;
|
|
31
|
+
};
|
|
32
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
33
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
34
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
35
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
36
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
37
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
38
|
+
mod
|
|
39
|
+
));
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
__spreadValues,
|
|
43
|
+
__commonJS,
|
|
44
|
+
__toESM
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=chunk-2HIMLZE3.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-2MRZANXZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/math/sum.ts"],"sourcesContent":["/**\n * Calculates the sum of an array of numbers.\n *\n * This function takes an array of numbers and returns the sum of all the elements in the array.\n *\n * @param {number[]} nums - An array of numbers to be summed.\n * @returns {number} The sum of all the numbers in the array.\n *\n * @example\n * const numbers = [1, 2, 3, 4, 5];\n * const result = sum(numbers);\n * // result will be 15\n */\nexport function sum(nums: readonly number[]): number {\n let result = 0;\n\n for (
|
|
1
|
+
{"version":3,"sources":["../src/math/sum.ts"],"sourcesContent":["/**\n * Calculates the sum of an array of numbers.\n *\n * This function takes an array of numbers and returns the sum of all the elements in the array.\n *\n * @param {number[]} nums - An array of numbers to be summed.\n * @returns {number} The sum of all the numbers in the array.\n *\n * @example\n * const numbers = [1, 2, 3, 4, 5];\n * const result = sum(numbers);\n * // result will be 15\n */\nexport function sum(nums: readonly number[]): number {\n let result = 0;\n\n for (let i = 0; i < nums.length; i++) {\n result += nums[i];\n }\n\n return result;\n}\n"],"mappings":";AAaO,SAAS,IAAI,MAAiC;AACnD,MAAI,SAAS;AAEb,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,cAAU,KAAK,CAAC;AAAA,EAClB;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__spreadValues
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2HIMLZE3.mjs";
|
|
4
4
|
|
|
5
5
|
// src/object/omit.ts
|
|
6
6
|
function omit(obj, keys) {
|
|
@@ -14,4 +14,4 @@ function omit(obj, keys) {
|
|
|
14
14
|
export {
|
|
15
15
|
omit
|
|
16
16
|
};
|
|
17
|
-
//# sourceMappingURL=chunk-
|
|
17
|
+
//# sourceMappingURL=chunk-4E4D3BMI.mjs.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getWords
|
|
3
|
+
} from "./chunk-WVQ7YVRK.mjs";
|
|
4
|
+
|
|
5
|
+
// src/string/lowerCase.ts
|
|
6
|
+
var lowerCase = (str) => {
|
|
7
|
+
const words = getWords(str);
|
|
8
|
+
return words.map((word) => word.toLowerCase()).join(" ");
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
lowerCase
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=chunk-5IKVJGHO.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/string/lowerCase.ts"],"sourcesContent":["import { getWords } from './_internal/getWords.ts';\n\n/**\n * Converts a string to lower case.\n *\n * Lower case is the naming convention in which each word is written in lowercase and separated by an space ( ) character.\n *\n * @param {string} str - The string that is to be changed to lower case.\n * @returns {string} - The converted string to lower case.\n *\n * @example\n * const convertedStr1 = lowerCase('camelCase') // returns 'camel case'\n * const convertedStr2 = lowerCase('some whitespace') // returns 'some whitespace'\n * const convertedStr3 = lowerCase('hyphen-text') // returns 'hyphen text'\n * const convertedStr4 = lowerCase('HTTPRequest') // returns 'http request'\n */\nexport const lowerCase = (str: string): string => {\n const words = getWords(str);\n return words.map(word => word.toLowerCase()).join(' ');\n};\n"],"mappings":";;;;;AAgBO,IAAM,YAAY,CAAC,QAAwB;AAChD,QAAM,QAAQ,SAAS,GAAG;AAC1B,SAAO,MAAM,IAAI,UAAQ,KAAK,YAAY,CAAC,EAAE,KAAK,GAAG;AACvD;","names":[]}
|