es-toolkit 1.6.1 → 1.7.0-dev.146
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 +13 -0
- 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/countBy.d.mts +20 -0
- package/dist/array/countBy.d.ts +20 -0
- package/dist/array/countBy.js +39 -0
- package/dist/array/countBy.js.map +1 -0
- package/dist/array/countBy.mjs +8 -0
- 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/forEachRight.d.mts +25 -0
- package/dist/array/forEachRight.d.ts +25 -0
- package/dist/array/forEachRight.js +36 -0
- package/dist/array/forEachRight.js.map +1 -0
- package/dist/array/forEachRight.mjs +8 -0
- package/dist/array/forEachRight.mjs.map +1 -0
- package/dist/array/groupBy.d.mts +3 -1
- package/dist/array/groupBy.d.ts +3 -1
- package/dist/array/groupBy.js.map +1 -1
- package/dist/array/groupBy.mjs +1 -1
- package/dist/array/index.d.mts +7 -1
- package/dist/array/index.d.ts +7 -1
- package/dist/array/index.js +103 -7
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +78 -52
- 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 +3 -1
- package/dist/array/keyBy.d.ts +3 -1
- 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 +21 -0
- package/dist/array/sampleSize.d.ts +21 -0
- package/dist/array/sampleSize.js +65 -0
- package/dist/array/sampleSize.js.map +1 -0
- package/dist/array/sampleSize.mjs +10 -0
- package/dist/array/sampleSize.mjs.map +1 -0
- 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/unzipWith.d.mts +17 -0
- package/dist/array/unzipWith.d.ts +17 -0
- package/dist/array/unzipWith.js +42 -0
- package/dist/array/unzipWith.js.map +1 -0
- package/dist/array/unzipWith.mjs +8 -0
- package/dist/array/unzipWith.mjs.map +1 -0
- package/dist/array/without.d.mts +23 -0
- package/dist/array/without.d.ts +23 -0
- package/dist/array/without.js +34 -0
- package/dist/array/without.js.map +1 -0
- package/dist/array/without.mjs +8 -0
- package/dist/array/without.mjs.map +1 -0
- 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-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-ZOTAORG3.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-CRSKT4WW.mjs +15 -0
- package/dist/chunk-CRSKT4WW.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-VP2LXY75.mjs → chunk-DXB7EZUQ.mjs} +1 -1
- package/dist/chunk-DXB7EZUQ.mjs.map +1 -0
- package/dist/{chunk-LWXZFXY5.mjs → chunk-E6E4RZLN.mjs} +1 -1
- package/dist/chunk-E6E4RZLN.mjs.map +1 -0
- package/dist/chunk-EHSKB6DF.mjs +26 -0
- package/dist/chunk-EHSKB6DF.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-IEA53J7P.mjs +12 -0
- package/dist/chunk-IEA53J7P.mjs.map +1 -0
- package/dist/chunk-IFNXROZR.mjs +18 -0
- package/dist/chunk-IFNXROZR.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-KHK7LKE5.mjs → chunk-LT6E4Y4Z.mjs} +1 -1
- package/dist/chunk-LT6E4Y4Z.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-CDA4NK7J.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-PYEYV7BY.mjs +10 -0
- package/dist/chunk-PYEYV7BY.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-SDIMTYZW.mjs +14 -0
- package/dist/chunk-SDIMTYZW.mjs.map +1 -0
- package/dist/chunk-TZE6EDCX.mjs +1 -0
- package/dist/chunk-TZE6EDCX.mjs.map +1 -0
- package/dist/{chunk-2EFS3VA3.mjs → chunk-XI7KRD2C.mjs} +1 -1
- package/dist/chunk-XI7KRD2C.mjs.map +1 -0
- package/dist/chunk-XJR5WV2Z.mjs +1 -0
- package/dist/chunk-XJR5WV2Z.mjs.map +1 -0
- package/dist/error/AbortError.d.mts +4 -0
- package/dist/error/AbortError.d.ts +4 -0
- 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 +7 -7
- 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 +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +109 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +119 -91
- package/dist/math/index.d.mts +1 -0
- package/dist/math/index.d.ts +1 -0
- package/dist/math/index.js +8 -0
- package/dist/math/index.js.map +1 -1
- package/dist/math/index.mjs +15 -11
- package/dist/math/mean.d.mts +1 -1
- package/dist/math/mean.d.ts +1 -1
- package/dist/math/mean.js.map +1 -1
- package/dist/math/mean.mjs +1 -1
- package/dist/math/meanBy.d.mts +18 -0
- package/dist/math/meanBy.d.ts +18 -0
- package/dist/math/meanBy.js +50 -0
- package/dist/math/meanBy.js.map +1 -0
- package/dist/math/meanBy.mjs +10 -0
- package/dist/math/meanBy.mjs.map +1 -0
- 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 +1 -1
- 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 +9 -1
- package/dist/chunk-2EFS3VA3.mjs.map +0 -1
- package/dist/chunk-2PFDLYQC.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-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-K2BAFL2T.mjs.map +0 -1
- package/dist/chunk-KHK7LKE5.mjs.map +0 -1
- package/dist/chunk-LWXZFXY5.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-Q75KEFW5.mjs.map +0 -1
- package/dist/chunk-QVHWSUEH.mjs +0 -1
- package/dist/chunk-UFAA5WKR.mjs.map +0 -1
- package/dist/chunk-UPJXHWSJ.mjs.map +0 -1
- package/dist/chunk-V6MDTRGS.mjs +0 -1
- package/dist/chunk-VKM3R5T5.mjs.map +0 -1
- package/dist/chunk-VP2LXY75.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-ZOTAORG3.mjs.map +0 -1
- package/dist/chunk-ZQNAZPSK.mjs.map +0 -1
- /package/dist/{chunk-QVHWSUEH.mjs.map → array/countBy.mjs.map} +0 -0
- /package/dist/{chunk-V6MDTRGS.mjs.map → array/fill.mjs.map} +0 -0
- /package/dist/{chunk-CDA4NK7J.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/index.mjs
CHANGED
|
@@ -1,94 +1,115 @@
|
|
|
1
|
-
import "../chunk-
|
|
2
|
-
import {
|
|
3
|
-
xorBy
|
|
4
|
-
} from "../chunk-E54CCWDL.mjs";
|
|
5
|
-
import {
|
|
6
|
-
xorWith
|
|
7
|
-
} from "../chunk-JSS4FXUD.mjs";
|
|
1
|
+
import "../chunk-XJR5WV2Z.mjs";
|
|
8
2
|
import {
|
|
9
3
|
zip
|
|
10
4
|
} from "../chunk-IDCUZVJL.mjs";
|
|
11
5
|
import {
|
|
12
6
|
zipObject
|
|
13
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-6GWEY5EL.mjs";
|
|
14
8
|
import {
|
|
15
9
|
zipWith
|
|
16
10
|
} from "../chunk-4KYXHZ4R.mjs";
|
|
11
|
+
import {
|
|
12
|
+
uniqBy
|
|
13
|
+
} from "../chunk-OXAZEEGP.mjs";
|
|
14
|
+
import {
|
|
15
|
+
unzipWith
|
|
16
|
+
} from "../chunk-IFNXROZR.mjs";
|
|
17
|
+
import {
|
|
18
|
+
without
|
|
19
|
+
} from "../chunk-PYEYV7BY.mjs";
|
|
20
|
+
import {
|
|
21
|
+
xor
|
|
22
|
+
} from "../chunk-L7FQX5MN.mjs";
|
|
23
|
+
import {
|
|
24
|
+
xorBy
|
|
25
|
+
} from "../chunk-Q47NGNXT.mjs";
|
|
26
|
+
import {
|
|
27
|
+
xorWith
|
|
28
|
+
} from "../chunk-QRSJBBFY.mjs";
|
|
29
|
+
import {
|
|
30
|
+
shuffle
|
|
31
|
+
} from "../chunk-G7UQ5PUR.mjs";
|
|
32
|
+
import {
|
|
33
|
+
take
|
|
34
|
+
} from "../chunk-ME352XO7.mjs";
|
|
35
|
+
import {
|
|
36
|
+
takeRight
|
|
37
|
+
} from "../chunk-IQLKIDXF.mjs";
|
|
38
|
+
import {
|
|
39
|
+
takeRightWhile
|
|
40
|
+
} from "../chunk-NTLX2MPV.mjs";
|
|
17
41
|
import {
|
|
18
42
|
takeWhile
|
|
19
43
|
} from "../chunk-2IXFGSUA.mjs";
|
|
44
|
+
import {
|
|
45
|
+
union
|
|
46
|
+
} from "../chunk-R6QA7PLZ.mjs";
|
|
47
|
+
import {
|
|
48
|
+
uniq
|
|
49
|
+
} from "../chunk-DVK2N4KC.mjs";
|
|
20
50
|
import {
|
|
21
51
|
unionBy
|
|
22
|
-
} from "../chunk-
|
|
52
|
+
} from "../chunk-NFS7RWWE.mjs";
|
|
23
53
|
import {
|
|
24
54
|
unionWith
|
|
25
|
-
} from "../chunk-
|
|
26
|
-
import {
|
|
27
|
-
uniqBy
|
|
28
|
-
} from "../chunk-WPDDOUQT.mjs";
|
|
55
|
+
} from "../chunk-2ZCITDMK.mjs";
|
|
29
56
|
import {
|
|
30
57
|
uniqWith
|
|
31
|
-
} from "../chunk-
|
|
58
|
+
} from "../chunk-237HGSZS.mjs";
|
|
32
59
|
import {
|
|
33
|
-
|
|
34
|
-
} from "../chunk-
|
|
60
|
+
intersectionBy
|
|
61
|
+
} from "../chunk-O6UXZR3U.mjs";
|
|
35
62
|
import {
|
|
36
|
-
|
|
37
|
-
} from "../chunk-
|
|
63
|
+
intersectionWith
|
|
64
|
+
} from "../chunk-XI7KRD2C.mjs";
|
|
38
65
|
import {
|
|
39
|
-
|
|
40
|
-
} from "../chunk-
|
|
66
|
+
keyBy
|
|
67
|
+
} from "../chunk-AJKZMN2V.mjs";
|
|
41
68
|
import {
|
|
42
69
|
maxBy
|
|
43
|
-
} from "../chunk-
|
|
70
|
+
} from "../chunk-OOKNBU4V.mjs";
|
|
44
71
|
import {
|
|
45
72
|
minBy
|
|
46
|
-
} from "../chunk-
|
|
73
|
+
} from "../chunk-IJD7FE2Z.mjs";
|
|
47
74
|
import {
|
|
48
75
|
partition
|
|
49
|
-
} from "../chunk-
|
|
76
|
+
} from "../chunk-DN3NOZ3H.mjs";
|
|
50
77
|
import {
|
|
51
78
|
sample
|
|
52
|
-
} from "../chunk-
|
|
53
|
-
import {
|
|
54
|
-
shuffle
|
|
55
|
-
} from "../chunk-DPLJQQFX.mjs";
|
|
79
|
+
} from "../chunk-2KNLZB7V.mjs";
|
|
56
80
|
import {
|
|
57
|
-
|
|
58
|
-
} from "../chunk-
|
|
59
|
-
import {
|
|
60
|
-
takeRight
|
|
61
|
-
} from "../chunk-XDKEPIUV.mjs";
|
|
81
|
+
sampleSize
|
|
82
|
+
} from "../chunk-EHSKB6DF.mjs";
|
|
62
83
|
import {
|
|
63
|
-
|
|
64
|
-
} from "../chunk-
|
|
84
|
+
dropRight
|
|
85
|
+
} from "../chunk-JEKUA56R.mjs";
|
|
65
86
|
import {
|
|
66
87
|
dropRightWhile
|
|
67
|
-
} from "../chunk-
|
|
88
|
+
} from "../chunk-JE6JKZU3.mjs";
|
|
68
89
|
import {
|
|
69
90
|
dropWhile
|
|
70
|
-
} from "../chunk-
|
|
91
|
+
} from "../chunk-LJ2C6MVP.mjs";
|
|
71
92
|
import {
|
|
72
|
-
|
|
73
|
-
} from "../chunk-
|
|
93
|
+
fill
|
|
94
|
+
} from "../chunk-C4WE4GLC.mjs";
|
|
74
95
|
import {
|
|
75
|
-
|
|
76
|
-
} from "../chunk-
|
|
77
|
-
import {
|
|
78
|
-
intersectionBy
|
|
79
|
-
} from "../chunk-GNSJP2AB.mjs";
|
|
96
|
+
forEachRight
|
|
97
|
+
} from "../chunk-IEA53J7P.mjs";
|
|
80
98
|
import {
|
|
81
|
-
|
|
82
|
-
} from "../chunk-
|
|
99
|
+
groupBy
|
|
100
|
+
} from "../chunk-E6E4RZLN.mjs";
|
|
83
101
|
import {
|
|
84
|
-
|
|
85
|
-
} from "../chunk-
|
|
102
|
+
intersection
|
|
103
|
+
} from "../chunk-FVVSE2F2.mjs";
|
|
86
104
|
import {
|
|
87
105
|
chunk
|
|
88
106
|
} from "../chunk-E6C5EZQA.mjs";
|
|
89
107
|
import {
|
|
90
108
|
compact
|
|
91
|
-
} from "../chunk-
|
|
109
|
+
} from "../chunk-DTJJIMKJ.mjs";
|
|
110
|
+
import {
|
|
111
|
+
countBy
|
|
112
|
+
} from "../chunk-CRSKT4WW.mjs";
|
|
92
113
|
import {
|
|
93
114
|
difference
|
|
94
115
|
} from "../chunk-JPUKH67K.mjs";
|
|
@@ -100,14 +121,14 @@ import {
|
|
|
100
121
|
} from "../chunk-6NVQAHXP.mjs";
|
|
101
122
|
import {
|
|
102
123
|
drop
|
|
103
|
-
} from "../chunk-
|
|
104
|
-
import
|
|
105
|
-
|
|
106
|
-
} from "../chunk-Q75KEFW5.mjs";
|
|
124
|
+
} from "../chunk-S3CORED5.mjs";
|
|
125
|
+
import "../chunk-GIWAOOFY.mjs";
|
|
126
|
+
import "../chunk-SYWMYQYJ.mjs";
|
|
107
127
|
import "../chunk-2MM5EJJX.mjs";
|
|
108
128
|
export {
|
|
109
129
|
chunk,
|
|
110
130
|
compact,
|
|
131
|
+
countBy,
|
|
111
132
|
difference,
|
|
112
133
|
differenceBy,
|
|
113
134
|
differenceWith,
|
|
@@ -115,6 +136,8 @@ export {
|
|
|
115
136
|
dropRight,
|
|
116
137
|
dropRightWhile,
|
|
117
138
|
dropWhile,
|
|
139
|
+
fill,
|
|
140
|
+
forEachRight,
|
|
118
141
|
groupBy,
|
|
119
142
|
intersection,
|
|
120
143
|
intersectionBy,
|
|
@@ -124,6 +147,7 @@ export {
|
|
|
124
147
|
minBy,
|
|
125
148
|
partition,
|
|
126
149
|
sample,
|
|
150
|
+
sampleSize,
|
|
127
151
|
shuffle,
|
|
128
152
|
take,
|
|
129
153
|
takeRight,
|
|
@@ -135,6 +159,8 @@ export {
|
|
|
135
159
|
uniq,
|
|
136
160
|
uniqBy,
|
|
137
161
|
uniqWith,
|
|
162
|
+
unzipWith,
|
|
163
|
+
without,
|
|
138
164
|
xor,
|
|
139
165
|
xorBy,
|
|
140
166
|
xorWith,
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* present in both arrays. It effectively filters out any elements from the first array that
|
|
6
6
|
* are not found in the second array.
|
|
7
7
|
*
|
|
8
|
+
* @template T - The type of elements in the array.
|
|
8
9
|
* @param {T[]} firstArr - The first array to compare.
|
|
9
10
|
* @param {T[]} secondArr - The second array to compare.
|
|
10
11
|
* @returns {T[]} A new array containing the elements that are present in both arrays.
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* present in both arrays. It effectively filters out any elements from the first array that
|
|
6
6
|
* are not found in the second array.
|
|
7
7
|
*
|
|
8
|
+
* @template T - The type of elements in the array.
|
|
8
9
|
* @param {T[]} firstArr - The first array to compare.
|
|
9
10
|
* @param {T[]} secondArr - The second array to compare.
|
|
10
11
|
* @returns {T[]} A new array containing the elements that are present in both arrays.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/intersection.ts"],"sourcesContent":["/**\n * Returns the intersection of two arrays.\n *\n * This function takes two arrays and returns a new array containing the elements that are\n * present in both arrays. It effectively filters out any elements from the first array that\n * are not found in the second array.\n *\n * @param {T[]} firstArr - The first array to compare.\n * @param {T[]} secondArr - The second array to compare.\n * @returns {T[]} A new array containing the elements that are present in both arrays.\n *\n * @example\n * const array1 = [1, 2, 3, 4, 5];\n * const array2 = [3, 4, 5, 6, 7];\n * const result = intersection(array1, array2);\n * // result will be [3, 4, 5] since these elements are in both arrays.\n */\nexport function intersection<T>(firstArr: readonly T[], secondArr: readonly T[]): T[] {\n const secondSet = new Set(secondArr);\n\n return firstArr.filter(item => {\n return secondSet.has(item);\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/array/intersection.ts"],"sourcesContent":["/**\n * Returns the intersection of two arrays.\n *\n * This function takes two arrays and returns a new array containing the elements that are\n * present in both arrays. It effectively filters out any elements from the first array that\n * are not found in the second array.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} firstArr - The first array to compare.\n * @param {T[]} secondArr - The second array to compare.\n * @returns {T[]} A new array containing the elements that are present in both arrays.\n *\n * @example\n * const array1 = [1, 2, 3, 4, 5];\n * const array2 = [3, 4, 5, 6, 7];\n * const result = intersection(array1, array2);\n * // result will be [3, 4, 5] since these elements are in both arrays.\n */\nexport function intersection<T>(firstArr: readonly T[], secondArr: readonly T[]): T[] {\n const secondSet = new Set(secondArr);\n\n return firstArr.filter(item => {\n return secondSet.has(item);\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBO,SAAS,aAAgB,UAAwB,WAA8B;AACpF,QAAM,YAAY,IAAI,IAAI,SAAS;AAEnC,SAAO,SAAS,OAAO,UAAQ;AAC7B,WAAO,UAAU,IAAI,IAAI;AAAA,EAC3B,CAAC;AACH;","names":[]}
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* mapped elements in the second array. It effectively filters out any elements from the first array
|
|
7
7
|
* that do not have corresponding mapped values in the second array.
|
|
8
8
|
*
|
|
9
|
+
* @template T - The type of elements in the array.
|
|
10
|
+
* @template U - The type of mapped elements.
|
|
9
11
|
* @param {T[]} firstArr - The first array to compare.
|
|
10
12
|
* @param {T[]} secondArr - The second array to compare.
|
|
11
13
|
* @param {(item: T) => U} mapper - A function to map the elements of both arrays for comparison.
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* mapped elements in the second array. It effectively filters out any elements from the first array
|
|
7
7
|
* that do not have corresponding mapped values in the second array.
|
|
8
8
|
*
|
|
9
|
+
* @template T - The type of elements in the array.
|
|
10
|
+
* @template U - The type of mapped elements.
|
|
9
11
|
* @param {T[]} firstArr - The first array to compare.
|
|
10
12
|
* @param {T[]} secondArr - The second array to compare.
|
|
11
13
|
* @param {(item: T) => U} mapper - A function to map the elements of both arrays for comparison.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/intersectionBy.ts"],"sourcesContent":["/**\n * Returns the intersection of two arrays based on a mapping function.\n *\n * This function takes two arrays and a mapping function. It returns a new array containing\n * the elements from the first array that, when mapped using the provided function, have matching\n * mapped elements in the second array. It effectively filters out any elements from the first array\n * that do not have corresponding mapped values in the second array.\n *\n * @param {T[]} firstArr - The first array to compare.\n * @param {T[]} secondArr - The second array to compare.\n * @param {(item: T) => U} mapper - A function to map the elements of both arrays for comparison.\n * @returns {T[]} A new array containing the elements from the first array that have corresponding mapped values in the second array.\n *\n * @example\n * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];\n * const array2 = [{ id: 2 }, { id: 4 }];\n * const mapper = item => item.id;\n * const result = intersectionBy(array1, array2, mapper);\n * // result will be [{ id: 2 }] since only this element has a matching id in both arrays.\n */\nexport function intersectionBy<T, U>(firstArr: readonly T[], secondArr: readonly T[], mapper: (item: T) => U): T[] {\n const mappedSecondSet = new Set(secondArr.map(mapper));\n return firstArr.filter(item => mappedSecondSet.has(mapper(item)));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/array/intersectionBy.ts"],"sourcesContent":["/**\n * Returns the intersection of two arrays based on a mapping function.\n *\n * This function takes two arrays and a mapping function. It returns a new array containing\n * the elements from the first array that, when mapped using the provided function, have matching\n * mapped elements in the second array. It effectively filters out any elements from the first array\n * that do not have corresponding mapped values in the second array.\n *\n * @template T - The type of elements in the array.\n * @template U - The type of mapped elements.\n * @param {T[]} firstArr - The first array to compare.\n * @param {T[]} secondArr - The second array to compare.\n * @param {(item: T) => U} mapper - A function to map the elements of both arrays for comparison.\n * @returns {T[]} A new array containing the elements from the first array that have corresponding mapped values in the second array.\n *\n * @example\n * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];\n * const array2 = [{ id: 2 }, { id: 4 }];\n * const mapper = item => item.id;\n * const result = intersectionBy(array1, array2, mapper);\n * // result will be [{ id: 2 }] since only this element has a matching id in both arrays.\n */\nexport function intersectionBy<T, U>(firstArr: readonly T[], secondArr: readonly T[], mapper: (item: T) => U): T[] {\n const mappedSecondSet = new Set(secondArr.map(mapper));\n return firstArr.filter(item => mappedSecondSet.has(mapper(item)));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBO,SAAS,eAAqB,UAAwB,WAAyB,QAA6B;AACjH,QAAM,kBAAkB,IAAI,IAAI,UAAU,IAAI,MAAM,CAAC;AACrD,SAAO,SAAS,OAAO,UAAQ,gBAAgB,IAAI,OAAO,IAAI,CAAC,CAAC;AAClE;","names":[]}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* by the custom equality function. It effectively filters out any elements from the first array that
|
|
7
7
|
* do not have corresponding matches in the second array according to the equality function.
|
|
8
8
|
*
|
|
9
|
+
* @template T - The type of elements in the array.
|
|
9
10
|
* @param {T[]} firstArr - The first array to compare.
|
|
10
11
|
* @param {T[]} secondArr - The second array to compare.
|
|
11
12
|
* @param {(x: T, y: T) => boolean} areItemsEqual - A custom function to determine if two elements are equal.
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* by the custom equality function. It effectively filters out any elements from the first array that
|
|
7
7
|
* do not have corresponding matches in the second array according to the equality function.
|
|
8
8
|
*
|
|
9
|
+
* @template T - The type of elements in the array.
|
|
9
10
|
* @param {T[]} firstArr - The first array to compare.
|
|
10
11
|
* @param {T[]} secondArr - The second array to compare.
|
|
11
12
|
* @param {(x: T, y: T) => boolean} areItemsEqual - A custom function to determine if two elements are equal.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/intersectionWith.ts"],"sourcesContent":["/**\n * Returns the intersection of two arrays based on a custom equality function.\n *\n * This function takes two arrays and a custom equality function. It returns a new array containing\n * the elements from the first array that have matching elements in the second array, as determined\n * by the custom equality function. It effectively filters out any elements from the first array that\n * do not have corresponding matches in the second array according to the equality function.\n *\n * @param {T[]} firstArr - The first array to compare.\n * @param {T[]} secondArr - The second array to compare.\n * @param {(x: T, y: T) => boolean} areItemsEqual - A custom function to determine if two elements are equal.\n * This function takes two arguments, one from each array, and returns `true` if the elements are considered equal, and `false` otherwise.\n * @returns {T[]} A new array containing the elements from the first array that have corresponding matches in the second array according to the custom equality function.\n *\n * @example\n * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];\n * const array2 = [{ id: 2 }, { id: 4 }];\n * const areItemsEqual = (a, b) => a.id === b.id;\n * const result = intersectionWith(array1, array2, areItemsEqual);\n * // result will be [{ id: 2 }] since this element has a matching id in both arrays.\n */\nexport function intersectionWith<T>(\n firstArr: readonly T[],\n secondArr: readonly T[],\n areItemsEqual: (x: T, y: T) => boolean\n): T[] {\n return firstArr.filter(firstItem => {\n return secondArr.some(secondItem => {\n return areItemsEqual(firstItem, secondItem);\n });\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/array/intersectionWith.ts"],"sourcesContent":["/**\n * Returns the intersection of two arrays based on a custom equality function.\n *\n * This function takes two arrays and a custom equality function. It returns a new array containing\n * the elements from the first array that have matching elements in the second array, as determined\n * by the custom equality function. It effectively filters out any elements from the first array that\n * do not have corresponding matches in the second array according to the equality function.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} firstArr - The first array to compare.\n * @param {T[]} secondArr - The second array to compare.\n * @param {(x: T, y: T) => boolean} areItemsEqual - A custom function to determine if two elements are equal.\n * This function takes two arguments, one from each array, and returns `true` if the elements are considered equal, and `false` otherwise.\n * @returns {T[]} A new array containing the elements from the first array that have corresponding matches in the second array according to the custom equality function.\n *\n * @example\n * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];\n * const array2 = [{ id: 2 }, { id: 4 }];\n * const areItemsEqual = (a, b) => a.id === b.id;\n * const result = intersectionWith(array1, array2, areItemsEqual);\n * // result will be [{ id: 2 }] since this element has a matching id in both arrays.\n */\nexport function intersectionWith<T>(\n firstArr: readonly T[],\n secondArr: readonly T[],\n areItemsEqual: (x: T, y: T) => boolean\n): T[] {\n return firstArr.filter(firstItem => {\n return secondArr.some(secondItem => {\n return areItemsEqual(firstItem, secondItem);\n });\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBO,SAAS,iBACd,UACA,WACA,eACK;AACL,SAAO,SAAS,OAAO,eAAa;AAClC,WAAO,UAAU,KAAK,gBAAc;AAClC,aAAO,cAAc,WAAW,UAAU;AAAA,IAC5C,CAAC;AAAA,EACH,CAAC;AACH;","names":[]}
|
package/dist/array/keyBy.d.mts
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* If there are multiple elements generating the same key, the last element among them is used
|
|
7
7
|
* as the value.
|
|
8
8
|
*
|
|
9
|
+
* @template T - The type of elements in the array.
|
|
10
|
+
* @template K - The type of keys.
|
|
9
11
|
* @param {T[]} arr - The array of elements to be mapped.
|
|
10
12
|
* @param {(item: T) => K} getKeyFromItem - A function that generates a key from an element.
|
|
11
13
|
* @returns {Record<K, T>} An object where keys are mapped to each element of an array.
|
|
@@ -23,6 +25,6 @@
|
|
|
23
25
|
* // vegetable: { category: 'vegetable', name: 'carrot' }
|
|
24
26
|
* // }
|
|
25
27
|
*/
|
|
26
|
-
declare function keyBy<T, K extends
|
|
28
|
+
declare function keyBy<T, K extends PropertyKey>(arr: readonly T[], getKeyFromItem: (item: T) => K): Record<K, T>;
|
|
27
29
|
|
|
28
30
|
export { keyBy };
|
package/dist/array/keyBy.d.ts
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* If there are multiple elements generating the same key, the last element among them is used
|
|
7
7
|
* as the value.
|
|
8
8
|
*
|
|
9
|
+
* @template T - The type of elements in the array.
|
|
10
|
+
* @template K - The type of keys.
|
|
9
11
|
* @param {T[]} arr - The array of elements to be mapped.
|
|
10
12
|
* @param {(item: T) => K} getKeyFromItem - A function that generates a key from an element.
|
|
11
13
|
* @returns {Record<K, T>} An object where keys are mapped to each element of an array.
|
|
@@ -23,6 +25,6 @@
|
|
|
23
25
|
* // vegetable: { category: 'vegetable', name: 'carrot' }
|
|
24
26
|
* // }
|
|
25
27
|
*/
|
|
26
|
-
declare function keyBy<T, K extends
|
|
28
|
+
declare function keyBy<T, K extends PropertyKey>(arr: readonly T[], getKeyFromItem: (item: T) => K): Record<K, T>;
|
|
27
29
|
|
|
28
30
|
export { keyBy };
|
package/dist/array/keyBy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/keyBy.ts"],"sourcesContent":["/**\n * Maps each element 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 the corresponding elements.\n * If there are multiple elements generating the same key, the last element among them is used\n * as the value.\n *\n * @param {T[]} arr - The array of elements to be mapped.\n * @param {(item: T) => K} getKeyFromItem - A function that generates a key from an element.\n * @returns {Record<K, T>} An object where keys are mapped to each element of an array.\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 = keyBy(array, item => item.category);\n * // result will be:\n * // {\n * // fruit: { category: 'fruit', name: 'banana' },\n * // vegetable: { category: 'vegetable', name: 'carrot' }\n * // }\n */\nexport function keyBy<T, K extends
|
|
1
|
+
{"version":3,"sources":["../../src/array/keyBy.ts"],"sourcesContent":["/**\n * Maps each element 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 the corresponding elements.\n * If there are multiple elements generating the same key, the last element among them is used\n * as the value.\n *\n * @template T - The type of elements in the array.\n * @template K - The type of keys.\n * @param {T[]} arr - The array of elements to be mapped.\n * @param {(item: T) => K} getKeyFromItem - A function that generates a key from an element.\n * @returns {Record<K, T>} An object where keys are mapped to each element of an array.\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 = keyBy(array, item => item.category);\n * // result will be:\n * // {\n * // fruit: { category: 'fruit', name: 'banana' },\n * // vegetable: { category: 'vegetable', name: 'carrot' }\n * // }\n */\nexport function keyBy<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 result[key] = item;\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BO,SAAS,MAAgC,KAAmB,gBAA8C;AAC/G,QAAM,SAAS,CAAC;AAEhB,aAAW,QAAQ,KAAK;AACtB,UAAM,MAAM,eAAe,IAAI;AAC/B,WAAO,GAAG,IAAI;AAAA,EAChB;AAEA,SAAO;AACT;","names":[]}
|
package/dist/array/keyBy.mjs
CHANGED
package/dist/array/maxBy.d.mts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Finds the element in an array that has the maximum value when applying
|
|
3
3
|
* the `getValue` function to each element.
|
|
4
4
|
*
|
|
5
|
+
* @template T - The type of elements in the array.
|
|
5
6
|
* @param {T[]} items The array of elements to search.
|
|
6
7
|
* @param {(element: T) => number} getValue A function that selects a numeric value from each element.
|
|
7
8
|
* @returns {T} The element with the maximum value as determined by the `getValue` function.
|
package/dist/array/maxBy.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Finds the element in an array that has the maximum value when applying
|
|
3
3
|
* the `getValue` function to each element.
|
|
4
4
|
*
|
|
5
|
+
* @template T - The type of elements in the array.
|
|
5
6
|
* @param {T[]} items The array of elements to search.
|
|
6
7
|
* @param {(element: T) => number} getValue A function that selects a numeric value from each element.
|
|
7
8
|
* @returns {T} The element with the maximum value as determined by the `getValue` function.
|
package/dist/array/maxBy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/maxBy.ts"],"sourcesContent":["/**\n * Finds the element in an array that has the maximum value when applying\n * the `getValue` function to each element.\n *\n * @param {T[]} items The array of elements to search.\n * @param {(element: T) => number} getValue A function that selects a numeric value from each element.\n * @returns {T} The element with the maximum value as determined by the `getValue` function.\n * @example\n * maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 }\n * maxBy([], x => x.a); // Returns: undefined\n */\nexport function maxBy<T>(items: T[], getValue: (element: T) => number): T {\n let maxElement = items[0];\n let max = -Infinity;\n\n for (const element of items) {\n const value = getValue(element);\n if (value > max) {\n max = value;\n maxElement = element;\n }\n }\n\n return maxElement;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/array/maxBy.ts"],"sourcesContent":["/**\n * Finds the element in an array that has the maximum value when applying\n * the `getValue` function to each element.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} items The array of elements to search.\n * @param {(element: T) => number} getValue A function that selects a numeric value from each element.\n * @returns {T} The element with the maximum value as determined by the `getValue` function.\n * @example\n * maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 }\n * maxBy([], x => x.a); // Returns: undefined\n */\nexport function maxBy<T>(items: T[], getValue: (element: T) => number): T {\n let maxElement = items[0];\n let max = -Infinity;\n\n for (const element of items) {\n const value = getValue(element);\n if (value > max) {\n max = value;\n maxElement = element;\n }\n }\n\n return maxElement;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAYO,SAAS,MAAS,OAAY,UAAqC;AACxE,MAAI,aAAa,MAAM,CAAC;AACxB,MAAI,MAAM;AAEV,aAAW,WAAW,OAAO;AAC3B,UAAM,QAAQ,SAAS,OAAO;AAC9B,QAAI,QAAQ,KAAK;AACf,YAAM;AACN,mBAAa;AAAA,IACf;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
package/dist/array/maxBy.mjs
CHANGED
package/dist/array/minBy.d.mts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Finds the element in an array that has the minimum value when applying
|
|
3
3
|
* the `getValue` function to each element.
|
|
4
4
|
*
|
|
5
|
+
* @template T - The type of elements in the array.
|
|
5
6
|
* @param {T[]} items The array of elements to search.
|
|
6
7
|
* @param {(element: T) => number} getValue A function that selects a numeric value from each element.
|
|
7
8
|
* @returns {T} The element with the minimum value as determined by the `getValue` function.
|
package/dist/array/minBy.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Finds the element in an array that has the minimum value when applying
|
|
3
3
|
* the `getValue` function to each element.
|
|
4
4
|
*
|
|
5
|
+
* @template T - The type of elements in the array.
|
|
5
6
|
* @param {T[]} items The array of elements to search.
|
|
6
7
|
* @param {(element: T) => number} getValue A function that selects a numeric value from each element.
|
|
7
8
|
* @returns {T} The element with the minimum value as determined by the `getValue` function.
|
package/dist/array/minBy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/minBy.ts"],"sourcesContent":["/**\n * Finds the element in an array that has the minimum value when applying\n * the `getValue` function to each element.\n *\n * @param {T[]} items The array of elements to search.\n * @param {(element: T) => number} getValue A function that selects a numeric value from each element.\n * @returns {T} The element with the minimum value as determined by the `getValue` function.\n * @example\n * minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }\n * minBy([], x => x.a); // Returns: undefined\n */\nexport function minBy<T>(items: T[], getValue: (element: T) => number): T {\n let minElement = items[0];\n let min = Infinity;\n\n for (const element of items) {\n const value = getValue(element);\n if (value < min) {\n min = value;\n minElement = element;\n }\n }\n\n return minElement;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/array/minBy.ts"],"sourcesContent":["/**\n * Finds the element in an array that has the minimum value when applying\n * the `getValue` function to each element.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} items The array of elements to search.\n * @param {(element: T) => number} getValue A function that selects a numeric value from each element.\n * @returns {T} The element with the minimum value as determined by the `getValue` function.\n * @example\n * minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }\n * minBy([], x => x.a); // Returns: undefined\n */\nexport function minBy<T>(items: T[], getValue: (element: T) => number): T {\n let minElement = items[0];\n let min = Infinity;\n\n for (const element of items) {\n const value = getValue(element);\n if (value < min) {\n min = value;\n minElement = element;\n }\n }\n\n return minElement;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAYO,SAAS,MAAS,OAAY,UAAqC;AACxE,MAAI,aAAa,MAAM,CAAC;AACxB,MAAI,MAAM;AAEV,aAAW,WAAW,OAAO;AAC3B,UAAM,QAAQ,SAAS,OAAO;AAC9B,QAAI,QAAQ,KAAK;AACf,YAAM;AACN,mBAAa;AAAA,IACf;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
package/dist/array/minBy.mjs
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* the first array contains elements for which the predicate function returns true, and
|
|
6
6
|
* the second array contains elements for which the predicate function returns false.
|
|
7
7
|
*
|
|
8
|
+
* @template T - The type of elements in the array.
|
|
8
9
|
* @param {T[]} arr - The array to partition.
|
|
9
10
|
* @param {(value: T) => boolean} isInTruthy - A predicate function that determines
|
|
10
11
|
* whether an element should be placed in the truthy array. The function is called with each
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* the first array contains elements for which the predicate function returns true, and
|
|
6
6
|
* the second array contains elements for which the predicate function returns false.
|
|
7
7
|
*
|
|
8
|
+
* @template T - The type of elements in the array.
|
|
8
9
|
* @param {T[]} arr - The array to partition.
|
|
9
10
|
* @param {(value: T) => boolean} isInTruthy - A predicate function that determines
|
|
10
11
|
* whether an element should be placed in the truthy array. The function is called with each
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/partition.ts"],"sourcesContent":["/**\n * Splits an array into two groups based on a predicate function.\n *\n * This function takes an array and a predicate function. It returns a tuple of two arrays:\n * the first array contains elements for which the predicate function returns true, and\n * the second array contains elements for which the predicate function returns false.\n *\n * @param {T[]} arr - The array to partition.\n * @param {(value: T) => boolean} isInTruthy - A predicate function that determines\n * whether an element should be placed in the truthy array. The function is called with each\n * element of the array.\n * @returns {[T[], T[]]} A tuple containing two arrays: the first array contains elements for\n * which the predicate returned true, and the second array contains elements for which the\n * predicate returned false.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const isEven = x => x % 2 === 0;\n * const [even, odd] = partition(array, isEven);\n * // even will be [2, 4], and odd will be [1, 3, 5]\n */\nexport function partition<T>(arr: readonly T[], isInTruthy: (value: T) => boolean): [truthy: T[], falsy: T[]] {\n const truthy: T[] = [];\n const falsy: T[] = [];\n\n for (const item of arr) {\n if (isInTruthy(item)) {\n truthy.push(item);\n } else {\n falsy.push(item);\n }\n }\n\n return [truthy, falsy];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/array/partition.ts"],"sourcesContent":["/**\n * Splits an array into two groups based on a predicate function.\n *\n * This function takes an array and a predicate function. It returns a tuple of two arrays:\n * the first array contains elements for which the predicate function returns true, and\n * the second array contains elements for which the predicate function returns false.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to partition.\n * @param {(value: T) => boolean} isInTruthy - A predicate function that determines\n * whether an element should be placed in the truthy array. The function is called with each\n * element of the array.\n * @returns {[T[], T[]]} A tuple containing two arrays: the first array contains elements for\n * which the predicate returned true, and the second array contains elements for which the\n * predicate returned false.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const isEven = x => x % 2 === 0;\n * const [even, odd] = partition(array, isEven);\n * // even will be [2, 4], and odd will be [1, 3, 5]\n */\nexport function partition<T>(arr: readonly T[], isInTruthy: (value: T) => boolean): [truthy: T[], falsy: T[]] {\n const truthy: T[] = [];\n const falsy: T[] = [];\n\n for (const item of arr) {\n if (isInTruthy(item)) {\n truthy.push(item);\n } else {\n falsy.push(item);\n }\n }\n\n return [truthy, falsy];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBO,SAAS,UAAa,KAAmB,YAA8D;AAC5G,QAAM,SAAc,CAAC;AACrB,QAAM,QAAa,CAAC;AAEpB,aAAW,QAAQ,KAAK;AACtB,QAAI,WAAW,IAAI,GAAG;AACpB,aAAO,KAAK,IAAI;AAAA,IAClB,OAAO;AACL,YAAM,KAAK,IAAI;AAAA,IACjB;AAAA,EACF;AAEA,SAAO,CAAC,QAAQ,KAAK;AACvB;","names":[]}
|
package/dist/array/partition.mjs
CHANGED
package/dist/array/sample.d.mts
CHANGED
package/dist/array/sample.d.ts
CHANGED
package/dist/array/sample.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/sample.ts"],"sourcesContent":["/**\n * Returns a random element from an array.\n *\n * This function takes an array and returns a single element selected randomly from the array.\n *\n * @param {T[]} arr - The array to sample from.\n * @returns {T} A random element from the array.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const randomElement = sample(array);\n * // randomElement will be one of the elements from the array, selected randomly.\n */\nexport function sample<T>(arr: readonly T[]): T {\n const randomIndex = Math.floor(Math.random() * arr.length);\n return arr[randomIndex];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/array/sample.ts"],"sourcesContent":["/**\n * Returns a random element from an array.\n *\n * This function takes an array and returns a single element selected randomly from the array.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to sample from.\n * @returns {T} A random element from the array.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const randomElement = sample(array);\n * // randomElement will be one of the elements from the array, selected randomly.\n */\nexport function sample<T>(arr: readonly T[]): T {\n const randomIndex = Math.floor(Math.random() * arr.length);\n return arr[randomIndex];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAcO,SAAS,OAAU,KAAsB;AAC9C,QAAM,cAAc,KAAK,MAAM,KAAK,OAAO,IAAI,IAAI,MAAM;AACzD,SAAO,IAAI,WAAW;AACxB;","names":[]}
|
package/dist/array/sample.mjs
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a sample element array of a specified `size`.
|
|
3
|
+
*
|
|
4
|
+
* This function takes an array and a number, and returns an array containing the sampled elements using Floyd's algorithm.
|
|
5
|
+
*
|
|
6
|
+
* {@link https://www.nowherenearithaca.com/2013/05/robert-floyds-tiny-and-beautiful.html Floyd's algoritm}
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of elements in the array.
|
|
9
|
+
* @param {T[]} array - The array to sample from.
|
|
10
|
+
* @param {number} size - The size of sample.
|
|
11
|
+
* @returns {T[]} A new array with sample size applied.
|
|
12
|
+
* @throws {Error} Throws an error if `size` is greater than the length of `array`.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const result = sampleSize([1, 2, 3], 2)
|
|
16
|
+
* // result will be an array containing two of the elements from the array.
|
|
17
|
+
* // [1, 2] or [1, 3] or [2, 3]
|
|
18
|
+
*/
|
|
19
|
+
declare function sampleSize<T>(array: readonly T[], size: number): T[];
|
|
20
|
+
|
|
21
|
+
export { sampleSize };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a sample element array of a specified `size`.
|
|
3
|
+
*
|
|
4
|
+
* This function takes an array and a number, and returns an array containing the sampled elements using Floyd's algorithm.
|
|
5
|
+
*
|
|
6
|
+
* {@link https://www.nowherenearithaca.com/2013/05/robert-floyds-tiny-and-beautiful.html Floyd's algoritm}
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of elements in the array.
|
|
9
|
+
* @param {T[]} array - The array to sample from.
|
|
10
|
+
* @param {number} size - The size of sample.
|
|
11
|
+
* @returns {T[]} A new array with sample size applied.
|
|
12
|
+
* @throws {Error} Throws an error if `size` is greater than the length of `array`.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const result = sampleSize([1, 2, 3], 2)
|
|
16
|
+
* // result will be an array containing two of the elements from the array.
|
|
17
|
+
* // [1, 2] or [1, 3] or [2, 3]
|
|
18
|
+
*/
|
|
19
|
+
declare function sampleSize<T>(array: readonly T[], size: number): T[];
|
|
20
|
+
|
|
21
|
+
export { sampleSize };
|
|
@@ -0,0 +1,65 @@
|
|
|
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/sampleSize.ts
|
|
21
|
+
var sampleSize_exports = {};
|
|
22
|
+
__export(sampleSize_exports, {
|
|
23
|
+
sampleSize: () => sampleSize
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(sampleSize_exports);
|
|
26
|
+
|
|
27
|
+
// src/math/random.ts
|
|
28
|
+
function random(minimum, maximum) {
|
|
29
|
+
if (maximum == null) {
|
|
30
|
+
maximum = minimum;
|
|
31
|
+
minimum = 0;
|
|
32
|
+
}
|
|
33
|
+
if (minimum >= maximum) {
|
|
34
|
+
throw new Error("Invalid input: The maximum value must be greater than the minimum value.");
|
|
35
|
+
}
|
|
36
|
+
return Math.random() * (maximum - minimum) + minimum;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/math/randomInt.ts
|
|
40
|
+
function randomInt(minimum, maximum) {
|
|
41
|
+
return Math.floor(random(minimum, maximum));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// src/array/sampleSize.ts
|
|
45
|
+
function sampleSize(array, size) {
|
|
46
|
+
if (size > array.length) {
|
|
47
|
+
throw new Error("Size must be less than or equal to the length of array.");
|
|
48
|
+
}
|
|
49
|
+
const result = new Array(size);
|
|
50
|
+
const selected = /* @__PURE__ */ new Set();
|
|
51
|
+
for (let step = array.length - size, resultIndex = 0; step < array.length; step++, resultIndex++) {
|
|
52
|
+
let index = randomInt(0, step + 1);
|
|
53
|
+
if (selected.has(index)) {
|
|
54
|
+
index = step;
|
|
55
|
+
}
|
|
56
|
+
selected.add(index);
|
|
57
|
+
result[resultIndex] = array[index];
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
+
0 && (module.exports = {
|
|
63
|
+
sampleSize
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=sampleSize.js.map
|