es-toolkit 1.6.1-dev.137 → 1.6.1-dev.139
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/compact.d.mts +1 -0
- package/dist/array/compact.d.ts +1 -0
- package/dist/array/compact.js.map +1 -1
- package/dist/array/compact.mjs +1 -1
- package/dist/array/drop.d.mts +1 -0
- package/dist/array/drop.d.ts +1 -0
- package/dist/array/drop.js.map +1 -1
- package/dist/array/drop.mjs +1 -1
- package/dist/array/dropRight.d.mts +1 -0
- package/dist/array/dropRight.d.ts +1 -0
- package/dist/array/dropRight.js.map +1 -1
- package/dist/array/dropRight.mjs +1 -1
- package/dist/array/dropRightWhile.d.mts +1 -0
- package/dist/array/dropRightWhile.d.ts +1 -0
- package/dist/array/dropRightWhile.js.map +1 -1
- package/dist/array/dropRightWhile.mjs +2 -2
- package/dist/array/dropWhile.d.mts +1 -0
- package/dist/array/dropWhile.d.ts +1 -0
- package/dist/array/dropWhile.js.map +1 -1
- package/dist/array/dropWhile.mjs +1 -1
- package/dist/array/fill.d.mts +29 -0
- package/dist/array/fill.d.ts +29 -0
- package/dist/array/fill.js +38 -0
- package/dist/array/fill.js.map +1 -0
- package/dist/array/fill.mjs +8 -0
- package/dist/array/groupBy.d.mts +2 -0
- package/dist/array/groupBy.d.ts +2 -0
- package/dist/array/groupBy.js.map +1 -1
- package/dist/array/groupBy.mjs +1 -1
- package/dist/array/index.d.mts +1 -0
- package/dist/array/index.d.ts +1 -0
- package/dist/array/index.js +12 -0
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +71 -67
- package/dist/array/intersection.d.mts +1 -0
- package/dist/array/intersection.d.ts +1 -0
- package/dist/array/intersection.js.map +1 -1
- package/dist/array/intersection.mjs +1 -1
- package/dist/array/intersectionBy.d.mts +2 -0
- package/dist/array/intersectionBy.d.ts +2 -0
- package/dist/array/intersectionBy.js.map +1 -1
- package/dist/array/intersectionBy.mjs +1 -1
- package/dist/array/intersectionWith.d.mts +1 -0
- package/dist/array/intersectionWith.d.ts +1 -0
- package/dist/array/intersectionWith.js.map +1 -1
- package/dist/array/intersectionWith.mjs +1 -1
- package/dist/array/keyBy.d.mts +2 -0
- package/dist/array/keyBy.d.ts +2 -0
- package/dist/array/keyBy.js.map +1 -1
- package/dist/array/keyBy.mjs +1 -1
- package/dist/array/maxBy.d.mts +1 -0
- package/dist/array/maxBy.d.ts +1 -0
- package/dist/array/maxBy.js.map +1 -1
- package/dist/array/maxBy.mjs +1 -1
- package/dist/array/minBy.d.mts +1 -0
- package/dist/array/minBy.d.ts +1 -0
- package/dist/array/minBy.js.map +1 -1
- package/dist/array/minBy.mjs +1 -1
- package/dist/array/partition.d.mts +1 -0
- package/dist/array/partition.d.ts +1 -0
- package/dist/array/partition.js.map +1 -1
- package/dist/array/partition.mjs +1 -1
- package/dist/array/sample.d.mts +1 -0
- package/dist/array/sample.d.ts +1 -0
- package/dist/array/sample.js.map +1 -1
- package/dist/array/sample.mjs +1 -1
- package/dist/array/sampleSize.d.mts +1 -0
- package/dist/array/sampleSize.d.ts +1 -0
- package/dist/array/sampleSize.js.map +1 -1
- package/dist/array/sampleSize.mjs +3 -3
- package/dist/array/shuffle.d.mts +1 -0
- package/dist/array/shuffle.d.ts +1 -0
- package/dist/array/shuffle.js.map +1 -1
- package/dist/array/shuffle.mjs +1 -1
- package/dist/array/takeRight.d.mts +1 -0
- package/dist/array/takeRight.d.ts +1 -0
- package/dist/array/takeRight.js.map +1 -1
- package/dist/array/takeRight.mjs +1 -1
- package/dist/array/union.d.mts +1 -0
- package/dist/array/union.d.ts +1 -0
- package/dist/array/union.js.map +1 -1
- package/dist/array/union.mjs +2 -2
- package/dist/array/unionBy.d.mts +2 -0
- package/dist/array/unionBy.d.ts +2 -0
- package/dist/array/unionBy.js.map +1 -1
- package/dist/array/unionBy.mjs +1 -1
- package/dist/array/unionWith.d.mts +1 -0
- package/dist/array/unionWith.d.ts +1 -0
- package/dist/array/unionWith.js.map +1 -1
- package/dist/array/unionWith.mjs +2 -2
- package/dist/array/uniq.d.mts +1 -0
- package/dist/array/uniq.d.ts +1 -0
- package/dist/array/uniq.js.map +1 -1
- package/dist/array/uniq.mjs +1 -1
- package/dist/array/uniqBy.d.mts +2 -0
- package/dist/array/uniqBy.d.ts +2 -0
- package/dist/array/uniqBy.js.map +1 -1
- package/dist/array/uniqBy.mjs +1 -1
- package/dist/array/uniqWith.d.mts +1 -0
- package/dist/array/uniqWith.d.ts +1 -0
- package/dist/array/uniqWith.js.map +1 -1
- package/dist/array/uniqWith.mjs +1 -1
- package/dist/array/xor.d.mts +1 -0
- package/dist/array/xor.d.ts +1 -0
- package/dist/array/xor.js.map +1 -1
- package/dist/array/xor.mjs +4 -4
- package/dist/array/xorBy.js.map +1 -1
- package/dist/array/xorBy.mjs +3 -3
- package/dist/array/xorWith.js.map +1 -1
- package/dist/array/xorWith.mjs +4 -4
- package/dist/array/zipObject.d.mts +2 -0
- package/dist/array/zipObject.d.ts +2 -0
- package/dist/array/zipObject.js.map +1 -1
- package/dist/array/zipObject.mjs +1 -1
- package/dist/{chunk-2PFDLYQC.mjs → chunk-237HGSZS.mjs} +1 -1
- package/dist/chunk-237HGSZS.mjs.map +1 -0
- package/dist/chunk-23O4IK6D.mjs +1 -0
- package/dist/chunk-23O4IK6D.mjs.map +1 -0
- package/dist/{chunk-DOOIIHT3.mjs → chunk-2KNLZB7V.mjs} +1 -1
- package/dist/chunk-2KNLZB7V.mjs.map +1 -0
- package/dist/{chunk-OUTSP4VR.mjs → chunk-2ZCITDMK.mjs} +2 -2
- package/dist/chunk-2ZCITDMK.mjs.map +1 -0
- package/dist/{chunk-G42NUGNE.mjs → chunk-3IP4JVLL.mjs} +1 -1
- package/dist/chunk-3IP4JVLL.mjs.map +1 -0
- package/dist/{chunk-MQWVBKUT.mjs → chunk-6CLH5YZ2.mjs} +1 -1
- package/dist/chunk-6CLH5YZ2.mjs.map +1 -0
- package/dist/{chunk-DA7GSKQ5.mjs → chunk-6GWEY5EL.mjs} +1 -1
- package/dist/chunk-6GWEY5EL.mjs.map +1 -0
- package/dist/{chunk-KSXWREB5.mjs → chunk-AJKZMN2V.mjs} +1 -1
- package/dist/chunk-AJKZMN2V.mjs.map +1 -0
- package/dist/{chunk-A67NF2C7.mjs → chunk-BCTYOXT7.mjs} +1 -1
- package/dist/chunk-BCTYOXT7.mjs.map +1 -0
- package/dist/{chunk-ZQNAZPSK.mjs → chunk-BMRTZMRE.mjs} +1 -1
- package/dist/chunk-BMRTZMRE.mjs.map +1 -0
- package/dist/chunk-C4WE4GLC.mjs +14 -0
- package/dist/chunk-C4WE4GLC.mjs.map +1 -0
- package/dist/{chunk-UFAA5WKR.mjs → chunk-CMBC4MXG.mjs} +1 -1
- package/dist/chunk-CMBC4MXG.mjs.map +1 -0
- package/dist/{chunk-JGNFYNYU.mjs → chunk-CXGIXTSH.mjs} +1 -1
- package/dist/chunk-CXGIXTSH.mjs.map +1 -0
- package/dist/{chunk-5L2V7WD3.mjs → chunk-DN3NOZ3H.mjs} +1 -1
- package/dist/chunk-DN3NOZ3H.mjs.map +1 -0
- package/dist/{chunk-NKTBEEIT.mjs → chunk-DTJJIMKJ.mjs} +1 -1
- package/dist/chunk-DTJJIMKJ.mjs.map +1 -0
- package/dist/{chunk-XFCW7XJ4.mjs → chunk-DVK2N4KC.mjs} +1 -1
- package/dist/chunk-DVK2N4KC.mjs.map +1 -0
- package/dist/{chunk-Q5XXJXXQ.mjs → chunk-DXB7EZUQ.mjs} +1 -1
- package/dist/chunk-DXB7EZUQ.mjs.map +1 -0
- package/dist/{chunk-H5YR3ZV4.mjs → chunk-E6E4RZLN.mjs} +1 -1
- package/dist/chunk-E6E4RZLN.mjs.map +1 -0
- package/dist/{chunk-PYLGHB3F.mjs → chunk-FVVSE2F2.mjs} +1 -1
- package/dist/chunk-FVVSE2F2.mjs.map +1 -0
- package/dist/{chunk-DPLJQQFX.mjs → chunk-G7UQ5PUR.mjs} +1 -1
- package/dist/chunk-G7UQ5PUR.mjs.map +1 -0
- package/dist/{chunk-OFWKFUFZ.mjs → chunk-HPFDYUGP.mjs} +1 -1
- package/dist/chunk-HPFDYUGP.mjs.map +1 -0
- package/dist/{chunk-OIHARMNM.mjs → chunk-IJD7FE2Z.mjs} +1 -1
- package/dist/chunk-IJD7FE2Z.mjs.map +1 -0
- package/dist/{chunk-XDKEPIUV.mjs → chunk-IQLKIDXF.mjs} +1 -1
- package/dist/chunk-IQLKIDXF.mjs.map +1 -0
- package/dist/{chunk-GTVOVGGZ.mjs → chunk-JE6JKZU3.mjs} +2 -2
- package/dist/chunk-JE6JKZU3.mjs.map +1 -0
- package/dist/{chunk-Q75KEFW5.mjs → chunk-JEKUA56R.mjs} +1 -1
- package/dist/chunk-JEKUA56R.mjs.map +1 -0
- package/dist/{chunk-VKM3R5T5.mjs → chunk-L7FQX5MN.mjs} +3 -3
- package/dist/chunk-L7FQX5MN.mjs.map +1 -0
- package/dist/{chunk-K2BAFL2T.mjs → chunk-LJ2C6MVP.mjs} +1 -1
- package/dist/chunk-LJ2C6MVP.mjs.map +1 -0
- package/dist/{chunk-4MRXVNGG.mjs → chunk-LUIKU43M.mjs} +1 -1
- package/dist/chunk-LUIKU43M.mjs.map +1 -0
- package/dist/{chunk-NRNKP6JF.mjs → chunk-NFS7RWWE.mjs} +1 -1
- package/dist/chunk-NFS7RWWE.mjs.map +1 -0
- package/dist/{chunk-H2FV6Z5X.mjs → chunk-O64NE2P4.mjs} +2 -2
- package/dist/{chunk-GNSJP2AB.mjs → chunk-O6UXZR3U.mjs} +1 -1
- package/dist/chunk-O6UXZR3U.mjs.map +1 -0
- package/dist/{chunk-FXOABQRO.mjs → chunk-OOKNBU4V.mjs} +1 -1
- package/dist/chunk-OOKNBU4V.mjs.map +1 -0
- package/dist/{chunk-WPDDOUQT.mjs → chunk-OXAZEEGP.mjs} +1 -1
- package/dist/chunk-OXAZEEGP.mjs.map +1 -0
- package/dist/{chunk-E54CCWDL.mjs → chunk-Q47NGNXT.mjs} +3 -3
- package/dist/{chunk-OEOAJOLQ.mjs → chunk-QOJGMVVR.mjs} +1 -1
- package/dist/chunk-QOJGMVVR.mjs.map +1 -0
- package/dist/{chunk-JSS4FXUD.mjs → chunk-QRSJBBFY.mjs} +3 -3
- package/dist/{chunk-PLTO44KM.mjs → chunk-QZITBKWX.mjs} +1 -1
- package/dist/chunk-QZITBKWX.mjs.map +1 -0
- package/dist/{chunk-UPJXHWSJ.mjs → chunk-R6QA7PLZ.mjs} +2 -2
- package/dist/chunk-R6QA7PLZ.mjs.map +1 -0
- package/dist/{chunk-ACFP3XMB.mjs → chunk-S3CORED5.mjs} +1 -1
- package/dist/chunk-S3CORED5.mjs.map +1 -0
- package/dist/{chunk-2EFS3VA3.mjs → chunk-XI7KRD2C.mjs} +1 -1
- package/dist/chunk-XI7KRD2C.mjs.map +1 -0
- package/dist/error/AbortError.d.mts +1 -1
- package/dist/error/AbortError.d.ts +1 -1
- package/dist/error/AbortError.js.map +1 -1
- package/dist/error/AbortError.mjs +1 -1
- package/dist/error/index.js.map +1 -1
- package/dist/error/index.mjs +1 -1
- package/dist/function/debounce.d.mts +1 -0
- package/dist/function/debounce.d.ts +1 -0
- package/dist/function/debounce.js.map +1 -1
- package/dist/function/debounce.mjs +1 -1
- package/dist/function/index.js.map +1 -1
- package/dist/function/index.mjs +3 -3
- package/dist/function/once.d.mts +1 -0
- package/dist/function/once.d.ts +1 -0
- package/dist/function/once.js.map +1 -1
- package/dist/function/once.mjs +1 -1
- package/dist/function/throttle.d.mts +1 -0
- package/dist/function/throttle.d.ts +1 -0
- package/dist/function/throttle.js.map +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 +12 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +106 -102
- package/dist/math/index.js.map +1 -1
- package/dist/math/index.mjs +6 -6
- package/dist/math/meanBy.d.mts +1 -0
- package/dist/math/meanBy.d.ts +1 -0
- package/dist/math/meanBy.js.map +1 -1
- package/dist/math/meanBy.mjs +1 -1
- package/dist/object/index.js.map +1 -1
- package/dist/object/index.mjs +6 -6
- package/dist/object/omit.d.mts +2 -0
- package/dist/object/omit.d.ts +2 -0
- package/dist/object/omit.js.map +1 -1
- package/dist/object/omit.mjs +1 -1
- package/dist/object/omitBy.d.mts +1 -0
- package/dist/object/omitBy.d.ts +1 -0
- package/dist/object/omitBy.js.map +1 -1
- package/dist/object/omitBy.mjs +1 -1
- package/dist/object/pick.d.mts +2 -0
- package/dist/object/pick.d.ts +2 -0
- package/dist/object/pick.js.map +1 -1
- package/dist/object/pick.mjs +1 -1
- package/dist/object/pickBy.d.mts +1 -0
- package/dist/object/pickBy.d.ts +1 -0
- package/dist/object/pickBy.js.map +1 -1
- package/dist/object/pickBy.mjs +1 -1
- package/dist/predicate/index.js.map +1 -1
- package/dist/predicate/index.mjs +4 -4
- package/dist/predicate/isNotNil.d.mts +1 -0
- package/dist/predicate/isNotNil.d.ts +1 -0
- package/dist/predicate/isNotNil.js.map +1 -1
- package/dist/predicate/isNotNil.mjs +1 -1
- package/dist/promise/delay.js.map +1 -1
- package/dist/promise/delay.mjs +2 -2
- package/dist/promise/index.js.map +1 -1
- package/dist/promise/index.mjs +2 -2
- package/package.json +2 -1
- package/dist/chunk-2EFS3VA3.mjs.map +0 -1
- package/dist/chunk-2PFDLYQC.mjs.map +0 -1
- package/dist/chunk-4MRXVNGG.mjs.map +0 -1
- package/dist/chunk-5L2V7WD3.mjs.map +0 -1
- package/dist/chunk-A67NF2C7.mjs.map +0 -1
- package/dist/chunk-ACFP3XMB.mjs.map +0 -1
- package/dist/chunk-D735JOLS.mjs +0 -1
- package/dist/chunk-DA7GSKQ5.mjs.map +0 -1
- package/dist/chunk-DOOIIHT3.mjs.map +0 -1
- package/dist/chunk-DPLJQQFX.mjs.map +0 -1
- package/dist/chunk-FXOABQRO.mjs.map +0 -1
- package/dist/chunk-G42NUGNE.mjs.map +0 -1
- package/dist/chunk-GNSJP2AB.mjs.map +0 -1
- package/dist/chunk-GTVOVGGZ.mjs.map +0 -1
- package/dist/chunk-H5YR3ZV4.mjs.map +0 -1
- package/dist/chunk-JGNFYNYU.mjs.map +0 -1
- package/dist/chunk-K2BAFL2T.mjs.map +0 -1
- package/dist/chunk-KSXWREB5.mjs.map +0 -1
- package/dist/chunk-MQWVBKUT.mjs.map +0 -1
- package/dist/chunk-NKTBEEIT.mjs.map +0 -1
- package/dist/chunk-NRNKP6JF.mjs.map +0 -1
- package/dist/chunk-OEOAJOLQ.mjs.map +0 -1
- package/dist/chunk-OFWKFUFZ.mjs.map +0 -1
- package/dist/chunk-OIHARMNM.mjs.map +0 -1
- package/dist/chunk-OUTSP4VR.mjs.map +0 -1
- package/dist/chunk-PLTO44KM.mjs.map +0 -1
- package/dist/chunk-PYLGHB3F.mjs.map +0 -1
- package/dist/chunk-Q5XXJXXQ.mjs.map +0 -1
- package/dist/chunk-Q75KEFW5.mjs.map +0 -1
- package/dist/chunk-UFAA5WKR.mjs.map +0 -1
- package/dist/chunk-UPJXHWSJ.mjs.map +0 -1
- package/dist/chunk-VKM3R5T5.mjs.map +0 -1
- package/dist/chunk-WPDDOUQT.mjs.map +0 -1
- package/dist/chunk-XDKEPIUV.mjs.map +0 -1
- package/dist/chunk-XFCW7XJ4.mjs.map +0 -1
- package/dist/chunk-ZQNAZPSK.mjs.map +0 -1
- /package/dist/{chunk-D735JOLS.mjs.map → array/fill.mjs.map} +0 -0
- /package/dist/{chunk-H2FV6Z5X.mjs.map → chunk-O64NE2P4.mjs.map} +0 -0
- /package/dist/{chunk-E54CCWDL.mjs.map → chunk-Q47NGNXT.mjs.map} +0 -0
- /package/dist/{chunk-JSS4FXUD.mjs.map → chunk-QRSJBBFY.mjs.map} +0 -0
package/dist/array/compact.d.mts
CHANGED
|
@@ -2,6 +2,7 @@ type NotFalsey<T> = Exclude<T, false | null | 0 | '' | undefined>;
|
|
|
2
2
|
/**
|
|
3
3
|
* Removes falsey values (false, null, 0, '', undefined, NaN) from an array.
|
|
4
4
|
*
|
|
5
|
+
* @template T - The type of elements in the array.
|
|
5
6
|
* @param {readonly T[]} arr - The input array to remove falsey values.
|
|
6
7
|
* @returns {Array<Exclude<T, false | null | 0 | '' | undefined>>} - A new array with all falsey values removed.
|
|
7
8
|
*
|
package/dist/array/compact.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ type NotFalsey<T> = Exclude<T, false | null | 0 | '' | undefined>;
|
|
|
2
2
|
/**
|
|
3
3
|
* Removes falsey values (false, null, 0, '', undefined, NaN) from an array.
|
|
4
4
|
*
|
|
5
|
+
* @template T - The type of elements in the array.
|
|
5
6
|
* @param {readonly T[]} arr - The input array to remove falsey values.
|
|
6
7
|
* @returns {Array<Exclude<T, false | null | 0 | '' | undefined>>} - A new array with all falsey values removed.
|
|
7
8
|
*
|
|
@@ -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 * @param {readonly 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;
|
|
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 {readonly 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/drop.d.mts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This function takes an array and a number, and returns a new array with the specified number
|
|
5
5
|
* of elements removed from the start.
|
|
6
6
|
*
|
|
7
|
+
* @template T - The type of elements in the array.
|
|
7
8
|
* @param {T[]} arr - The array from which to drop elements.
|
|
8
9
|
* @param {number} itemsCount - The number of elements to drop from the beginning of the array.
|
|
9
10
|
* @returns {T[]} A new array with the specified number of elements removed from the start.
|
package/dist/array/drop.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This function takes an array and a number, and returns a new array with the specified number
|
|
5
5
|
* of elements removed from the start.
|
|
6
6
|
*
|
|
7
|
+
* @template T - The type of elements in the array.
|
|
7
8
|
* @param {T[]} arr - The array from which to drop elements.
|
|
8
9
|
* @param {number} itemsCount - The number of elements to drop from the beginning of the array.
|
|
9
10
|
* @returns {T[]} A new array with the specified number of elements removed from the start.
|
package/dist/array/drop.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/drop.ts"],"sourcesContent":["/**\n * Removes a specified number of elements from the beginning of an array and returns the rest.\n *\n * This function takes an array and a number, and returns a new array with the specified number\n * of elements removed from the start.\n *\n * @param {T[]} arr - The array from which to drop elements.\n * @param {number} itemsCount - The number of elements to drop from the beginning of the array.\n * @returns {T[]} A new array with the specified number of elements removed from the start.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = drop(array, 2);\n * // result will be [3, 4, 5] since the first two elements are dropped.\n */\nexport function drop<T>(arr: readonly T[], itemsCount: number): T[] {\n return arr.slice(itemsCount);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/array/drop.ts"],"sourcesContent":["/**\n * Removes a specified number of elements from the beginning of an array and returns the rest.\n *\n * This function takes an array and a number, and returns a new array with the specified number\n * of elements removed from the start.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {number} itemsCount - The number of elements to drop from the beginning of the array.\n * @returns {T[]} A new array with the specified number of elements removed from the start.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = drop(array, 2);\n * // result will be [3, 4, 5] since the first two elements are dropped.\n */\nexport function drop<T>(arr: readonly T[], itemsCount: number): T[] {\n return arr.slice(itemsCount);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,SAAS,KAAQ,KAAmB,YAAyB;AAClE,SAAO,IAAI,MAAM,UAAU;AAC7B;","names":[]}
|
package/dist/array/drop.mjs
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This function takes an array and a number, and returns a new array with the specified number
|
|
5
5
|
* of elements removed from the end.
|
|
6
6
|
*
|
|
7
|
+
* @template T - The type of elements in the array.
|
|
7
8
|
* @param {T[]} arr - The array from which to drop elements.
|
|
8
9
|
* @param {number} itemsCount - The number of elements to drop from the end of the array.
|
|
9
10
|
* @returns {T[]} A new array with the specified number of elements removed from the end.
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This function takes an array and a number, and returns a new array with the specified number
|
|
5
5
|
* of elements removed from the end.
|
|
6
6
|
*
|
|
7
|
+
* @template T - The type of elements in the array.
|
|
7
8
|
* @param {T[]} arr - The array from which to drop elements.
|
|
8
9
|
* @param {number} itemsCount - The number of elements to drop from the end of the array.
|
|
9
10
|
* @returns {T[]} A new array with the specified number of elements removed from the end.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/dropRight.ts"],"sourcesContent":["/**\n * Removes a specified number of elements from the end of an array and returns the rest.\n *\n * This function takes an array and a number, and returns a new array with the specified number\n * of elements removed from the end.\n *\n * @param {T[]} arr - The array from which to drop elements.\n * @param {number} itemsCount - The number of elements to drop from the end of the array.\n * @returns {T[]} A new array with the specified number of elements removed from the end.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropRight(array, 2);\n * // result will be [1, 2, 3] since the last two elements are dropped.\n */\nexport function dropRight<T>(arr: readonly T[], itemsCount: number): T[] {\n return arr.slice(0, -itemsCount);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/array/dropRight.ts"],"sourcesContent":["/**\n * Removes a specified number of elements from the end of an array and returns the rest.\n *\n * This function takes an array and a number, and returns a new array with the specified number\n * of elements removed from the end.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {number} itemsCount - The number of elements to drop from the end of the array.\n * @returns {T[]} A new array with the specified number of elements removed from the end.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropRight(array, 2);\n * // result will be [1, 2, 3] since the last two elements are dropped.\n */\nexport function dropRight<T>(arr: readonly T[], itemsCount: number): T[] {\n return arr.slice(0, -itemsCount);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,SAAS,UAAa,KAAmB,YAAyB;AACvE,SAAO,IAAI,MAAM,GAAG,CAAC,UAAU;AACjC;","names":[]}
|
package/dist/array/dropRight.mjs
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This function iterates over an array from the end and drops elements until the provided
|
|
5
5
|
* predicate function returns false. It then returns a new array with the remaining elements.
|
|
6
6
|
*
|
|
7
|
+
* @template T - The type of elements in the array.
|
|
7
8
|
* @param {T[]} arr - The array from which to drop elements.
|
|
8
9
|
* @param {(item: T) => boolean} canContinueDropping - A predicate function that determines
|
|
9
10
|
* whether to continue dropping elements. The function is called with each element from the end,
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This function iterates over an array from the end and drops elements until the provided
|
|
5
5
|
* predicate function returns false. It then returns a new array with the remaining elements.
|
|
6
6
|
*
|
|
7
|
+
* @template T - The type of elements in the array.
|
|
7
8
|
* @param {T[]} arr - The array from which to drop elements.
|
|
8
9
|
* @param {(item: T) => boolean} canContinueDropping - A predicate function that determines
|
|
9
10
|
* whether to continue dropping elements. The function is called with each element from the end,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/dropRightWhile.ts","../../src/array/dropWhile.ts"],"sourcesContent":["import { dropWhile } from './dropWhile.ts';\n\n/**\n * Removes elements from the end of an array until the predicate returns false.\n *\n * This function iterates over an array from the end and drops elements until the provided\n * predicate function returns false. It then returns a new array with the remaining elements.\n *\n * @param {T[]} arr - The array from which to drop elements.\n * @param {(item: T) => boolean} canContinueDropping - A predicate function that determines\n * whether to continue dropping elements. The function is called with each element from the end,\n * and dropping continues as long as it returns true.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropRightWhile(array, x => x > 3);\n * // result will be [1, 2, 3] since elements greater than 3 are dropped from the end.\n */\nexport function dropRightWhile<T>(arr: readonly T[], canContinueDropping: (item: T) => boolean): T[] {\n const reversed = arr.slice().reverse();\n const dropped = dropWhile(reversed, canContinueDropping);\n return dropped.slice().reverse();\n}\n","/**\n * Removes elements from the beginning of an array until the predicate returns false.\n *\n * This function iterates over an array and drops elements from the start until the provided\n * predicate function returns false. It then returns a new array with the remaining elements.\n *\n * @param {T[]} arr - The array from which to drop elements.\n * @param {(item: T) => boolean} canContinueDropping - A predicate function that determines\n * whether to continue dropping elements. The function is called with each element, and dropping\n * continues as long as it returns true.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropWhile(array, x => x < 3);\n * // result will be [3, 4, 5] since elements less than 3 are dropped.\n */\nexport function dropWhile<T>(arr: readonly T[], canContinueDropping: (item: T) => boolean): T[] {\n const dropEndIndex = arr.findIndex(item => !canContinueDropping(item));\n if (dropEndIndex === -1) {\n return [];\n }\n\n return arr.slice(dropEndIndex);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;
|
|
1
|
+
{"version":3,"sources":["../../src/array/dropRightWhile.ts","../../src/array/dropWhile.ts"],"sourcesContent":["import { dropWhile } from './dropWhile.ts';\n\n/**\n * Removes elements from the end of an array until the predicate returns false.\n *\n * This function iterates over an array from the end and drops elements until the provided\n * predicate function returns false. It then returns a new array with the remaining elements.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {(item: T) => boolean} canContinueDropping - A predicate function that determines\n * whether to continue dropping elements. The function is called with each element from the end,\n * and dropping continues as long as it returns true.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropRightWhile(array, x => x > 3);\n * // result will be [1, 2, 3] since elements greater than 3 are dropped from the end.\n */\nexport function dropRightWhile<T>(arr: readonly T[], canContinueDropping: (item: T) => boolean): T[] {\n const reversed = arr.slice().reverse();\n const dropped = dropWhile(reversed, canContinueDropping);\n return dropped.slice().reverse();\n}\n","/**\n * Removes elements from the beginning of an array until the predicate returns false.\n *\n * This function iterates over an array and drops elements from the start until the provided\n * predicate function returns false. It then returns a new array with the remaining elements.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {(item: T) => boolean} canContinueDropping - A predicate function that determines\n * whether to continue dropping elements. The function is called with each element, and dropping\n * continues as long as it returns true.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropWhile(array, x => x < 3);\n * // result will be [3, 4, 5] since elements less than 3 are dropped.\n */\nexport function dropWhile<T>(arr: readonly T[], canContinueDropping: (item: T) => boolean): T[] {\n const dropEndIndex = arr.findIndex(item => !canContinueDropping(item));\n if (dropEndIndex === -1) {\n return [];\n }\n\n return arr.slice(dropEndIndex);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACkBO,SAAS,UAAa,KAAmB,qBAAgD;AAC9F,QAAM,eAAe,IAAI,UAAU,UAAQ,CAAC,oBAAoB,IAAI,CAAC;AACrE,MAAI,iBAAiB,IAAI;AACvB,WAAO,CAAC;AAAA,EACV;AAEA,SAAO,IAAI,MAAM,YAAY;AAC/B;;;ADLO,SAAS,eAAkB,KAAmB,qBAAgD;AACnG,QAAM,WAAW,IAAI,MAAM,EAAE,QAAQ;AACrC,QAAM,UAAU,UAAU,UAAU,mBAAmB;AACvD,SAAO,QAAQ,MAAM,EAAE,QAAQ;AACjC;","names":[]}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This function iterates over an array and drops elements from the start until the provided
|
|
5
5
|
* predicate function returns false. It then returns a new array with the remaining elements.
|
|
6
6
|
*
|
|
7
|
+
* @template T - The type of elements in the array.
|
|
7
8
|
* @param {T[]} arr - The array from which to drop elements.
|
|
8
9
|
* @param {(item: T) => boolean} canContinueDropping - A predicate function that determines
|
|
9
10
|
* whether to continue dropping elements. The function is called with each element, and dropping
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This function iterates over an array and drops elements from the start until the provided
|
|
5
5
|
* predicate function returns false. It then returns a new array with the remaining elements.
|
|
6
6
|
*
|
|
7
|
+
* @template T - The type of elements in the array.
|
|
7
8
|
* @param {T[]} arr - The array from which to drop elements.
|
|
8
9
|
* @param {(item: T) => boolean} canContinueDropping - A predicate function that determines
|
|
9
10
|
* whether to continue dropping elements. The function is called with each element, and dropping
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/dropWhile.ts"],"sourcesContent":["/**\n * Removes elements from the beginning of an array until the predicate returns false.\n *\n * This function iterates over an array and drops elements from the start until the provided\n * predicate function returns false. It then returns a new array with the remaining elements.\n *\n * @param {T[]} arr - The array from which to drop elements.\n * @param {(item: T) => boolean} canContinueDropping - A predicate function that determines\n * whether to continue dropping elements. The function is called with each element, and dropping\n * continues as long as it returns true.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropWhile(array, x => x < 3);\n * // result will be [3, 4, 5] since elements less than 3 are dropped.\n */\nexport function dropWhile<T>(arr: readonly T[], canContinueDropping: (item: T) => boolean): T[] {\n const dropEndIndex = arr.findIndex(item => !canContinueDropping(item));\n if (dropEndIndex === -1) {\n return [];\n }\n\n return arr.slice(dropEndIndex);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/array/dropWhile.ts"],"sourcesContent":["/**\n * Removes elements from the beginning of an array until the predicate returns false.\n *\n * This function iterates over an array and drops elements from the start until the provided\n * predicate function returns false. It then returns a new array with the remaining elements.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {(item: T) => boolean} canContinueDropping - A predicate function that determines\n * whether to continue dropping elements. The function is called with each element, and dropping\n * continues as long as it returns true.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropWhile(array, x => x < 3);\n * // result will be [3, 4, 5] since elements less than 3 are dropped.\n */\nexport function dropWhile<T>(arr: readonly T[], canContinueDropping: (item: T) => boolean): T[] {\n const dropEndIndex = arr.findIndex(item => !canContinueDropping(item));\n if (dropEndIndex === -1) {\n return [];\n }\n\n return arr.slice(dropEndIndex);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBO,SAAS,UAAa,KAAmB,qBAAgD;AAC9F,QAAM,eAAe,IAAI,UAAU,UAAQ,CAAC,oBAAoB,IAAI,CAAC;AACrE,MAAI,iBAAiB,IAAI;AACvB,WAAO,CAAC;AAAA,EACV;AAEA,SAAO,IAAI,MAAM,YAAY;AAC/B;","names":[]}
|
package/dist/array/dropWhile.mjs
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fills elements of an array with a specified value from the start position up to, but not including, the end position.
|
|
3
|
+
*
|
|
4
|
+
* This function mutates the original array and replaces its elements with the provided value, starting from the specified
|
|
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
|
+
* entire array. Negative indices can be used to specify positions from the end of the array.
|
|
7
|
+
*
|
|
8
|
+
* @param {Array<T | P>} arr - The array to fill.
|
|
9
|
+
* @param {P} value - The value to fill the array with.
|
|
10
|
+
* @param {number} [start=0] - The start position. Defaults to 0.
|
|
11
|
+
* @param {number} [end=arr.length] - The end position. Defaults to the array's length.
|
|
12
|
+
* @returns {Array<T | P>} The array with the filled values.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const array = [1, 2, 3];
|
|
16
|
+
* const result = fill(array, 'a');
|
|
17
|
+
* // => ['a', 'a', 'a']
|
|
18
|
+
*
|
|
19
|
+
* const result = fill(Array(3), 2);
|
|
20
|
+
* // => [2, 2, 2]
|
|
21
|
+
*
|
|
22
|
+
* const result = fill([4, 6, 8, 10], '*', 1, 3);
|
|
23
|
+
* // => [4, '*', '*', 10]
|
|
24
|
+
*/
|
|
25
|
+
declare function fill<T>(arr: unknown[], value: T): T[];
|
|
26
|
+
declare function fill<T, P>(arr: Array<T | P>, value: P, start: number): Array<T | P>;
|
|
27
|
+
declare function fill<T, P>(arr: Array<T | P>, value: P, start: number, end: number): Array<T | P>;
|
|
28
|
+
|
|
29
|
+
export { fill };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fills elements of an array with a specified value from the start position up to, but not including, the end position.
|
|
3
|
+
*
|
|
4
|
+
* This function mutates the original array and replaces its elements with the provided value, starting from the specified
|
|
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
|
+
* entire array. Negative indices can be used to specify positions from the end of the array.
|
|
7
|
+
*
|
|
8
|
+
* @param {Array<T | P>} arr - The array to fill.
|
|
9
|
+
* @param {P} value - The value to fill the array with.
|
|
10
|
+
* @param {number} [start=0] - The start position. Defaults to 0.
|
|
11
|
+
* @param {number} [end=arr.length] - The end position. Defaults to the array's length.
|
|
12
|
+
* @returns {Array<T | P>} The array with the filled values.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const array = [1, 2, 3];
|
|
16
|
+
* const result = fill(array, 'a');
|
|
17
|
+
* // => ['a', 'a', 'a']
|
|
18
|
+
*
|
|
19
|
+
* const result = fill(Array(3), 2);
|
|
20
|
+
* // => [2, 2, 2]
|
|
21
|
+
*
|
|
22
|
+
* const result = fill([4, 6, 8, 10], '*', 1, 3);
|
|
23
|
+
* // => [4, '*', '*', 10]
|
|
24
|
+
*/
|
|
25
|
+
declare function fill<T>(arr: unknown[], value: T): T[];
|
|
26
|
+
declare function fill<T, P>(arr: Array<T | P>, value: P, start: number): Array<T | P>;
|
|
27
|
+
declare function fill<T, P>(arr: Array<T | P>, value: P, start: number, end: number): Array<T | P>;
|
|
28
|
+
|
|
29
|
+
export { fill };
|
|
@@ -0,0 +1,38 @@
|
|
|
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/fill.ts
|
|
21
|
+
var fill_exports = {};
|
|
22
|
+
__export(fill_exports, {
|
|
23
|
+
fill: () => fill
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(fill_exports);
|
|
26
|
+
function fill(arr, value, start = 0, end = arr.length) {
|
|
27
|
+
start = Math.max(start, 0);
|
|
28
|
+
end = Math.min(end, arr.length);
|
|
29
|
+
for (let i = start; i < end; i++) {
|
|
30
|
+
arr[i] = value;
|
|
31
|
+
}
|
|
32
|
+
return arr;
|
|
33
|
+
}
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
fill
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=fill.js.map
|
|
@@ -0,0 +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. Negative indices can be used to specify positions from the end of the array.\n *\n * @param {Array<T | P>} arr - The array to fill.\n * @param {P} 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 | P>} 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\nexport function fill<T>(arr: unknown[], value: T): T[];\nexport function fill<T, P>(arr: Array<T | P>, value: P, start: number): Array<T | P>;\nexport function fill<T, P>(arr: Array<T | P>, value: P, start: number, end: number): Array<T | P>;\nexport function fill<T, P>(arr: Array<T | P>, value: P, start = 0, end = arr.length): Array<T | P> {\n start = Math.max(start, 0);\n end = Math.min(end, arr.length);\n\n for (let i = start; i < end; i++) {\n arr[i] = value;\n }\n\n return arr;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4BO,SAAS,KAAW,KAAmB,OAAU,QAAQ,GAAG,MAAM,IAAI,QAAsB;AACjG,UAAQ,KAAK,IAAI,OAAO,CAAC;AACzB,QAAM,KAAK,IAAI,KAAK,IAAI,MAAM;AAE9B,WAAS,IAAI,OAAO,IAAI,KAAK,KAAK;AAChC,QAAI,CAAC,IAAI;AAAA,EACX;AAEA,SAAO;AACT;","names":[]}
|
package/dist/array/groupBy.d.mts
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* an object where the keys are the generated keys and the values are arrays of elements that share
|
|
6
6
|
* the same key.
|
|
7
7
|
*
|
|
8
|
+
* @template T - The type of elements in the array.
|
|
9
|
+
* @template K - The type of keys.
|
|
8
10
|
* @param {T[]} arr - The array to group.
|
|
9
11
|
* @param {(item: T) => K} getKeyFromItem - A function that generates a key from an element.
|
|
10
12
|
* @returns {Record<K, T[]>} An object where each key is associated with an array of elements that
|
package/dist/array/groupBy.d.ts
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* an object where the keys are the generated keys and the values are arrays of elements that share
|
|
6
6
|
* the same key.
|
|
7
7
|
*
|
|
8
|
+
* @template T - The type of elements in the array.
|
|
9
|
+
* @template K - The type of keys.
|
|
8
10
|
* @param {T[]} arr - The array to group.
|
|
9
11
|
* @param {(item: T) => K} getKeyFromItem - A function that generates a key from an element.
|
|
10
12
|
* @returns {Record<K, T[]>} An object where each key is associated with an array of elements that
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/groupBy.ts"],"sourcesContent":["/**\n * Groups the elements of an array based on a provided key-generating function.\n *\n * This function takes an array and a function that generates a key from each element. It returns\n * an object where the keys are the generated keys and the values are arrays of elements that share\n * the same key.\n *\n * @param {T[]} arr - The array to group.\n * @param {(item: T) => K} getKeyFromItem - A function that generates a key from an element.\n * @returns {Record<K, T[]>} An object where each key is associated with an array of elements that\n * share that key.\n *\n * @example\n * const array = [\n * { category: 'fruit', name: 'apple' },\n * { category: 'fruit', name: 'banana' },\n * { category: 'vegetable', name: 'carrot' }\n * ];\n * const result = groupBy(array, item => item.category);\n * // result will be:\n * // {\n * // fruit: [\n * // { category: 'fruit', name: 'apple' },\n * // { category: 'fruit', name: 'banana' }\n * // ],\n * // vegetable: [\n * // { category: 'vegetable', name: 'carrot' }\n * // ]\n * // }\n */\nexport function groupBy<T, K extends PropertyKey>(arr: readonly T[], getKeyFromItem: (item: T) => K): Record<K, T[]> {\n const result = {} as Record<K, T[]>;\n\n for (const item of arr) {\n const key = getKeyFromItem(item);\n\n if (result[key] == null) {\n result[key] = [];\n }\n\n result[key].push(item);\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/array/groupBy.ts"],"sourcesContent":["/**\n * Groups the elements of an array based on a provided key-generating function.\n *\n * This function takes an array and a function that generates a key from each element. It returns\n * an object where the keys are the generated keys and the values are arrays of elements that share\n * the same key.\n *\n * @template T - The type of elements in the array.\n * @template K - The type of keys.\n * @param {T[]} arr - The array to group.\n * @param {(item: T) => K} getKeyFromItem - A function that generates a key from an element.\n * @returns {Record<K, T[]>} An object where each key is associated with an array of elements that\n * share that key.\n *\n * @example\n * const array = [\n * { category: 'fruit', name: 'apple' },\n * { category: 'fruit', name: 'banana' },\n * { category: 'vegetable', name: 'carrot' }\n * ];\n * const result = groupBy(array, item => item.category);\n * // result will be:\n * // {\n * // fruit: [\n * // { category: 'fruit', name: 'apple' },\n * // { category: 'fruit', name: 'banana' }\n * // ],\n * // vegetable: [\n * // { category: 'vegetable', name: 'carrot' }\n * // ]\n * // }\n */\nexport function groupBy<T, K extends PropertyKey>(arr: readonly T[], getKeyFromItem: (item: T) => K): Record<K, T[]> {\n const result = {} as Record<K, T[]>;\n\n for (const item of arr) {\n const key = getKeyFromItem(item);\n\n if (result[key] == null) {\n result[key] = [];\n }\n\n result[key].push(item);\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgCO,SAAS,QAAkC,KAAmB,gBAAgD;AACnH,QAAM,SAAS,CAAC;AAEhB,aAAW,QAAQ,KAAK;AACtB,UAAM,MAAM,eAAe,IAAI;AAE/B,QAAI,OAAO,GAAG,KAAK,MAAM;AACvB,aAAO,GAAG,IAAI,CAAC;AAAA,IACjB;AAEA,WAAO,GAAG,EAAE,KAAK,IAAI;AAAA,EACvB;AAEA,SAAO;AACT;","names":[]}
|
package/dist/array/groupBy.mjs
CHANGED
package/dist/array/index.d.mts
CHANGED
package/dist/array/index.d.ts
CHANGED
package/dist/array/index.js
CHANGED
|
@@ -29,6 +29,7 @@ __export(array_exports, {
|
|
|
29
29
|
dropRight: () => dropRight,
|
|
30
30
|
dropRightWhile: () => dropRightWhile,
|
|
31
31
|
dropWhile: () => dropWhile,
|
|
32
|
+
fill: () => fill,
|
|
32
33
|
groupBy: () => groupBy,
|
|
33
34
|
intersection: () => intersection,
|
|
34
35
|
intersectionBy: () => intersectionBy,
|
|
@@ -413,6 +414,16 @@ function zipObject(keys, values) {
|
|
|
413
414
|
}
|
|
414
415
|
return result;
|
|
415
416
|
}
|
|
417
|
+
|
|
418
|
+
// src/array/fill.ts
|
|
419
|
+
function fill(arr, value, start = 0, end = arr.length) {
|
|
420
|
+
start = Math.max(start, 0);
|
|
421
|
+
end = Math.min(end, arr.length);
|
|
422
|
+
for (let i = start; i < end; i++) {
|
|
423
|
+
arr[i] = value;
|
|
424
|
+
}
|
|
425
|
+
return arr;
|
|
426
|
+
}
|
|
416
427
|
// Annotate the CommonJS export names for ESM import in node:
|
|
417
428
|
0 && (module.exports = {
|
|
418
429
|
chunk,
|
|
@@ -424,6 +435,7 @@ function zipObject(keys, values) {
|
|
|
424
435
|
dropRight,
|
|
425
436
|
dropRightWhile,
|
|
426
437
|
dropWhile,
|
|
438
|
+
fill,
|
|
427
439
|
groupBy,
|
|
428
440
|
intersection,
|
|
429
441
|
intersectionBy,
|