es-toolkit 1.13.1-dev.320 → 1.13.1-dev.322
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/dist/array/chunk.mjs +1 -1
- package/dist/array/compact.d.mts +1 -1
- package/dist/array/compact.d.ts +1 -1
- package/dist/array/compact.js.map +1 -1
- package/dist/array/compact.mjs +2 -2
- package/dist/array/countBy.js +1 -2
- package/dist/array/countBy.js.map +1 -1
- package/dist/array/countBy.mjs +2 -2
- 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.d.mts +1 -0
- package/dist/array/fill.d.ts +1 -0
- package/dist/array/fill.js.map +1 -1
- package/dist/array/fill.mjs +2 -2
- package/dist/array/flatMap.mjs +1 -1
- package/dist/array/flatten.mjs +1 -1
- package/dist/array/flattenDeep.mjs +1 -1
- package/dist/array/forEachRight.mjs +1 -1
- package/dist/array/groupBy.mjs +1 -1
- package/dist/array/head.d.mts +1 -0
- package/dist/array/head.d.ts +1 -0
- package/dist/array/head.js.map +1 -1
- package/dist/array/head.mjs +2 -2
- package/dist/array/index.js +1 -2
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +56 -56
- package/dist/array/initial.mjs +1 -1
- 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 +1 -0
- package/dist/array/last.d.ts +1 -0
- package/dist/array/last.js.map +1 -1
- package/dist/array/last.mjs +2 -2
- 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.d.mts +9 -4
- package/dist/array/tail.d.ts +9 -4
- package/dist/array/tail.js.map +1 -1
- package/dist/array/tail.mjs +2 -2
- 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 +2 -0
- package/dist/array/toFilled.d.ts +2 -0
- package/dist/array/toFilled.js.map +1 -1
- package/dist/array/toFilled.mjs +2 -2
- 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.d.mts +3 -2
- package/dist/array/unzip.d.ts +3 -2
- package/dist/array/unzip.js.map +1 -1
- package/dist/array/unzip.mjs +2 -2
- 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.d.mts +5 -0
- package/dist/array/zipWith.d.ts +5 -0
- package/dist/array/zipWith.js.map +1 -1
- package/dist/array/zipWith.mjs +2 -2
- package/dist/browser.js +22 -58
- package/dist/browser.js.map +1 -1
- package/dist/browser.mjs +54 -53
- package/dist/browser.mjs.map +1 -1
- package/dist/{chunk-QXTNZR7B.mjs → chunk-3SBT6WDU.mjs} +2 -2
- package/dist/{chunk-O64NE2P4.mjs → chunk-4DFAGGIM.mjs} +3 -3
- package/dist/{chunk-O64NE2P4.mjs.map → chunk-4DFAGGIM.mjs.map} +1 -1
- package/dist/{chunk-Y5V7UAZZ.mjs → chunk-4ZES5T6V.mjs} +4 -4
- package/dist/{chunk-TJ4Z5I7M.mjs → chunk-DLS7UJKJ.mjs} +1 -1
- package/dist/chunk-DLS7UJKJ.mjs.map +1 -0
- package/dist/{chunk-KPBQ7OUY.mjs → chunk-DTTKJ3VC.mjs} +1 -1
- package/dist/chunk-DTTKJ3VC.mjs.map +1 -0
- package/dist/{chunk-YNJH6GEG.mjs → chunk-EEHJ656S.mjs} +95 -92
- package/dist/chunk-EEHJ656S.mjs.map +1 -0
- package/dist/{chunk-EYYZQFOP.mjs → chunk-ET33L3MQ.mjs} +2 -2
- package/dist/chunk-EZYYB34V.mjs +17 -0
- package/dist/{chunk-CVVZHOJX.mjs.map → chunk-EZYYB34V.mjs.map} +1 -1
- package/dist/{chunk-HM2JT2RX.mjs → chunk-FZZNWXDM.mjs} +1 -1
- package/dist/chunk-FZZNWXDM.mjs.map +1 -0
- package/dist/{chunk-YFN6KOC4.mjs → chunk-GTFDDKZ2.mjs} +1 -1
- package/dist/chunk-GTFDDKZ2.mjs.map +1 -0
- package/dist/{chunk-F3WCQQET.mjs → chunk-IWXZI3QT.mjs} +2 -2
- package/dist/chunk-J5LGTIGS.mjs +10 -0
- package/dist/{chunk-UYZKMBDO.mjs → chunk-JCRY7ZYS.mjs} +1 -1
- package/dist/chunk-JCRY7ZYS.mjs.map +1 -0
- package/dist/{chunk-5CPXZFCB.mjs → chunk-K5WL54BY.mjs} +2 -2
- package/dist/{chunk-5CPXZFCB.mjs.map → chunk-K5WL54BY.mjs.map} +1 -1
- package/dist/{chunk-4KYXHZ4R.mjs → chunk-MJ7LNBI6.mjs} +1 -1
- package/dist/chunk-MJ7LNBI6.mjs.map +1 -0
- package/dist/{chunk-3IP4JVLL.mjs → chunk-MSHSKENG.mjs} +3 -3
- package/dist/{chunk-3IP4JVLL.mjs.map → chunk-MSHSKENG.mjs.map} +1 -1
- package/dist/{chunk-WVQ7YVRK.mjs → chunk-OG2RLT5U.mjs} +2 -3
- package/dist/{chunk-WVQ7YVRK.mjs.map → chunk-OG2RLT5U.mjs.map} +1 -1
- package/dist/{chunk-DTJJIMKJ.mjs → chunk-PJPGJ2O6.mjs} +1 -1
- package/dist/chunk-PJPGJ2O6.mjs.map +1 -0
- package/dist/chunk-R6GLTTAB.mjs +9 -0
- package/dist/chunk-R6GLTTAB.mjs.map +1 -0
- package/dist/{chunk-5IKVJGHO.mjs → chunk-RTFTLCF3.mjs} +2 -2
- package/dist/{chunk-OP4OAKQJ.mjs → chunk-XHSIT5DL.mjs} +1 -1
- package/dist/chunk-XHSIT5DL.mjs.map +1 -0
- package/dist/{chunk-WFZXCGEG.mjs → chunk-YOPFSFTD.mjs} +2 -6
- package/dist/{chunk-WFZXCGEG.mjs.map → chunk-YOPFSFTD.mjs.map} +1 -1
- package/dist/chunk-YXD3AQAK.mjs +1 -0
- package/dist/{chunk-CRSKT4WW.mjs → chunk-Z7HWEOQX.mjs} +2 -3
- package/dist/{chunk-CRSKT4WW.mjs.map → chunk-Z7HWEOQX.mjs.map} +1 -1
- package/dist/chunk-ZPNX2QDE.mjs +13 -0
- package/dist/{chunk-IIDZ3KAJ.mjs.map → chunk-ZPNX2QDE.mjs.map} +1 -1
- package/dist/compat/index.d.mts +3 -1
- package/dist/compat/index.d.ts +3 -1
- package/dist/compat/index.js +23 -57
- package/dist/compat/index.js.map +1 -1
- package/dist/compat/index.mjs +98 -94
- package/dist/error/AbortError.mjs +1 -1
- package/dist/error/TimeoutError.mjs +1 -1
- package/dist/error/index.mjs +4 -4
- package/dist/function/after.mjs +1 -1
- package/dist/function/debounce.js +2 -2
- package/dist/function/debounce.js.map +1 -1
- package/dist/function/debounce.mjs +2 -2
- package/dist/function/index.js +2 -2
- package/dist/function/index.js.map +1 -1
- package/dist/function/index.mjs +10 -10
- package/dist/function/negate.mjs +1 -1
- 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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +20 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -93
- package/dist/math/clamp.mjs +1 -1
- package/dist/math/inRange.mjs +1 -1
- package/dist/math/index.mjs +1 -1
- package/dist/math/mean.mjs +1 -1
- package/dist/math/meanBy.mjs +1 -1
- 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.mjs +1 -1
- package/dist/math/sumBy.mjs +1 -1
- package/dist/object/clone.mjs +1 -1
- package/dist/object/cloneDeep.js +1 -1
- package/dist/object/cloneDeep.js.map +1 -1
- package/dist/object/cloneDeep.mjs +2 -2
- package/dist/object/flattenObject.mjs +1 -1
- package/dist/object/index.js +2 -16
- package/dist/object/index.js.map +1 -1
- package/dist/object/index.mjs +3 -3
- package/dist/object/invert.mjs +1 -1
- package/dist/object/omit.js +1 -15
- package/dist/object/omit.js.map +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 +7 -0
- package/dist/predicate/index.js.map +1 -1
- package/dist/predicate/index.mjs +9 -5
- package/dist/predicate/isArrayLike.mjs +1 -1
- package/dist/predicate/isEqual.mjs +1 -1
- package/dist/predicate/isFunction.mjs +1 -1
- package/dist/predicate/isLength.mjs +1 -1
- package/dist/predicate/isNil.mjs +1 -1
- package/dist/predicate/isNotNil.mjs +1 -1
- package/dist/predicate/isNull.mjs +1 -1
- package/dist/predicate/isPlainObject.mjs +1 -1
- package/dist/predicate/isPrimitive.d.mts +17 -0
- package/dist/predicate/isPrimitive.d.ts +17 -0
- package/dist/predicate/isPrimitive.js +33 -0
- package/dist/predicate/isPrimitive.js.map +1 -0
- package/dist/predicate/isPrimitive.mjs +8 -0
- package/dist/predicate/isPrimitive.mjs.map +1 -0
- package/dist/predicate/isTypedArray.mjs +1 -1
- package/dist/predicate/isUndefined.mjs +1 -1
- package/dist/promise/delay.js +2 -2
- package/dist/promise/delay.js.map +1 -1
- package/dist/promise/delay.mjs +2 -2
- package/dist/promise/index.js +7 -31
- package/dist/promise/index.js.map +1 -1
- package/dist/promise/index.mjs +5 -5
- package/dist/promise/timeout.js +5 -27
- package/dist/promise/timeout.js.map +1 -1
- package/dist/promise/timeout.mjs +4 -4
- package/dist/promise/withTimeout.js +7 -31
- package/dist/promise/withTimeout.js.map +1 -1
- package/dist/promise/withTimeout.mjs +5 -5
- package/dist/string/camelCase.js +1 -2
- package/dist/string/camelCase.js.map +1 -1
- package/dist/string/camelCase.mjs +3 -3
- package/dist/string/capitalize.mjs +1 -1
- package/dist/string/index.js +1 -2
- package/dist/string/index.js.map +1 -1
- package/dist/string/index.mjs +9 -9
- package/dist/string/kebabCase.js +1 -2
- package/dist/string/kebabCase.js.map +1 -1
- package/dist/string/kebabCase.mjs +3 -3
- package/dist/string/lowerCase.js +1 -2
- package/dist/string/lowerCase.js.map +1 -1
- package/dist/string/lowerCase.mjs +3 -3
- package/dist/string/snakeCase.js +1 -2
- package/dist/string/snakeCase.js.map +1 -1
- package/dist/string/snakeCase.mjs +3 -3
- package/dist/string/startCase.js +1 -2
- package/dist/string/startCase.js.map +1 -1
- package/dist/string/startCase.mjs +3 -3
- package/package.json +1 -1
- package/umd/browser.global.js +1 -1
- package/dist/chunk-24FKGR6U.mjs +0 -47
- package/dist/chunk-4KYXHZ4R.mjs.map +0 -1
- package/dist/chunk-CVVZHOJX.mjs +0 -22
- package/dist/chunk-DTJJIMKJ.mjs.map +0 -1
- package/dist/chunk-HM2JT2RX.mjs.map +0 -1
- package/dist/chunk-IIDZ3KAJ.mjs +0 -18
- package/dist/chunk-KPBQ7OUY.mjs.map +0 -1
- package/dist/chunk-OP4OAKQJ.mjs.map +0 -1
- package/dist/chunk-STL6TD3L.mjs +0 -1
- package/dist/chunk-TJ4Z5I7M.mjs.map +0 -1
- package/dist/chunk-UYZKMBDO.mjs.map +0 -1
- package/dist/chunk-YFN6KOC4.mjs.map +0 -1
- package/dist/chunk-YNJH6GEG.mjs.map +0 -1
- /package/dist/{chunk-QXTNZR7B.mjs.map → chunk-3SBT6WDU.mjs.map} +0 -0
- /package/dist/{chunk-Y5V7UAZZ.mjs.map → chunk-4ZES5T6V.mjs.map} +0 -0
- /package/dist/{chunk-EYYZQFOP.mjs.map → chunk-ET33L3MQ.mjs.map} +0 -0
- /package/dist/{chunk-F3WCQQET.mjs.map → chunk-IWXZI3QT.mjs.map} +0 -0
- /package/dist/{chunk-24FKGR6U.mjs.map → chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/{chunk-5IKVJGHO.mjs.map → chunk-RTFTLCF3.mjs.map} +0 -0
- /package/dist/{chunk-STL6TD3L.mjs.map → chunk-YXD3AQAK.mjs.map} +0 -0
package/dist/array/chunk.mjs
CHANGED
package/dist/array/compact.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ type NotFalsey<T> = Exclude<T, false | null | 0 | '' | undefined>;
|
|
|
3
3
|
* Removes falsey values (false, null, 0, '', undefined, NaN) from an array.
|
|
4
4
|
*
|
|
5
5
|
* @template T - The type of elements in the array.
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {T[]} arr - The input array to remove falsey values.
|
|
7
7
|
* @returns {Array<Exclude<T, false | null | 0 | '' | undefined>>} - A new array with all falsey values removed.
|
|
8
8
|
*
|
|
9
9
|
* @example
|
package/dist/array/compact.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ type NotFalsey<T> = Exclude<T, false | null | 0 | '' | undefined>;
|
|
|
3
3
|
* Removes falsey values (false, null, 0, '', undefined, NaN) from an array.
|
|
4
4
|
*
|
|
5
5
|
* @template T - The type of elements in the array.
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {T[]} arr - The input array to remove falsey values.
|
|
7
7
|
* @returns {Array<Exclude<T, false | null | 0 | '' | undefined>>} - A new array with all falsey values removed.
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/compact.ts"],"sourcesContent":["type NotFalsey<T> = Exclude<T, false | null | 0 | '' | undefined>;\n\n/**\n * Removes falsey values (false, null, 0, '', undefined, NaN) from an array.\n *\n * @template T - The type of elements in the array.\n * @param {
|
|
1
|
+
{"version":3,"sources":["../../src/array/compact.ts"],"sourcesContent":["type NotFalsey<T> = Exclude<T, false | null | 0 | '' | undefined>;\n\n/**\n * Removes falsey values (false, null, 0, '', undefined, NaN) from an array.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The input array to remove falsey values.\n * @returns {Array<Exclude<T, false | null | 0 | '' | undefined>>} - A new array with all falsey values removed.\n *\n * @example\n * compact([0, 1, false, 2, '', 3, null, undefined, 4, NaN, 5]);\n * Returns: [1, 2, 3, 4, 5]\n */\nexport function compact<T>(arr: readonly T[]): Array<NotFalsey<T>> {\n const result: Array<NotFalsey<T>> = [];\n\n for (const item of arr) {\n if (item) {\n result.push(item as NotFalsey<T>);\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,QAAW,KAAwC;AACjE,QAAM,SAA8B,CAAC;AAErC,aAAW,QAAQ,KAAK;AACtB,QAAI,MAAM;AACR,aAAO,KAAK,IAAoB;AAAA,IAClC;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
package/dist/array/compact.mjs
CHANGED
package/dist/array/countBy.js
CHANGED
|
@@ -24,11 +24,10 @@ __export(countBy_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(countBy_exports);
|
|
26
26
|
function countBy(arr, mapper) {
|
|
27
|
-
var _a;
|
|
28
27
|
const result = {};
|
|
29
28
|
for (const item of arr) {
|
|
30
29
|
const key = mapper(item);
|
|
31
|
-
result[key] = (
|
|
30
|
+
result[key] = (result[key] ?? 0) + 1;
|
|
32
31
|
}
|
|
33
32
|
return result;
|
|
34
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/countBy.ts"],"sourcesContent":["/**\n * Count the occurrences of each item in an array\n * based on a transformation function.\n *\n * This function takes an array and a transformation function\n * that converts each item in the array to a string. It then\n * counts the occurrences of each transformed item and returns\n * an object with the transformed items as keys and the counts\n * as values.\n *\n * @template T - The type of the items in the input array.\n *\n * @param {T[]} arr - The input array to count occurrences.\n * @param {(item: T) => string} mapper - The transformation function that maps each item to a string key.\n * @returns {Record<string, number>} An object containing the transformed items as keys and the\n * counts as values.\n */\nexport function countBy<T>(arr: T[], mapper: (item: T) => string): Record<string, number> {\n const result: Record<string, number> = {};\n \n for (const item of arr) {\n const key = mapper(item);\n \n result[key] = (result[key] ?? 0) + 1;\n }\n \n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBO,SAAS,QAAW,KAAU,QAAqD;
|
|
1
|
+
{"version":3,"sources":["../../src/array/countBy.ts"],"sourcesContent":["/**\n * Count the occurrences of each item in an array\n * based on a transformation function.\n *\n * This function takes an array and a transformation function\n * that converts each item in the array to a string. It then\n * counts the occurrences of each transformed item and returns\n * an object with the transformed items as keys and the counts\n * as values.\n *\n * @template T - The type of the items in the input array.\n *\n * @param {T[]} arr - The input array to count occurrences.\n * @param {(item: T) => string} mapper - The transformation function that maps each item to a string key.\n * @returns {Record<string, number>} An object containing the transformed items as keys and the\n * counts as values.\n */\nexport function countBy<T>(arr: T[], mapper: (item: T) => string): Record<string, number> {\n const result: Record<string, number> = {};\n \n for (const item of arr) {\n const key = mapper(item);\n \n result[key] = (result[key] ?? 0) + 1;\n }\n \n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBO,SAAS,QAAW,KAAU,QAAqD;AACxF,QAAM,SAAiC,CAAC;AAExC,aAAW,QAAQ,KAAK;AACtB,UAAM,MAAM,OAAO,IAAI;AAEvB,WAAO,GAAG,KAAK,OAAO,GAAG,KAAK,KAAK;AAAA,EACrC;AAEA,SAAO;AACT;","names":[]}
|
package/dist/array/countBy.mjs
CHANGED
package/dist/array/drop.mjs
CHANGED
package/dist/array/dropRight.mjs
CHANGED
package/dist/array/dropWhile.mjs
CHANGED
package/dist/array/fill.d.mts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the
|
|
6
6
|
* entire array.
|
|
7
7
|
*
|
|
8
|
+
* @template T, U
|
|
8
9
|
* @param {Array<T | U>} array - The array to fill.
|
|
9
10
|
* @param {U} value - The value to fill the array with.
|
|
10
11
|
* @param {number} [start=0] - The start position. Defaults to 0.
|
package/dist/array/fill.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the
|
|
6
6
|
* entire array.
|
|
7
7
|
*
|
|
8
|
+
* @template T, U
|
|
8
9
|
* @param {Array<T | U>} array - The array to fill.
|
|
9
10
|
* @param {U} value - The value to fill the array with.
|
|
10
11
|
* @param {number} [start=0] - The start position. Defaults to 0.
|
package/dist/array/fill.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/fill.ts"],"sourcesContent":["/**\n * Fills elements of an array with a specified value from the start position up to, but not including, the end position.\n *\n * This function mutates the original array and replaces its elements with the provided value, starting from the specified\n * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the\n * entire array.\n *\n * @param {Array<T | U>} array - The array to fill.\n * @param {U} value - The value to fill the 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 array with the filled values.\n *\n * @example\n * const array = [1, 2, 3];\n * const result = fill(array, 'a');\n * // => ['a', 'a', 'a']\n *\n * const result = fill(Array(3), 2);\n * // => [2, 2, 2]\n *\n * const result = fill([4, 6, 8, 10], '*', 1, 3);\n * // => [4, '*', '*', 10]\n *\n * const result = fill(array, '*', -2, -1);\n * // => [1, '*', 3]\n */\nexport function fill<T>(array: unknown[], value: T): T[];\nexport function fill<T, U>(array: Array<T | U>, value: U, start: number): Array<T | U>;\nexport function fill<T, U>(array: Array<T | U>, value: U, start: number, end: number): Array<T | U>;\nexport function fill<T, U>(array: Array<T | U>, value: U, start = 0, end = array.length): Array<T | U> {\n const length = array.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 for (let i = finalStart; i < finalEnd; i++) {\n array[i] = value;\n }\n\n return array;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/array/fill.ts"],"sourcesContent":["/**\n * Fills elements of an array with a specified value from the start position up to, but not including, the end position.\n *\n * This function mutates the original array and replaces its elements with the provided value, starting from the specified\n * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the\n * entire array.\n *\n * @template T, U\n * @param {Array<T | U>} array - The array to fill.\n * @param {U} value - The value to fill the 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 array with the filled values.\n *\n * @example\n * const array = [1, 2, 3];\n * const result = fill(array, 'a');\n * // => ['a', 'a', 'a']\n *\n * const result = fill(Array(3), 2);\n * // => [2, 2, 2]\n *\n * const result = fill([4, 6, 8, 10], '*', 1, 3);\n * // => [4, '*', '*', 10]\n *\n * const result = fill(array, '*', -2, -1);\n * // => [1, '*', 3]\n */\nexport function fill<T>(array: unknown[], value: T): T[];\nexport function fill<T, U>(array: Array<T | U>, value: U, start: number): Array<T | U>;\nexport function fill<T, U>(array: Array<T | U>, value: U, start: number, end: number): Array<T | U>;\nexport function fill<T, U>(array: Array<T | U>, value: U, start = 0, end = array.length): Array<T | U> {\n const length = array.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 for (let i = finalStart; i < finalEnd; i++) {\n array[i] = value;\n }\n\n return array;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA+BO,SAAS,KAAW,OAAqB,OAAU,QAAQ,GAAG,MAAM,MAAM,QAAsB;AACrG,QAAM,SAAS,MAAM;AACrB,QAAM,aAAa,KAAK,IAAI,SAAS,IAAI,QAAQ,SAAS,OAAO,CAAC;AAClE,QAAM,WAAW,KAAK,IAAI,OAAO,IAAI,MAAM,SAAS,KAAK,MAAM;AAE/D,WAAS,IAAI,YAAY,IAAI,UAAU,KAAK;AAC1C,UAAM,CAAC,IAAI;AAAA,EACb;AAEA,SAAO;AACT;","names":[]}
|
package/dist/array/fill.mjs
CHANGED
package/dist/array/flatMap.mjs
CHANGED
package/dist/array/flatten.mjs
CHANGED
package/dist/array/groupBy.mjs
CHANGED
package/dist/array/head.d.mts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This function takes an array and returns the first element of the array.
|
|
5
5
|
* If the array is empty, the function returns `undefined`.
|
|
6
6
|
*
|
|
7
|
+
* @template T - The type of elements in the array.
|
|
7
8
|
* @param {T[]} arr - The array from which to get the first element.
|
|
8
9
|
* @returns {T | undefined} The first element of the array, or `undefined` if the array is empty.
|
|
9
10
|
*
|
package/dist/array/head.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This function takes an array and returns the first element of the array.
|
|
5
5
|
* If the array is empty, the function returns `undefined`.
|
|
6
6
|
*
|
|
7
|
+
* @template T - The type of elements in the array.
|
|
7
8
|
* @param {T[]} arr - The array from which to get the first element.
|
|
8
9
|
* @returns {T | undefined} The first element of the array, or `undefined` if the array is empty.
|
|
9
10
|
*
|
package/dist/array/head.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/head.ts"],"sourcesContent":["/**\n * Returns the first element of an array.\n *\n * This function takes an array and returns the first element of the array.\n * If the array is empty, the function returns `undefined`.\n *\n * @param {T[]} arr - The array from which to get the first element.\n * @returns {T | undefined} The first element of the array, or `undefined` if the array is empty.\n *\n * @example\n * const arr = [1, 2, 3];\n * const firstElement = head(arr);\n * // firstElement will be 1\n *\n * const emptyArr: number[] = [];\n * const noElement = head(emptyArr);\n * // noElement will be undefined\n */\nexport function head<T>(arr: readonly [T, ...T[]]): T;\nexport function head<T>(arr: readonly T[]): T | undefined;\nexport function head<T>(arr: readonly T[]): T | undefined {\n return arr[0];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/array/head.ts"],"sourcesContent":["/**\n * Returns the first element of an array.\n *\n * This function takes an array and returns the first element of the array.\n * If the array is empty, the function returns `undefined`.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to get the first element.\n * @returns {T | undefined} The first element of the array, or `undefined` if the array is empty.\n *\n * @example\n * const arr = [1, 2, 3];\n * const firstElement = head(arr);\n * // firstElement will be 1\n *\n * const emptyArr: number[] = [];\n * const noElement = head(emptyArr);\n * // noElement will be undefined\n */\nexport function head<T>(arr: readonly [T, ...T[]]): T;\nexport function head<T>(arr: readonly T[]): T | undefined;\nexport function head<T>(arr: readonly T[]): T | undefined {\n return arr[0];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBO,SAAS,KAAQ,KAAkC;AACxD,SAAO,IAAI,CAAC;AACd;","names":[]}
|
package/dist/array/head.mjs
CHANGED
package/dist/array/index.js
CHANGED
|
@@ -102,11 +102,10 @@ function compact(arr) {
|
|
|
102
102
|
|
|
103
103
|
// src/array/countBy.ts
|
|
104
104
|
function countBy(arr, mapper) {
|
|
105
|
-
var _a;
|
|
106
105
|
const result = {};
|
|
107
106
|
for (const item of arr) {
|
|
108
107
|
const key = mapper(item);
|
|
109
|
-
result[key] = (
|
|
108
|
+
result[key] = (result[key] ?? 0) + 1;
|
|
110
109
|
}
|
|
111
110
|
return result;
|
|
112
111
|
}
|