es-toolkit 1.2.1-dev.65 → 1.2.1-dev.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/array/chunk.d.mts +1 -1
- package/dist/array/chunk.d.ts +1 -1
- package/dist/array/chunk.js.map +1 -1
- package/dist/array/chunk.mjs +1 -1
- package/dist/array/difference.d.mts +1 -1
- package/dist/array/difference.d.ts +1 -1
- package/dist/array/difference.js.map +1 -1
- package/dist/array/difference.mjs +1 -1
- package/dist/array/differenceBy.d.mts +1 -1
- package/dist/array/differenceBy.d.ts +1 -1
- package/dist/array/differenceBy.js.map +1 -1
- package/dist/array/differenceBy.mjs +1 -1
- package/dist/array/differenceWith.d.mts +1 -1
- package/dist/array/differenceWith.d.ts +1 -1
- package/dist/array/differenceWith.js.map +1 -1
- package/dist/array/differenceWith.mjs +1 -1
- package/dist/array/drop.d.mts +1 -1
- package/dist/array/drop.d.ts +1 -1
- package/dist/array/drop.js.map +1 -1
- package/dist/array/drop.mjs +1 -1
- package/dist/array/dropRight.d.mts +1 -1
- package/dist/array/dropRight.d.ts +1 -1
- package/dist/array/dropRight.js.map +1 -1
- package/dist/array/dropRight.mjs +1 -1
- package/dist/array/dropRightWhile.d.mts +1 -1
- package/dist/array/dropRightWhile.d.ts +1 -1
- package/dist/array/dropRightWhile.js.map +1 -1
- package/dist/array/dropRightWhile.mjs +2 -2
- package/dist/array/dropWhile.d.mts +1 -1
- package/dist/array/dropWhile.d.ts +1 -1
- package/dist/array/dropWhile.js.map +1 -1
- package/dist/array/dropWhile.mjs +1 -1
- package/dist/array/groupBy.d.mts +1 -1
- package/dist/array/groupBy.d.ts +1 -1
- package/dist/array/groupBy.js.map +1 -1
- package/dist/array/groupBy.mjs +1 -1
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +29 -29
- package/dist/array/intersection.d.mts +1 -1
- package/dist/array/intersection.d.ts +1 -1
- package/dist/array/intersection.js.map +1 -1
- package/dist/array/intersection.mjs +1 -1
- package/dist/array/intersectionBy.d.mts +1 -1
- package/dist/array/intersectionBy.d.ts +1 -1
- package/dist/array/intersectionBy.js.map +1 -1
- package/dist/array/intersectionBy.mjs +1 -1
- package/dist/array/intersectionWith.d.mts +1 -1
- package/dist/array/intersectionWith.d.ts +1 -1
- package/dist/array/intersectionWith.js.map +1 -1
- package/dist/array/intersectionWith.mjs +1 -1
- package/dist/array/sample.d.mts +1 -1
- package/dist/array/sample.d.ts +1 -1
- package/dist/array/sample.js.map +1 -1
- package/dist/array/sample.mjs +1 -1
- package/dist/array/shuffle.d.mts +1 -1
- package/dist/array/shuffle.d.ts +1 -1
- package/dist/array/shuffle.js.map +1 -1
- package/dist/array/shuffle.mjs +1 -1
- package/dist/array/take.d.mts +1 -1
- package/dist/array/take.d.ts +1 -1
- package/dist/array/take.js.map +1 -1
- package/dist/array/take.mjs +1 -1
- package/dist/array/takeRight.d.mts +1 -1
- package/dist/array/takeRight.d.ts +1 -1
- package/dist/array/takeRight.js.map +1 -1
- package/dist/array/takeRight.mjs +1 -1
- package/dist/array/takeRightWhile.d.mts +1 -1
- package/dist/array/takeRightWhile.d.ts +1 -1
- package/dist/array/takeRightWhile.js.map +1 -1
- package/dist/array/takeRightWhile.mjs +1 -1
- package/dist/array/takeWhile.d.mts +1 -1
- package/dist/array/takeWhile.d.ts +1 -1
- package/dist/array/takeWhile.js.map +1 -1
- package/dist/array/takeWhile.mjs +1 -1
- package/dist/array/union.d.mts +1 -1
- package/dist/array/union.d.ts +1 -1
- package/dist/array/union.js.map +1 -1
- package/dist/array/union.mjs +2 -2
- package/dist/array/unionBy.d.mts +1 -1
- package/dist/array/unionBy.d.ts +1 -1
- package/dist/array/unionBy.js.map +1 -1
- package/dist/array/unionBy.mjs +1 -1
- package/dist/array/unionWith.d.mts +1 -1
- package/dist/array/unionWith.d.ts +1 -1
- package/dist/array/unionWith.js.map +1 -1
- package/dist/array/unionWith.mjs +2 -2
- package/dist/array/uniq.d.mts +1 -1
- package/dist/array/uniq.d.ts +1 -1
- package/dist/array/uniq.js.map +1 -1
- package/dist/array/uniq.mjs +1 -1
- package/dist/array/uniqBy.d.mts +1 -1
- package/dist/array/uniqBy.d.ts +1 -1
- package/dist/array/uniqBy.js.map +1 -1
- package/dist/array/uniqBy.mjs +2 -2
- package/dist/array/uniqWith.d.mts +1 -1
- package/dist/array/uniqWith.d.ts +1 -1
- package/dist/array/uniqWith.js.map +1 -1
- package/dist/array/uniqWith.mjs +1 -1
- package/dist/array/xor.d.mts +1 -1
- package/dist/array/xor.d.ts +1 -1
- package/dist/array/xor.js.map +1 -1
- package/dist/array/xor.mjs +5 -5
- package/dist/array/xorBy.d.mts +1 -1
- package/dist/array/xorBy.d.ts +1 -1
- package/dist/array/xorBy.js.map +1 -1
- package/dist/array/xorBy.mjs +4 -4
- package/dist/array/xorWith.d.mts +1 -1
- package/dist/array/xorWith.d.ts +1 -1
- package/dist/array/xorWith.js.map +1 -1
- package/dist/array/xorWith.mjs +5 -5
- package/dist/array/zip.d.mts +4 -4
- package/dist/array/zip.d.ts +4 -4
- package/dist/array/zip.js.map +1 -1
- package/dist/array/zip.mjs +1 -1
- package/dist/array/zipWith.d.mts +4 -4
- package/dist/array/zipWith.d.ts +4 -4
- package/dist/array/zipWith.js.map +1 -1
- package/dist/array/zipWith.mjs +1 -1
- package/dist/{chunk-LLOAPSQ6.mjs → chunk-2IXFGSUA.mjs} +1 -1
- package/dist/{chunk-LLOAPSQ6.mjs.map → chunk-2IXFGSUA.mjs.map} +1 -1
- package/dist/{chunk-AB3DGGY3.mjs → chunk-5P2QE2VI.mjs} +2 -2
- package/dist/{chunk-AB3DGGY3.mjs.map → chunk-5P2QE2VI.mjs.map} +1 -1
- package/dist/{chunk-T6NXSQ6Z.mjs → chunk-62EFHAYX.mjs} +4 -4
- package/dist/{chunk-T6NXSQ6Z.mjs.map → chunk-62EFHAYX.mjs.map} +1 -1
- package/dist/{chunk-YNRYG5OB.mjs → chunk-7XTQCUMW.mjs} +1 -1
- package/dist/{chunk-YNRYG5OB.mjs.map → chunk-7XTQCUMW.mjs.map} +1 -1
- package/dist/{chunk-25R2U4KM.mjs → chunk-ACFP3XMB.mjs} +1 -1
- package/dist/{chunk-25R2U4KM.mjs.map → chunk-ACFP3XMB.mjs.map} +1 -1
- package/dist/{chunk-XPOJM4E7.mjs → chunk-DAJZ3JCI.mjs} +2 -2
- package/dist/{chunk-XPOJM4E7.mjs.map → chunk-DAJZ3JCI.mjs.map} +1 -1
- package/dist/{chunk-L25VRQ54.mjs → chunk-DD73BULA.mjs} +1 -1
- package/dist/chunk-DD73BULA.mjs.map +1 -0
- package/dist/{chunk-PHG5JCSW.mjs → chunk-DOOIIHT3.mjs} +1 -1
- package/dist/{chunk-PHG5JCSW.mjs.map → chunk-DOOIIHT3.mjs.map} +1 -1
- package/dist/{chunk-KPG3XQEN.mjs → chunk-DPLJQQFX.mjs} +1 -1
- package/dist/chunk-DPLJQQFX.mjs.map +1 -0
- package/dist/{chunk-OS5PZ4B4.mjs → chunk-E6C5EZQA.mjs} +1 -1
- package/dist/{chunk-OS5PZ4B4.mjs.map → chunk-E6C5EZQA.mjs.map} +1 -1
- package/dist/{chunk-VOAKEOIM.mjs → chunk-E7BJSLIX.mjs} +2 -2
- package/dist/{chunk-VOAKEOIM.mjs.map → chunk-E7BJSLIX.mjs.map} +1 -1
- package/dist/{chunk-RVAUVY4Q.mjs → chunk-EW3RT4QW.mjs} +4 -4
- package/dist/{chunk-RVAUVY4Q.mjs.map → chunk-EW3RT4QW.mjs.map} +1 -1
- package/dist/{chunk-5NSVMWDQ.mjs → chunk-FQ4K36VD.mjs} +1 -1
- package/dist/{chunk-5NSVMWDQ.mjs.map → chunk-FQ4K36VD.mjs.map} +1 -1
- package/dist/{chunk-QN3DD4XG.mjs → chunk-GNSJP2AB.mjs} +1 -1
- package/dist/{chunk-QN3DD4XG.mjs.map → chunk-GNSJP2AB.mjs.map} +1 -1
- package/dist/{chunk-LIXL7PEP.mjs → chunk-JBDGK6X4.mjs} +1 -1
- package/dist/{chunk-LIXL7PEP.mjs.map → chunk-JBDGK6X4.mjs.map} +1 -1
- package/dist/{chunk-6Z2YFKXQ.mjs → chunk-KLJRZJOR.mjs} +1 -1
- package/dist/{chunk-6Z2YFKXQ.mjs.map → chunk-KLJRZJOR.mjs.map} +1 -1
- package/dist/{chunk-JD42XAYW.mjs → chunk-LCYPY5SA.mjs} +2 -2
- package/dist/{chunk-JD42XAYW.mjs.map → chunk-LCYPY5SA.mjs.map} +1 -1
- package/dist/{chunk-S3ZF7ZPG.mjs → chunk-LVB7BYUY.mjs} +4 -4
- package/dist/{chunk-S3ZF7ZPG.mjs.map → chunk-LVB7BYUY.mjs.map} +1 -1
- package/dist/{chunk-HK5OJANS.mjs → chunk-LVWX5B43.mjs} +1 -1
- package/dist/{chunk-HK5OJANS.mjs.map → chunk-LVWX5B43.mjs.map} +1 -1
- package/dist/{chunk-V6LXSPMF.mjs → chunk-LWXZFXY5.mjs} +1 -1
- package/dist/{chunk-V6LXSPMF.mjs.map → chunk-LWXZFXY5.mjs.map} +1 -1
- package/dist/{chunk-SORNYLIU.mjs → chunk-M7UI5ETO.mjs} +1 -1
- package/dist/{chunk-SORNYLIU.mjs.map → chunk-M7UI5ETO.mjs.map} +1 -1
- package/dist/{chunk-4RRRH7OY.mjs → chunk-ME352XO7.mjs} +1 -1
- package/dist/{chunk-4RRRH7OY.mjs.map → chunk-ME352XO7.mjs.map} +1 -1
- package/dist/{chunk-IFCX35BI.mjs → chunk-NTLX2MPV.mjs} +1 -1
- package/dist/{chunk-IFCX35BI.mjs.map → chunk-NTLX2MPV.mjs.map} +1 -1
- package/dist/{chunk-DVRGUUQG.mjs → chunk-NXPEUTDI.mjs} +1 -1
- package/dist/{chunk-DVRGUUQG.mjs.map → chunk-NXPEUTDI.mjs.map} +1 -1
- package/dist/{chunk-EXU45QAF.mjs → chunk-Q75KEFW5.mjs} +1 -1
- package/dist/{chunk-EXU45QAF.mjs.map → chunk-Q75KEFW5.mjs.map} +1 -1
- package/dist/{chunk-C4IZ7TGA.mjs → chunk-T5FDOBCA.mjs} +1 -1
- package/dist/chunk-T5FDOBCA.mjs.map +1 -0
- package/dist/{chunk-3PFYAKOD.mjs → chunk-VNMVP3DL.mjs} +1 -1
- package/dist/{chunk-3PFYAKOD.mjs.map → chunk-VNMVP3DL.mjs.map} +1 -1
- package/dist/{chunk-L3C6TG2V.mjs → chunk-XDKEPIUV.mjs} +1 -1
- package/dist/{chunk-L3C6TG2V.mjs.map → chunk-XDKEPIUV.mjs.map} +1 -1
- package/dist/{chunk-5IY7KVTH.mjs → chunk-XFCW7XJ4.mjs} +1 -1
- package/dist/{chunk-5IY7KVTH.mjs.map → chunk-XFCW7XJ4.mjs.map} +1 -1
- package/dist/function/index.mjs +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -42
- package/dist/math/index.mjs +3 -3
- package/package.json +1 -1
- package/dist/chunk-C4IZ7TGA.mjs.map +0 -1
- package/dist/chunk-KPG3XQEN.mjs.map +0 -1
- package/dist/chunk-L25VRQ54.mjs.map +0 -1
package/dist/array/index.mjs
CHANGED
|
@@ -1,94 +1,94 @@
|
|
|
1
1
|
import "../chunk-EJGAXTF7.mjs";
|
|
2
2
|
import {
|
|
3
3
|
uniqBy
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-LCYPY5SA.mjs";
|
|
5
5
|
import {
|
|
6
6
|
xor
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-62EFHAYX.mjs";
|
|
8
8
|
import {
|
|
9
9
|
xorBy
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-EW3RT4QW.mjs";
|
|
11
11
|
import {
|
|
12
12
|
xorWith
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-LVB7BYUY.mjs";
|
|
14
14
|
import {
|
|
15
15
|
zip
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-DD73BULA.mjs";
|
|
17
17
|
import {
|
|
18
18
|
zipWith
|
|
19
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-T5FDOBCA.mjs";
|
|
20
20
|
import {
|
|
21
21
|
shuffle
|
|
22
|
-
} from "../chunk-
|
|
22
|
+
} from "../chunk-DPLJQQFX.mjs";
|
|
23
23
|
import {
|
|
24
24
|
take
|
|
25
|
-
} from "../chunk-
|
|
25
|
+
} from "../chunk-ME352XO7.mjs";
|
|
26
26
|
import {
|
|
27
27
|
takeRight
|
|
28
|
-
} from "../chunk-
|
|
28
|
+
} from "../chunk-XDKEPIUV.mjs";
|
|
29
29
|
import {
|
|
30
30
|
takeRightWhile
|
|
31
|
-
} from "../chunk-
|
|
31
|
+
} from "../chunk-NTLX2MPV.mjs";
|
|
32
32
|
import {
|
|
33
33
|
takeWhile
|
|
34
|
-
} from "../chunk-
|
|
34
|
+
} from "../chunk-2IXFGSUA.mjs";
|
|
35
35
|
import {
|
|
36
36
|
union
|
|
37
|
-
} from "../chunk-
|
|
37
|
+
} from "../chunk-DAJZ3JCI.mjs";
|
|
38
38
|
import {
|
|
39
39
|
uniq
|
|
40
|
-
} from "../chunk-
|
|
40
|
+
} from "../chunk-XFCW7XJ4.mjs";
|
|
41
41
|
import {
|
|
42
42
|
unionBy
|
|
43
|
-
} from "../chunk-
|
|
43
|
+
} from "../chunk-JBDGK6X4.mjs";
|
|
44
44
|
import {
|
|
45
45
|
unionWith
|
|
46
|
-
} from "../chunk-
|
|
46
|
+
} from "../chunk-5P2QE2VI.mjs";
|
|
47
47
|
import {
|
|
48
48
|
uniqWith
|
|
49
|
-
} from "../chunk-
|
|
49
|
+
} from "../chunk-NXPEUTDI.mjs";
|
|
50
50
|
import {
|
|
51
51
|
groupBy
|
|
52
|
-
} from "../chunk-
|
|
52
|
+
} from "../chunk-LWXZFXY5.mjs";
|
|
53
53
|
import {
|
|
54
54
|
intersection
|
|
55
|
-
} from "../chunk-
|
|
55
|
+
} from "../chunk-7XTQCUMW.mjs";
|
|
56
56
|
import {
|
|
57
57
|
intersectionBy
|
|
58
|
-
} from "../chunk-
|
|
58
|
+
} from "../chunk-GNSJP2AB.mjs";
|
|
59
59
|
import {
|
|
60
60
|
intersectionWith
|
|
61
|
-
} from "../chunk-
|
|
61
|
+
} from "../chunk-KLJRZJOR.mjs";
|
|
62
62
|
import {
|
|
63
63
|
partition
|
|
64
64
|
} from "../chunk-5L2V7WD3.mjs";
|
|
65
65
|
import {
|
|
66
66
|
sample
|
|
67
|
-
} from "../chunk-
|
|
67
|
+
} from "../chunk-DOOIIHT3.mjs";
|
|
68
68
|
import {
|
|
69
69
|
chunk
|
|
70
|
-
} from "../chunk-
|
|
70
|
+
} from "../chunk-E6C5EZQA.mjs";
|
|
71
71
|
import {
|
|
72
72
|
difference
|
|
73
|
-
} from "../chunk-
|
|
73
|
+
} from "../chunk-M7UI5ETO.mjs";
|
|
74
74
|
import {
|
|
75
75
|
differenceBy
|
|
76
|
-
} from "../chunk-
|
|
76
|
+
} from "../chunk-LVWX5B43.mjs";
|
|
77
77
|
import {
|
|
78
78
|
differenceWith
|
|
79
|
-
} from "../chunk-
|
|
79
|
+
} from "../chunk-FQ4K36VD.mjs";
|
|
80
80
|
import {
|
|
81
81
|
drop
|
|
82
|
-
} from "../chunk-
|
|
82
|
+
} from "../chunk-ACFP3XMB.mjs";
|
|
83
83
|
import {
|
|
84
84
|
dropRight
|
|
85
|
-
} from "../chunk-
|
|
85
|
+
} from "../chunk-Q75KEFW5.mjs";
|
|
86
86
|
import {
|
|
87
87
|
dropRightWhile
|
|
88
|
-
} from "../chunk-
|
|
88
|
+
} from "../chunk-E7BJSLIX.mjs";
|
|
89
89
|
import {
|
|
90
90
|
dropWhile
|
|
91
|
-
} from "../chunk-
|
|
91
|
+
} from "../chunk-VNMVP3DL.mjs";
|
|
92
92
|
import "../chunk-2MM5EJJX.mjs";
|
|
93
93
|
export {
|
|
94
94
|
chunk,
|
|
@@ -15,6 +15,6 @@
|
|
|
15
15
|
* const result = intersection(array1, array2);
|
|
16
16
|
* // result will be [3, 4, 5] since these elements are in both arrays.
|
|
17
17
|
*/
|
|
18
|
-
declare function intersection<T>(firstArr: T[], secondArr: T[]): T[];
|
|
18
|
+
declare function intersection<T>(firstArr: readonly T[], secondArr: readonly T[]): T[];
|
|
19
19
|
|
|
20
20
|
export { intersection };
|
|
@@ -15,6 +15,6 @@
|
|
|
15
15
|
* const result = intersection(array1, array2);
|
|
16
16
|
* // result will be [3, 4, 5] since these elements are in both arrays.
|
|
17
17
|
*/
|
|
18
|
-
declare function intersection<T>(firstArr: T[], secondArr: T[]): T[];
|
|
18
|
+
declare function intersection<T>(firstArr: readonly T[], secondArr: readonly T[]): T[];
|
|
19
19
|
|
|
20
20
|
export { intersection };
|
|
@@ -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: T[], secondArr: T[]): T[] {\n return firstArr.filter(item => {\n return secondArr.includes(item);\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBO,SAAS,aAAgB,
|
|
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 return firstArr.filter(item => {\n return secondArr.includes(item);\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBO,SAAS,aAAgB,UAAwB,WAA8B;AACpF,SAAO,SAAS,OAAO,UAAQ;AAC7B,WAAO,UAAU,SAAS,IAAI;AAAA,EAChC,CAAC;AACH;","names":[]}
|
|
@@ -18,6 +18,6 @@
|
|
|
18
18
|
* const result = intersectionBy(array1, array2, mapper);
|
|
19
19
|
* // result will be [{ id: 2 }] since only this element has a matching id in both arrays.
|
|
20
20
|
*/
|
|
21
|
-
declare function intersectionBy<T, U>(firstArr: T[], secondArr: T[], mapper: (item: T) => U): T[];
|
|
21
|
+
declare function intersectionBy<T, U>(firstArr: readonly T[], secondArr: readonly T[], mapper: (item: T) => U): T[];
|
|
22
22
|
|
|
23
23
|
export { intersectionBy };
|
|
@@ -18,6 +18,6 @@
|
|
|
18
18
|
* const result = intersectionBy(array1, array2, mapper);
|
|
19
19
|
* // result will be [{ id: 2 }] since only this element has a matching id in both arrays.
|
|
20
20
|
*/
|
|
21
|
-
declare function intersectionBy<T, U>(firstArr: T[], secondArr: T[], mapper: (item: T) => U): T[];
|
|
21
|
+
declare function intersectionBy<T, U>(firstArr: readonly T[], secondArr: readonly T[], mapper: (item: T) => U): T[];
|
|
22
22
|
|
|
23
23
|
export { intersectionBy };
|
|
@@ -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: T[], secondArr: 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;AAoBO,SAAS,eAAqB,
|
|
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;AAoBO,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":[]}
|
|
@@ -19,6 +19,6 @@
|
|
|
19
19
|
* const result = intersectionWith(array1, array2, areItemsEqual);
|
|
20
20
|
* // result will be [{ id: 2 }] since this element has a matching id in both arrays.
|
|
21
21
|
*/
|
|
22
|
-
declare function intersectionWith<T>(firstArr: T[], secondArr: T[], areItemsEqual: (x: T, y: T) => boolean): T[];
|
|
22
|
+
declare function intersectionWith<T>(firstArr: readonly T[], secondArr: readonly T[], areItemsEqual: (x: T, y: T) => boolean): T[];
|
|
23
23
|
|
|
24
24
|
export { intersectionWith };
|
|
@@ -19,6 +19,6 @@
|
|
|
19
19
|
* const result = intersectionWith(array1, array2, areItemsEqual);
|
|
20
20
|
* // result will be [{ id: 2 }] since this element has a matching id in both arrays.
|
|
21
21
|
*/
|
|
22
|
-
declare function intersectionWith<T>(firstArr: T[], secondArr: T[], areItemsEqual: (x: T, y: T) => boolean): T[];
|
|
22
|
+
declare function intersectionWith<T>(firstArr: readonly T[], secondArr: readonly T[], areItemsEqual: (x: T, y: T) => boolean): T[];
|
|
23
23
|
|
|
24
24
|
export { intersectionWith };
|
|
@@ -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>(firstArr: T[], secondArr: T[], areItemsEqual: (x: T, y: T) => boolean): 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;AAqBO,SAAS,iBAAoB,
|
|
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>(firstArr: readonly T[], secondArr: readonly T[], areItemsEqual: (x: T, y: T) => boolean): 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;AAqBO,SAAS,iBAAoB,UAAwB,WAAyB,eAA6C;AAChI,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/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: T[]): T {\n const randomIndex = Math.floor(Math.random() * arr.length);\n return arr[randomIndex];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,OAAU,
|
|
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;AAaO,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
package/dist/array/shuffle.d.mts
CHANGED
|
@@ -11,6 +11,6 @@
|
|
|
11
11
|
* const shuffledArray = shuffle(array);
|
|
12
12
|
* // shuffledArray will be a new array with elements of array in random order, e.g., [3, 1, 4, 5, 2]
|
|
13
13
|
*/
|
|
14
|
-
declare function shuffle<T>(arr: T[]): T[];
|
|
14
|
+
declare function shuffle<T>(arr: readonly T[]): T[];
|
|
15
15
|
|
|
16
16
|
export { shuffle };
|
package/dist/array/shuffle.d.ts
CHANGED
|
@@ -11,6 +11,6 @@
|
|
|
11
11
|
* const shuffledArray = shuffle(array);
|
|
12
12
|
* // shuffledArray will be a new array with elements of array in random order, e.g., [3, 1, 4, 5, 2]
|
|
13
13
|
*/
|
|
14
|
-
declare function shuffle<T>(arr: T[]): T[];
|
|
14
|
+
declare function shuffle<T>(arr: readonly T[]): T[];
|
|
15
15
|
|
|
16
16
|
export { shuffle };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/shuffle.ts"],"sourcesContent":["/**\n * Randomizes the order of elements in an array using the Fisher-Yates algorithm.\n *\n * This function takes an array and returns a new array with its elements shuffled in a random order.\n *\n * @param {T[]} arr - The array to shuffle.\n * @returns {T[]} A new array with its elements shuffled in random order.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const shuffledArray = shuffle(array);\n * // shuffledArray will be a new array with elements of array in random order, e.g., [3, 1, 4, 5, 2]\n */\nexport function shuffle<T>(arr: T[]): T[] {\n const result = arr.slice();\n\n /**\n * https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm\n */\n for (let i = result.length - 1; i >= 1; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [result[i], result[j]] = [result[j], result[i]];\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,QAAW,
|
|
1
|
+
{"version":3,"sources":["../../src/array/shuffle.ts"],"sourcesContent":["/**\n * Randomizes the order of elements in an array using the Fisher-Yates algorithm.\n *\n * This function takes an array and returns a new array with its elements shuffled in a random order.\n *\n * @param {T[]} arr - The array to shuffle.\n * @returns {T[]} A new array with its elements shuffled in random order.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const shuffledArray = shuffle(array);\n * // shuffledArray will be a new array with elements of array in random order, e.g., [3, 1, 4, 5, 2]\n */\nexport function shuffle<T>(arr: readonly T[]): T[] {\n const result = arr.slice();\n\n /**\n * https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm\n */\n for (let i = result.length - 1; i >= 1; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [result[i], result[j]] = [result[j], result[i]];\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,QAAW,KAAwB;AACjD,QAAM,SAAS,IAAI,MAAM;AAKzB,WAAS,IAAI,OAAO,SAAS,GAAG,KAAK,GAAG,KAAK;AAC3C,UAAM,IAAI,KAAK,MAAM,KAAK,OAAO,KAAK,IAAI,EAAE;AAC5C,KAAC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC;AAAA,EAChD;AAEA,SAAO;AACT;","names":[]}
|
package/dist/array/shuffle.mjs
CHANGED
package/dist/array/take.d.mts
CHANGED
package/dist/array/take.d.ts
CHANGED
package/dist/array/take.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/take.ts"],"sourcesContent":["/**\n * Returns a new array containing the first `count` elements from the input array `arr`.\n * If `count` is greater than the length of `arr`, the entire array is returned.\n *\n * @template T - Type of elements in the input array.\n *\n * @param {T[]} arr - The array to take elements from.\n * @param {number} count - The number of elements to take.\n * @returns {T[]} A new array containing the first `count` elements from `arr`.\n *\n * @example\n * // Returns [1, 2, 3]\n * take([1, 2, 3, 4, 5], 3);\n *\n * @example\n * // Returns ['a', 'b']\n * take(['a', 'b', 'c'], 2);\n *\n * @example\n * // Returns [1, 2, 3]\n * take([1, 2, 3], 5);\n */\nexport function take<T>(arr: T[], count: number): T[] {\n return arr.slice(0, count);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBO,SAAS,KAAQ,
|
|
1
|
+
{"version":3,"sources":["../../src/array/take.ts"],"sourcesContent":["/**\n * Returns a new array containing the first `count` elements from the input array `arr`.\n * If `count` is greater than the length of `arr`, the entire array is returned.\n *\n * @template T - Type of elements in the input array.\n *\n * @param {T[]} arr - The array to take elements from.\n * @param {number} count - The number of elements to take.\n * @returns {T[]} A new array containing the first `count` elements from `arr`.\n *\n * @example\n * // Returns [1, 2, 3]\n * take([1, 2, 3, 4, 5], 3);\n *\n * @example\n * // Returns ['a', 'b']\n * take(['a', 'b', 'c'], 2);\n *\n * @example\n * // Returns [1, 2, 3]\n * take([1, 2, 3], 5);\n */\nexport function take<T>(arr: readonly T[], count: number): T[] {\n return arr.slice(0, count);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBO,SAAS,KAAQ,KAAmB,OAAoB;AAC7D,SAAO,IAAI,MAAM,GAAG,KAAK;AAC3B;","names":[]}
|
package/dist/array/take.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/takeRight.ts"],"sourcesContent":["/**\n * Returns a new array containing the last `count` elements from the input array `arr`.\n * If `count` is greater than the length of `arr`, the entire array is returned.\n *\n * @param {T[]} arr - The array to take elements from.\n * @param {number} count - The number of elements to take.\n * @returns {T[]} A new array containing the last `count` elements from `arr`.\n *\n * @example\n * // Returns [4, 5]\n * takeRight([1, 2, 3, 4, 5], 2);\n *\n * @example\n * // Returns ['b', 'c']\n * takeRight(['a', 'b', 'c'], 2);\n *\n * @example\n * // Returns [1, 2, 3]\n * takeRight([1, 2, 3], 5);\n */\nexport function takeRight<T>(arr: T[], count: number): T[] {\n if (count === 0) {\n return [];\n }\n\n return arr.slice(-count);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBO,SAAS,UAAa,
|
|
1
|
+
{"version":3,"sources":["../../src/array/takeRight.ts"],"sourcesContent":["/**\n * Returns a new array containing the last `count` elements from the input array `arr`.\n * If `count` is greater than the length of `arr`, the entire array is returned.\n *\n * @param {T[]} arr - The array to take elements from.\n * @param {number} count - The number of elements to take.\n * @returns {T[]} A new array containing the last `count` elements from `arr`.\n *\n * @example\n * // Returns [4, 5]\n * takeRight([1, 2, 3, 4, 5], 2);\n *\n * @example\n * // Returns ['b', 'c']\n * takeRight(['a', 'b', 'c'], 2);\n *\n * @example\n * // Returns [1, 2, 3]\n * takeRight([1, 2, 3], 5);\n */\nexport function takeRight<T>(arr: readonly T[], count: number): T[] {\n if (count === 0) {\n return [];\n }\n\n return arr.slice(-count);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBO,SAAS,UAAa,KAAmB,OAAoB;AAClE,MAAI,UAAU,GAAG;AACf,WAAO,CAAC;AAAA,EACV;AAEA,SAAO,IAAI,MAAM,CAAC,KAAK;AACzB;","names":[]}
|
package/dist/array/takeRight.mjs
CHANGED
|
@@ -15,6 +15,6 @@
|
|
|
15
15
|
* // Returns []
|
|
16
16
|
* takeRightWhile([1, 2, 3], n => n > 3);
|
|
17
17
|
*/
|
|
18
|
-
declare function takeRightWhile<T>(arr: T[], shouldContinueTaking: (item: T) => boolean): T[];
|
|
18
|
+
declare function takeRightWhile<T>(arr: readonly T[], shouldContinueTaking: (item: T) => boolean): T[];
|
|
19
19
|
|
|
20
20
|
export { takeRightWhile };
|
|
@@ -15,6 +15,6 @@
|
|
|
15
15
|
* // Returns []
|
|
16
16
|
* takeRightWhile([1, 2, 3], n => n > 3);
|
|
17
17
|
*/
|
|
18
|
-
declare function takeRightWhile<T>(arr: T[], shouldContinueTaking: (item: T) => boolean): T[];
|
|
18
|
+
declare function takeRightWhile<T>(arr: readonly T[], shouldContinueTaking: (item: T) => boolean): T[];
|
|
19
19
|
|
|
20
20
|
export { takeRightWhile };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/takeRightWhile.ts"],"sourcesContent":["/**\n * Takes elements from the end of the array while the predicate function returns `true`.\n *\n * @template T - Type of elements in the input array.\n *\n * @param {T[]} arr - The array to take elements from.\n * @param {function(T): boolean} shouldContinueTaking - The function invoked per element.\n * @returns {T[]} A new array containing the elements taken from the end while the predicate returns `true`.\n *\n * @example\n * // Returns [3, 2, 1]\n * takeRightWhile([5, 4, 3, 2, 1], n => n < 4);\n *\n * @example\n * // Returns []\n * takeRightWhile([1, 2, 3], n => n > 3);\n */\nexport function takeRightWhile<T>(arr: T[], shouldContinueTaking: (item: T) => boolean): T[] {\n for (let i = arr.length - 1; i >= 0; i--) {\n if (!shouldContinueTaking(arr[i])) {\n return arr.slice(i + 1);\n }\n }\n\n return arr.slice();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBO,SAAS,eAAkB,
|
|
1
|
+
{"version":3,"sources":["../../src/array/takeRightWhile.ts"],"sourcesContent":["/**\n * Takes elements from the end of the array while the predicate function returns `true`.\n *\n * @template T - Type of elements in the input array.\n *\n * @param {T[]} arr - The array to take elements from.\n * @param {function(T): boolean} shouldContinueTaking - The function invoked per element.\n * @returns {T[]} A new array containing the elements taken from the end while the predicate returns `true`.\n *\n * @example\n * // Returns [3, 2, 1]\n * takeRightWhile([5, 4, 3, 2, 1], n => n < 4);\n *\n * @example\n * // Returns []\n * takeRightWhile([1, 2, 3], n => n > 3);\n */\nexport function takeRightWhile<T>(arr: readonly T[], shouldContinueTaking: (item: T) => boolean): T[] {\n for (let i = arr.length - 1; i >= 0; i--) {\n if (!shouldContinueTaking(arr[i])) {\n return arr.slice(i + 1);\n }\n }\n\n return arr.slice();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBO,SAAS,eAAkB,KAAmB,sBAAiD;AACpG,WAAS,IAAI,IAAI,SAAS,GAAG,KAAK,GAAG,KAAK;AACxC,QAAI,CAAC,qBAAqB,IAAI,CAAC,CAAC,GAAG;AACjC,aAAO,IAAI,MAAM,IAAI,CAAC;AAAA,IACxB;AAAA,EACF;AAEA,SAAO,IAAI,MAAM;AACnB;","names":[]}
|
|
@@ -16,6 +16,6 @@
|
|
|
16
16
|
* // Returns []
|
|
17
17
|
* takeWhile([1, 2, 3, 4], x => x > 3);
|
|
18
18
|
*/
|
|
19
|
-
declare function takeWhile<T>(arr: T[], shouldContinueTaking: (element: T) => boolean): T[];
|
|
19
|
+
declare function takeWhile<T>(arr: readonly T[], shouldContinueTaking: (element: T) => boolean): T[];
|
|
20
20
|
|
|
21
21
|
export { takeWhile };
|
|
@@ -16,6 +16,6 @@
|
|
|
16
16
|
* // Returns []
|
|
17
17
|
* takeWhile([1, 2, 3, 4], x => x > 3);
|
|
18
18
|
*/
|
|
19
|
-
declare function takeWhile<T>(arr: T[], shouldContinueTaking: (element: T) => boolean): T[];
|
|
19
|
+
declare function takeWhile<T>(arr: readonly T[], shouldContinueTaking: (element: T) => boolean): T[];
|
|
20
20
|
|
|
21
21
|
export { takeWhile };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/takeWhile.ts"],"sourcesContent":["/**\n * Returns a new array containing the leading elements of the provided array\n * that satisfy the provided predicate function. It stops taking elements as soon\n * as an element does not satisfy the predicate.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to process.\n * @param {(element: T) => boolean} shouldContinueTaking - The predicate function that is called with each element. Elements are included in the result as long as this function returns true.\n * @returns {T[]} A new array containing the leading elements that satisfy the predicate.\n *\n * @example\n * // Returns [1, 2]\n * takeWhile([1, 2, 3, 4], x => x < 3);\n *\n * @example\n * // Returns []\n * takeWhile([1, 2, 3, 4], x => x > 3);\n */\nexport function takeWhile<T>(arr: T[], shouldContinueTaking: (element: T) => boolean): T[] {\n const result: T[] = [];\n\n for (const item of arr) {\n if (!shouldContinueTaking(item)) {\n break;\n }\n\n result.push(item);\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBO,SAAS,UAAa,
|
|
1
|
+
{"version":3,"sources":["../../src/array/takeWhile.ts"],"sourcesContent":["/**\n * Returns a new array containing the leading elements of the provided array\n * that satisfy the provided predicate function. It stops taking elements as soon\n * as an element does not satisfy the predicate.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to process.\n * @param {(element: T) => boolean} shouldContinueTaking - The predicate function that is called with each element. Elements are included in the result as long as this function returns true.\n * @returns {T[]} A new array containing the leading elements that satisfy the predicate.\n *\n * @example\n * // Returns [1, 2]\n * takeWhile([1, 2, 3, 4], x => x < 3);\n *\n * @example\n * // Returns []\n * takeWhile([1, 2, 3, 4], x => x > 3);\n */\nexport function takeWhile<T>(arr: readonly T[], shouldContinueTaking: (element: T) => boolean): T[] {\n const result: T[] = [];\n\n for (const item of arr) {\n if (!shouldContinueTaking(item)) {\n break;\n }\n\n result.push(item);\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBO,SAAS,UAAa,KAAmB,sBAAoD;AAClG,QAAM,SAAc,CAAC;AAErB,aAAW,QAAQ,KAAK;AACtB,QAAI,CAAC,qBAAqB,IAAI,GAAG;AAC/B;AAAA,IACF;AAEA,WAAO,KAAK,IAAI;AAAA,EAClB;AAEA,SAAO;AACT;","names":[]}
|
package/dist/array/takeWhile.mjs
CHANGED
package/dist/array/union.d.mts
CHANGED
package/dist/array/union.d.ts
CHANGED
package/dist/array/union.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/union.ts","../../src/array/uniq.ts"],"sourcesContent":["import { uniq } from './uniq';\n\n/**\n * Creates an array of unique values from all given arrays.\n *\n * This function takes two arrays, merges them into a single array, and returns a new array\n * containing only the unique values from the merged array.\n *\n * @param {T[]} arr1 - The first array to merge and filter for unique values.\n * @param {T[]} arr2 - The second array to merge and filter for unique values.\n * @returns {T[]} A new array of unique values.\n *\n * @example\n * const array1 = [1, 2, 3];\n * const array2 = [3, 4, 5];\n * const result = union(array1, array2);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function union<T>(arr1: T[], arr2: T[]): T[] {\n return uniq(arr1.concat(arr2));\n}\n","/**\n * Creates a duplicate-free version of an array.\n *\n * This function takes an array and returns a new array containing only the unique values\n * from the original array, preserving the order of first occurrence.\n *\n * @param {T[]} arr - The array to process.\n * @returns {T[]} A new array with only unique values from the original array.\n *\n * @example\n * const array = [1, 2, 2, 3, 4, 4, 5];\n * const result = uniq(array);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function uniq<T>(arr: T[]): T[] {\n return Array.from(new Set(arr));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACcO,SAAS,KAAQ,
|
|
1
|
+
{"version":3,"sources":["../../src/array/union.ts","../../src/array/uniq.ts"],"sourcesContent":["import { uniq } from './uniq';\n\n/**\n * Creates an array of unique values from all given arrays.\n *\n * This function takes two arrays, merges them into a single array, and returns a new array\n * containing only the unique values from the merged array.\n *\n * @param {T[]} arr1 - The first array to merge and filter for unique values.\n * @param {T[]} arr2 - The second array to merge and filter for unique values.\n * @returns {T[]} A new array of unique values.\n *\n * @example\n * const array1 = [1, 2, 3];\n * const array2 = [3, 4, 5];\n * const result = union(array1, array2);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function union<T>(arr1: readonly T[], arr2: readonly T[]): T[] {\n return uniq(arr1.concat(arr2));\n}\n","/**\n * Creates a duplicate-free version of an array.\n *\n * This function takes an array and returns a new array containing only the unique values\n * from the original array, preserving the order of first occurrence.\n *\n * @param {T[]} arr - The array to process.\n * @returns {T[]} A new array with only unique values from the original array.\n *\n * @example\n * const array = [1, 2, 2, 3, 4, 4, 5];\n * const result = uniq(array);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function uniq<T>(arr: readonly T[]): T[] {\n return Array.from(new Set(arr));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACcO,SAAS,KAAQ,KAAwB;AAC9C,SAAO,MAAM,KAAK,IAAI,IAAI,GAAG,CAAC;AAChC;;;ADEO,SAAS,MAAS,MAAoB,MAAyB;AACpE,SAAO,KAAK,KAAK,OAAO,IAAI,CAAC;AAC/B;","names":[]}
|
package/dist/array/union.mjs
CHANGED
package/dist/array/unionBy.d.mts
CHANGED
|
@@ -18,6 +18,6 @@
|
|
|
18
18
|
* unionBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);
|
|
19
19
|
* // Returns [{ id: 1 }, { id: 2 }, { id: 3 }]
|
|
20
20
|
*/
|
|
21
|
-
declare function unionBy<T, U>(arr1: T[], arr2: T[], mapper: (item: T) => U): T[];
|
|
21
|
+
declare function unionBy<T, U>(arr1: readonly T[], arr2: readonly T[], mapper: (item: T) => U): T[];
|
|
22
22
|
|
|
23
23
|
export { unionBy };
|
package/dist/array/unionBy.d.ts
CHANGED
|
@@ -18,6 +18,6 @@
|
|
|
18
18
|
* unionBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);
|
|
19
19
|
* // Returns [{ id: 1 }, { id: 2 }, { id: 3 }]
|
|
20
20
|
*/
|
|
21
|
-
declare function unionBy<T, U>(arr1: T[], arr2: T[], mapper: (item: T) => U): T[];
|
|
21
|
+
declare function unionBy<T, U>(arr1: readonly T[], arr2: readonly T[], mapper: (item: T) => U): T[];
|
|
22
22
|
|
|
23
23
|
export { unionBy };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/unionBy.ts"],"sourcesContent":["/**\n * Creates an array of unique values, in order, from all given arrays using a provided mapping function to determine equality.\n *\n * @param {T[]} arr1 - The first array.\n * @param {T[]} arr2 - The second array.\n * @param {(item: T) => U} mapper - The function to map array elements to comparison values.\n * @returns {T[]} A new array containing the union of unique elements from `arr1` and `arr2`, based on the values returned by the mapping function.\n *\n * @example\n * // Custom mapping function for numbers (modulo comparison)\n * const moduloMapper = (x) => x % 3;\n * unionBy([1, 2, 3], [4, 5, 6], moduloMapper);\n * // Returns [1, 2, 3]\n *\n * @example\n * // Custom mapping function for objects with an 'id' property\n * const idMapper = (obj) => obj.id;\n * unionBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);\n * // Returns [{ id: 1 }, { id: 2 }, { id: 3 }]\n */\nexport function unionBy<T, U>(arr1: T[], arr2: T[], mapper: (item: T) => U): T[] {\n const map = new Map<U, T>();\n\n for (const item of [...arr1, ...arr2]) {\n const key = mapper(item);\n if (!map.has(key)) {\n map.set(key, item);\n }\n }\n\n return [...map.values()];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBO,SAAS,QAAc,
|
|
1
|
+
{"version":3,"sources":["../../src/array/unionBy.ts"],"sourcesContent":["/**\n * Creates an array of unique values, in order, from all given arrays using a provided mapping function to determine equality.\n *\n * @param {T[]} arr1 - The first array.\n * @param {T[]} arr2 - The second array.\n * @param {(item: T) => U} mapper - The function to map array elements to comparison values.\n * @returns {T[]} A new array containing the union of unique elements from `arr1` and `arr2`, based on the values returned by the mapping function.\n *\n * @example\n * // Custom mapping function for numbers (modulo comparison)\n * const moduloMapper = (x) => x % 3;\n * unionBy([1, 2, 3], [4, 5, 6], moduloMapper);\n * // Returns [1, 2, 3]\n *\n * @example\n * // Custom mapping function for objects with an 'id' property\n * const idMapper = (obj) => obj.id;\n * unionBy([{ id: 1 }, { id: 2 }], [{ id: 2 }, { id: 3 }], idMapper);\n * // Returns [{ id: 1 }, { id: 2 }, { id: 3 }]\n */\nexport function unionBy<T, U>(arr1: readonly T[], arr2: readonly T[], mapper: (item: T) => U): T[] {\n const map = new Map<U, T>();\n\n for (const item of [...arr1, ...arr2]) {\n const key = mapper(item);\n if (!map.has(key)) {\n map.set(key, item);\n }\n }\n\n return [...map.values()];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBO,SAAS,QAAc,MAAoB,MAAoB,QAA6B;AACjG,QAAM,MAAM,oBAAI,IAAU;AAE1B,aAAW,QAAQ,CAAC,GAAG,MAAM,GAAG,IAAI,GAAG;AACrC,UAAM,MAAM,OAAO,IAAI;AACvB,QAAI,CAAC,IAAI,IAAI,GAAG,GAAG;AACjB,UAAI,IAAI,KAAK,IAAI;AAAA,IACnB;AAAA,EACF;AAEA,SAAO,CAAC,GAAG,IAAI,OAAO,CAAC;AACzB;","names":[]}
|
package/dist/array/unionBy.mjs
CHANGED
|
@@ -17,6 +17,6 @@
|
|
|
17
17
|
* const result = unionWith(array1, array2, areItemsEqual);
|
|
18
18
|
* // result will be [{ id: 1 }, { id: 2 }, { id: 3 }] since { id: 2 } is considered equal in both arrays
|
|
19
19
|
*/
|
|
20
|
-
declare function unionWith<T>(arr1: T[], arr2: T[], areItemsEqual: (item1: T, item2: T) => boolean): T[];
|
|
20
|
+
declare function unionWith<T>(arr1: readonly T[], arr2: readonly T[], areItemsEqual: (item1: T, item2: T) => boolean): T[];
|
|
21
21
|
|
|
22
22
|
export { unionWith };
|
|
@@ -17,6 +17,6 @@
|
|
|
17
17
|
* const result = unionWith(array1, array2, areItemsEqual);
|
|
18
18
|
* // result will be [{ id: 1 }, { id: 2 }, { id: 3 }] since { id: 2 } is considered equal in both arrays
|
|
19
19
|
*/
|
|
20
|
-
declare function unionWith<T>(arr1: T[], arr2: T[], areItemsEqual: (item1: T, item2: T) => boolean): T[];
|
|
20
|
+
declare function unionWith<T>(arr1: readonly T[], arr2: readonly T[], areItemsEqual: (item1: T, item2: T) => boolean): T[];
|
|
21
21
|
|
|
22
22
|
export { unionWith };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/unionWith.ts","../../src/array/uniqWith.ts"],"sourcesContent":["import { uniqWith } from './uniqWith';\n\n/**\n * Creates an array of unique values from two given arrays based on a custom equality function.\n *\n * This function takes two arrays and a custom equality function, merges the arrays, and returns\n * a new array containing only the unique values as determined by the custom equality function.\n *\n * @param {T[]} arr1 - The first array to merge and filter for unique values.\n * @param {T[]} arr2 - The second array to merge and filter for unique values.\n * @param {(item1: T, item2: T) => boolean} areItemsEqual - A custom function to determine if two elements are equal.\n * It takes two arguments and returns `true` if the elements are considered equal, and `false` otherwise.\n * @returns {T[]} A new array of unique values based on the custom equality function.\n *\n * @example\n * const array1 = [{ id: 1 }, { id: 2 }];\n * const array2 = [{ id: 2 }, { id: 3 }];\n * const areItemsEqual = (a, b) => a.id === b.id;\n * const result = unionWith(array1, array2, areItemsEqual);\n * // result will be [{ id: 1 }, { id: 2 }, { id: 3 }] since { id: 2 } is considered equal in both arrays\n */\nexport function unionWith<T>(arr1: T[], arr2: T[], areItemsEqual: (item1: T, item2: T) => boolean): T[] {\n return uniqWith(arr1.concat(arr2), areItemsEqual);\n}\n","/**\n * The `uniqWith` function takes an array as its first argument and a 'comparator' function as the second.\n *\n * It evaluates the elements of the array using the comparator function, and if true is returned, it considers those elements as duplicates and removes them.\n *\n * @param {T[]} arr - The array to process.\n * @param {(item1: T, item2: T) => boolean} areItemsEqual - The function used to compare the array elements.\n * @returns {T[]} A new array containing only the unique elements from the original array, based on the values returned by the comparator function.\n *\n * @example\n * ```ts\n * uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => Math.abs(a - b) < 1);\n * // [1.2, 3.2, 5.7, 7.19]\n * ```\n */\nexport function uniqWith<T>(arr: T[], areItemsEqual: (item1: T, item2: T) => boolean): T[] {\n const result: T[] = [];\n\n for (const item of arr) {\n const isUniq = result.every(v => !areItemsEqual(v, item));\n\n if (isUniq) {\n result.push(item);\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeO,SAAS,SAAY,
|
|
1
|
+
{"version":3,"sources":["../../src/array/unionWith.ts","../../src/array/uniqWith.ts"],"sourcesContent":["import { uniqWith } from './uniqWith';\n\n/**\n * Creates an array of unique values from two given arrays based on a custom equality function.\n *\n * This function takes two arrays and a custom equality function, merges the arrays, and returns\n * a new array containing only the unique values as determined by the custom equality function.\n *\n * @param {T[]} arr1 - The first array to merge and filter for unique values.\n * @param {T[]} arr2 - The second array to merge and filter for unique values.\n * @param {(item1: T, item2: T) => boolean} areItemsEqual - A custom function to determine if two elements are equal.\n * It takes two arguments and returns `true` if the elements are considered equal, and `false` otherwise.\n * @returns {T[]} A new array of unique values based on the custom equality function.\n *\n * @example\n * const array1 = [{ id: 1 }, { id: 2 }];\n * const array2 = [{ id: 2 }, { id: 3 }];\n * const areItemsEqual = (a, b) => a.id === b.id;\n * const result = unionWith(array1, array2, areItemsEqual);\n * // result will be [{ id: 1 }, { id: 2 }, { id: 3 }] since { id: 2 } is considered equal in both arrays\n */\nexport function unionWith<T>(arr1: readonly T[], arr2: readonly T[], areItemsEqual: (item1: T, item2: T) => boolean): T[] {\n return uniqWith(arr1.concat(arr2), areItemsEqual);\n}\n","/**\n * The `uniqWith` function takes an array as its first argument and a 'comparator' function as the second.\n *\n * It evaluates the elements of the array using the comparator function, and if true is returned, it considers those elements as duplicates and removes them.\n *\n * @param {T[]} arr - The array to process.\n * @param {(item1: T, item2: T) => boolean} areItemsEqual - The function used to compare the array elements.\n * @returns {T[]} A new array containing only the unique elements from the original array, based on the values returned by the comparator function.\n *\n * @example\n * ```ts\n * uniqWith([1.2, 1.5, 2.1, 3.2, 5.7, 5.3, 7.19], (a, b) => Math.abs(a - b) < 1);\n * // [1.2, 3.2, 5.7, 7.19]\n * ```\n */\nexport function uniqWith<T>(arr: readonly T[], areItemsEqual: (item1: T, item2: T) => boolean): T[] {\n const result: T[] = [];\n\n for (const item of arr) {\n const isUniq = result.every(v => !areItemsEqual(v, item));\n\n if (isUniq) {\n result.push(item);\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeO,SAAS,SAAY,KAAmB,eAAqD;AAClG,QAAM,SAAc,CAAC;AAErB,aAAW,QAAQ,KAAK;AACtB,UAAM,SAAS,OAAO,MAAM,OAAK,CAAC,cAAc,GAAG,IAAI,CAAC;AAExD,QAAI,QAAQ;AACV,aAAO,KAAK,IAAI;AAAA,IAClB;AAAA,EACF;AAEA,SAAO;AACT;;;ADNO,SAAS,UAAa,MAAoB,MAAoB,eAAqD;AACxH,SAAO,SAAS,KAAK,OAAO,IAAI,GAAG,aAAa;AAClD;","names":[]}
|
package/dist/array/unionWith.mjs
CHANGED
package/dist/array/uniq.d.mts
CHANGED
package/dist/array/uniq.d.ts
CHANGED
package/dist/array/uniq.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/array/uniq.ts"],"sourcesContent":["/**\n * Creates a duplicate-free version of an array.\n *\n * This function takes an array and returns a new array containing only the unique values\n * from the original array, preserving the order of first occurrence.\n *\n * @param {T[]} arr - The array to process.\n * @returns {T[]} A new array with only unique values from the original array.\n *\n * @example\n * const array = [1, 2, 2, 3, 4, 4, 5];\n * const result = uniq(array);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function uniq<T>(arr: T[]): T[] {\n return Array.from(new Set(arr));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAcO,SAAS,KAAQ,
|
|
1
|
+
{"version":3,"sources":["../../src/array/uniq.ts"],"sourcesContent":["/**\n * Creates a duplicate-free version of an array.\n *\n * This function takes an array and returns a new array containing only the unique values\n * from the original array, preserving the order of first occurrence.\n *\n * @param {T[]} arr - The array to process.\n * @returns {T[]} A new array with only unique values from the original array.\n *\n * @example\n * const array = [1, 2, 2, 3, 4, 4, 5];\n * const result = uniq(array);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function uniq<T>(arr: readonly T[]): T[] {\n return Array.from(new Set(arr));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAcO,SAAS,KAAQ,KAAwB;AAC9C,SAAO,MAAM,KAAK,IAAI,IAAI,GAAG,CAAC;AAChC;","names":[]}
|