es-toolkit 1.26.1 → 1.27.0-dev.876
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 +12 -0
- package/dist/_chunk/{sumBy-RVppiV.js → rangeRight-w3WrXN.js} +2 -14
- package/dist/_chunk/{toMerged-wNz52b.js → toMerged-CPY8Ug.js} +7 -1
- package/dist/_chunk/{upperFirst-BUECmK.js → upperFirst-DK_rTF.js} +23 -23
- package/dist/_chunk/{zipWith-Dkv3D1.js → zipWith-Bb2eZI.js} +19 -5
- package/dist/array/at.mjs +7 -2
- package/dist/array/index.d.mts +1 -0
- package/dist/array/index.d.ts +1 -0
- package/dist/array/index.js +2 -1
- package/dist/array/index.mjs +1 -0
- package/dist/array/isSubsetWith.d.mts +33 -0
- package/dist/array/isSubsetWith.d.ts +33 -0
- package/dist/array/isSubsetWith.mjs +7 -0
- package/dist/array/without.mjs +3 -2
- package/dist/array/zip.mjs +6 -1
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/_internal/flattenArrayLike.mjs +17 -0
- package/dist/compat/_internal/isPrototype.mjs +7 -0
- package/dist/compat/_internal/toArray.mjs +5 -0
- package/dist/compat/array/chunk.mjs +2 -1
- package/dist/compat/array/difference.mjs +2 -1
- package/dist/compat/array/differenceBy.d.mts +82 -0
- package/dist/compat/array/differenceBy.d.ts +82 -0
- package/dist/compat/array/differenceBy.mjs +20 -0
- package/dist/compat/array/drop.mjs +2 -1
- package/dist/compat/array/dropRight.mjs +2 -1
- package/dist/compat/array/dropWhile.mjs +2 -1
- package/dist/compat/array/findLastIndex.mjs +2 -1
- package/dist/compat/array/forEach.d.mts +106 -0
- package/dist/compat/array/forEach.d.ts +106 -0
- package/dist/compat/array/forEach.mjs +21 -0
- package/dist/compat/array/head.mjs +2 -1
- package/dist/compat/array/last.mjs +2 -1
- package/dist/compat/array/sample.mjs +2 -1
- package/dist/compat/array/tail.mjs +2 -1
- package/dist/compat/array/take.mjs +2 -1
- package/dist/compat/array/takeRight.mjs +2 -1
- package/dist/compat/array/union.d.mts +30 -0
- package/dist/compat/array/union.d.ts +30 -0
- package/dist/compat/array/union.mjs +11 -0
- package/dist/compat/array/uniqBy.d.mts +60 -0
- package/dist/compat/array/uniqBy.d.ts +60 -0
- package/dist/compat/array/uniqBy.mjs +25 -0
- package/dist/compat/array/unzip.d.mts +16 -0
- package/dist/compat/array/unzip.d.ts +16 -0
- package/dist/compat/array/unzip.mjs +14 -0
- package/dist/compat/array/zip.d.mts +134 -0
- package/dist/compat/array/zip.d.ts +134 -0
- package/dist/compat/array/zip.mjs +11 -0
- package/dist/compat/index.d.mts +15 -8
- package/dist/compat/index.d.ts +15 -8
- package/dist/compat/index.js +312 -104
- package/dist/compat/index.mjs +15 -8
- package/dist/compat/math/sum.d.mts +37 -0
- package/dist/compat/math/sum.d.ts +37 -0
- package/dist/compat/math/sum.mjs +7 -0
- package/dist/compat/math/sumBy.d.mts +64 -0
- package/dist/compat/math/sumBy.d.ts +64 -0
- package/dist/compat/math/sumBy.mjs +20 -0
- package/dist/compat/predicate/isEmpty.d.mts +78 -0
- package/dist/compat/predicate/isEmpty.d.ts +78 -0
- package/dist/compat/predicate/isEmpty.mjs +33 -0
- package/dist/compat/string/replace.d.mts +17 -0
- package/dist/compat/string/replace.d.ts +17 -0
- package/dist/compat/string/replace.mjs +10 -0
- package/dist/compat/string/startCase.mjs +4 -4
- package/dist/compat/util/iteratee.d.mts +44 -0
- package/dist/compat/util/iteratee.d.ts +44 -0
- package/dist/compat/util/iteratee.mjs +28 -0
- package/dist/compat/util/toPath.mjs +56 -25
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +17 -14
- package/dist/index.mjs +3 -0
- package/dist/math/index.js +19 -11
- package/dist/math/range.mjs +1 -4
- package/dist/math/rangeRight.mjs +1 -4
- package/dist/math/sumBy.mjs +5 -4
- package/dist/object/cloneDeep.mjs +1 -1
- package/dist/object/findKey.d.mts +21 -0
- package/dist/object/findKey.d.ts +21 -0
- package/dist/object/findKey.mjs +6 -0
- package/dist/object/index.d.mts +1 -0
- package/dist/object/index.d.ts +1 -0
- package/dist/object/index.js +2 -1
- package/dist/object/index.mjs +1 -0
- package/dist/object/mapKeys.d.mts +4 -5
- package/dist/object/mapKeys.d.ts +4 -5
- package/dist/object/mergeWith.d.mts +1 -1
- package/dist/object/mergeWith.d.ts +1 -1
- package/dist/object/toMerged.d.mts +1 -1
- package/dist/object/toMerged.d.ts +1 -1
- package/dist/string/camelCase.mjs +4 -4
- package/dist/string/constantCase.mjs +3 -3
- package/dist/string/index.d.mts +1 -0
- package/dist/string/index.d.ts +1 -0
- package/dist/string/index.js +3 -2
- package/dist/string/index.mjs +1 -0
- package/dist/string/kebabCase.mjs +3 -3
- package/dist/string/lowerCase.mjs +3 -3
- package/dist/string/pascalCase.mjs +3 -3
- package/dist/string/snakeCase.mjs +3 -3
- package/dist/string/startCase.mjs +4 -4
- package/dist/string/upperCase.mjs +5 -5
- package/dist/string/words.d.mts +20 -0
- package/dist/string/words.d.ts +20 -0
- package/dist/string/{_internal/getWords.mjs → words.mjs} +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# es-toolkit Changelog
|
|
2
2
|
|
|
3
|
+
## Version v1.27.0
|
|
4
|
+
|
|
5
|
+
Released on November 10th, 2024.
|
|
6
|
+
|
|
7
|
+
- Added support for [findKey](https://es-toolkit.slash.page/reference/object/findKey.html) and [isSubsetWith](https://es-toolkit.slash.page/reference/array/isSubsetWith.html).
|
|
8
|
+
- Introduced compatibility functions for [words](https://es-toolkit.slash.page/reference/string/words.html), [at](https://es-toolkit.slash.page/reference/array/at.html), [differenceBy](https://es-toolkit.slash.page/reference/array/differenceBy.html), [uniqBy](https://es-toolkit.slash.page/reference/array/uniqBy.html), [forEach](https://es-toolkit.slash.page/reference/compat/array/forEach.html), [each](https://es-toolkit.slash.page/reference/compat/array/each.html), [sum](https://es-toolkit.slash.page/reference/math/sum.html), [sumBy](https://es-toolkit.slash.page/reference/array/sumBy.html), [union](https://es-toolkit.slash.page/reference/array/union.html), [zip](https://es-toolkit.slash.page/reference/array/zip.html), [unzip](https://es-toolkit.slash.page/reference/array/unzip.html), [iteratee](https://es-toolkit.slash.page/reference/compat/util/iteratee.html), [isEmpty](https://es-toolkit.slash.page/reference/compat/predicate/isEmpty.html), and [replace](https://es-toolkit.slash.page/reference/compat/string/replace.html).
|
|
9
|
+
- Fixed a bug in [cloneDeep](https://es-toolkit.slash.page/reference/object/cloneDeep.html) that prevented it from correctly cloning object prototypes.
|
|
10
|
+
- Improved performance for [at](https://es-toolkit.slash.page/reference/array/at.html).
|
|
11
|
+
- Enhanced performance for [toPath](https://es-toolkit.slash.page/reference/compat/util/toPath.html), [get](https://es-toolkit.slash.page/reference/compat/object/get.html), [set](https://es-toolkit.slash.page/reference/compat/object/set.html), [unset](https://es-toolkit.slash.page/reference/compat/object/unset.html), [has](https://es-toolkit.slash.page/reference/compat/object/has.html), [orderBy](https://es-toolkit.slash.page/reference/array/orderBy.html), [chunk](https://es-toolkit.slash.page/reference/array/chunk.html), [difference](https://es-toolkit.slash.page/reference/array/difference.html), [drop](https://es-toolkit.slash.page/reference/array/drop.html), [dropRight](https://es-toolkit.slash.page/reference/array/dropRight.html), [dropWhile](https://es-toolkit.slash.page/reference/array/dropWhile.html), [findLastIndex](https://es-toolkit.slash.page/reference/compat/array/findLastIndex.html), [head](https://es-toolkit.slash.page/reference/array/head.html), [last](https://es-toolkit.slash.page/reference/array/last.html), [sample](https://es-toolkit.slash.page/reference/array/sample.html), [tail](https://es-toolkit.slash.page/reference/array/tail.html), [take](https://es-toolkit.slash.page/reference/array/take.html), and [takeRight](https://es-toolkit.slash.page/reference/array/takeRight.html) in our compatibility library.
|
|
12
|
+
|
|
13
|
+
We sincerely thank @scato3, @ssi02014, @filipsobol, @mass2527, @Gyumong, @D-Sketon, @dayongkr, @kyvg, @Na-hyunwoo, @kaehehehe, and @bhollis for their contributions. Special thanks to @cruelladevil for improving the documentation. We appreciate your great efforts!
|
|
14
|
+
|
|
3
15
|
## Version v1.26.1
|
|
4
16
|
|
|
5
17
|
Released on October 25th, 2024.
|
|
@@ -54,14 +54,11 @@ function medianBy(items, getValue) {
|
|
|
54
54
|
return median(nums);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
function range(start, end, step) {
|
|
57
|
+
function range(start, end, step = 1) {
|
|
58
58
|
if (end == null) {
|
|
59
59
|
end = start;
|
|
60
60
|
start = 0;
|
|
61
61
|
}
|
|
62
|
-
if (step == null) {
|
|
63
|
-
step = 1;
|
|
64
|
-
}
|
|
65
62
|
if (!Number.isInteger(step) || step === 0) {
|
|
66
63
|
throw new Error(`The step value must be a non-zero integer.`);
|
|
67
64
|
}
|
|
@@ -73,14 +70,11 @@ function range(start, end, step) {
|
|
|
73
70
|
return result;
|
|
74
71
|
}
|
|
75
72
|
|
|
76
|
-
function rangeRight(start, end, step) {
|
|
73
|
+
function rangeRight(start, end, step = 1) {
|
|
77
74
|
if (end == null) {
|
|
78
75
|
end = start;
|
|
79
76
|
start = 0;
|
|
80
77
|
}
|
|
81
|
-
if (step == null) {
|
|
82
|
-
step = 1;
|
|
83
|
-
}
|
|
84
78
|
if (!Number.isInteger(step) || step === 0) {
|
|
85
79
|
throw new Error(`The step value must be a non-zero integer.`);
|
|
86
80
|
}
|
|
@@ -92,11 +86,6 @@ function rangeRight(start, end, step) {
|
|
|
92
86
|
return result;
|
|
93
87
|
}
|
|
94
88
|
|
|
95
|
-
function sumBy(items, getValue) {
|
|
96
|
-
const nums = items.map(x => getValue(x));
|
|
97
|
-
return sum(nums);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
89
|
exports.clamp = clamp;
|
|
101
90
|
exports.inRange = inRange;
|
|
102
91
|
exports.mean = mean;
|
|
@@ -106,4 +95,3 @@ exports.medianBy = medianBy;
|
|
|
106
95
|
exports.range = range;
|
|
107
96
|
exports.rangeRight = rangeRight;
|
|
108
97
|
exports.sum = sum;
|
|
109
|
-
exports.sumBy = sumBy;
|
|
@@ -134,7 +134,7 @@ function cloneDeepImpl(obj, stack = new Map()) {
|
|
|
134
134
|
return result;
|
|
135
135
|
}
|
|
136
136
|
if (typeof obj === 'object' && obj !== null) {
|
|
137
|
-
const result =
|
|
137
|
+
const result = Object.create(Object.getPrototypeOf(obj));
|
|
138
138
|
stack.set(obj, result);
|
|
139
139
|
copyProperties(result, obj, stack);
|
|
140
140
|
return result;
|
|
@@ -152,6 +152,11 @@ function copyProperties(target, source, stack) {
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
+
function findKey(obj, predicate) {
|
|
156
|
+
const keys = Object.keys(obj);
|
|
157
|
+
return keys.find(key => predicate(obj[key], key, obj));
|
|
158
|
+
}
|
|
159
|
+
|
|
155
160
|
function flattenObject(object) {
|
|
156
161
|
return flattenObjectImpl(object);
|
|
157
162
|
}
|
|
@@ -276,6 +281,7 @@ function toMerged(target, source) {
|
|
|
276
281
|
exports.clone = clone;
|
|
277
282
|
exports.cloneDeep = cloneDeep;
|
|
278
283
|
exports.copyProperties = copyProperties;
|
|
284
|
+
exports.findKey = findKey;
|
|
279
285
|
exports.flattenObject = flattenObject;
|
|
280
286
|
exports.invert = invert;
|
|
281
287
|
exports.isObjectLike = isObjectLike;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const CASE_SPLIT_PATTERN = /\p{Lu}?\p{Ll}+|[0-9]+|\p{Lu}+(?!\p{Ll})|\p{Emoji_Presentation}|\p{Extended_Pictographic}|\p{L}+/gu;
|
|
4
|
-
function getWords(str) {
|
|
5
|
-
return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
3
|
function capitalize(str) {
|
|
9
4
|
return (str.charAt(0).toUpperCase() + str.slice(1).toLowerCase());
|
|
10
5
|
}
|
|
11
6
|
|
|
7
|
+
const CASE_SPLIT_PATTERN = /\p{Lu}?\p{Ll}+|[0-9]+|\p{Lu}+(?!\p{Ll})|\p{Emoji_Presentation}|\p{Extended_Pictographic}|\p{L}+/gu;
|
|
8
|
+
function words(str) {
|
|
9
|
+
return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
12
|
function camelCase(str) {
|
|
13
|
-
const words =
|
|
14
|
-
if (words.length === 0) {
|
|
13
|
+
const words$1 = words(str);
|
|
14
|
+
if (words$1.length === 0) {
|
|
15
15
|
return '';
|
|
16
16
|
}
|
|
17
|
-
const [first, ...rest] = words;
|
|
17
|
+
const [first, ...rest] = words$1;
|
|
18
18
|
return `${first.toLowerCase()}${rest.map(word => capitalize(word)).join('')}`;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
function constantCase(str) {
|
|
22
|
-
const words =
|
|
23
|
-
return words.map(word => word.toUpperCase()).join('_');
|
|
22
|
+
const words$1 = words(str);
|
|
23
|
+
return words$1.map(word => word.toUpperCase()).join('_');
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const deburrMap = new Map(Object.entries({
|
|
@@ -83,13 +83,13 @@ function escapeRegExp(str) {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
function kebabCase(str) {
|
|
86
|
-
const words =
|
|
87
|
-
return words.map(word => word.toLowerCase()).join('-');
|
|
86
|
+
const words$1 = words(str);
|
|
87
|
+
return words$1.map(word => word.toLowerCase()).join('-');
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
function lowerCase(str) {
|
|
91
|
-
const words =
|
|
92
|
-
return words.map(word => word.toLowerCase()).join(' ');
|
|
91
|
+
const words$1 = words(str);
|
|
92
|
+
return words$1.map(word => word.toLowerCase()).join(' ');
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
function lowerFirst(str) {
|
|
@@ -101,13 +101,13 @@ function pad(str, length, chars = ' ') {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
function pascalCase(str) {
|
|
104
|
-
const words =
|
|
105
|
-
return words.map(word => capitalize(word)).join('');
|
|
104
|
+
const words$1 = words(str);
|
|
105
|
+
return words$1.map(word => capitalize(word)).join('');
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
function snakeCase(str) {
|
|
109
|
-
const words =
|
|
110
|
-
return words.map(word => word.toLowerCase()).join('_');
|
|
109
|
+
const words$1 = words(str);
|
|
110
|
+
return words$1.map(word => word.toLowerCase()).join('_');
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
function trimEnd(str, chars) {
|
|
@@ -171,11 +171,11 @@ function unescape(str) {
|
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
function upperCase(str) {
|
|
174
|
-
const words =
|
|
174
|
+
const words$1 = words(str);
|
|
175
175
|
let result = '';
|
|
176
|
-
for (let i = 0; i < words.length; i++) {
|
|
177
|
-
result += words[i].toUpperCase();
|
|
178
|
-
if (i < words.length - 1) {
|
|
176
|
+
for (let i = 0; i < words$1.length; i++) {
|
|
177
|
+
result += words$1[i].toUpperCase();
|
|
178
|
+
if (i < words$1.length - 1) {
|
|
179
179
|
result += ' ';
|
|
180
180
|
}
|
|
181
181
|
}
|
|
@@ -192,7 +192,6 @@ exports.constantCase = constantCase;
|
|
|
192
192
|
exports.deburr = deburr;
|
|
193
193
|
exports.escape = escape;
|
|
194
194
|
exports.escapeRegExp = escapeRegExp;
|
|
195
|
-
exports.getWords = getWords;
|
|
196
195
|
exports.kebabCase = kebabCase;
|
|
197
196
|
exports.lowerCase = lowerCase;
|
|
198
197
|
exports.lowerFirst = lowerFirst;
|
|
@@ -205,3 +204,4 @@ exports.trimStart = trimStart;
|
|
|
205
204
|
exports.unescape = unescape;
|
|
206
205
|
exports.upperCase = upperCase;
|
|
207
206
|
exports.upperFirst = upperFirst;
|
|
207
|
+
exports.words = words;
|
|
@@ -4,9 +4,14 @@ const randomInt = require('./randomInt-CF7bZK.js');
|
|
|
4
4
|
|
|
5
5
|
function at(arr, indices) {
|
|
6
6
|
const result = new Array(indices.length);
|
|
7
|
+
const length = arr.length;
|
|
7
8
|
for (let i = 0; i < indices.length; i++) {
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
let index = indices[i];
|
|
10
|
+
index = Number.isInteger(index) ? index : Math.trunc(index) || 0;
|
|
11
|
+
if (index < 0) {
|
|
12
|
+
index += length;
|
|
13
|
+
}
|
|
14
|
+
result[i] = arr[index];
|
|
10
15
|
}
|
|
11
16
|
return result;
|
|
12
17
|
}
|
|
@@ -188,6 +193,10 @@ function isSubset(superset, subset) {
|
|
|
188
193
|
return difference(subset, superset).length === 0;
|
|
189
194
|
}
|
|
190
195
|
|
|
196
|
+
function isSubsetWith(superset, subset, areItemsEqual) {
|
|
197
|
+
return differenceWith(subset, superset, areItemsEqual).length === 0;
|
|
198
|
+
}
|
|
199
|
+
|
|
191
200
|
function keyBy(arr, getKeyFromItem) {
|
|
192
201
|
const result = {};
|
|
193
202
|
for (let i = 0; i < arr.length; i++) {
|
|
@@ -403,8 +412,7 @@ function unzipWith(target, iteratee) {
|
|
|
403
412
|
}
|
|
404
413
|
|
|
405
414
|
function without(array, ...values) {
|
|
406
|
-
|
|
407
|
-
return array.filter(item => !valuesSet.has(item));
|
|
415
|
+
return difference(array, values);
|
|
408
416
|
}
|
|
409
417
|
|
|
410
418
|
function xor(arr1, arr2) {
|
|
@@ -424,7 +432,12 @@ function xorWith(arr1, arr2, areElementsEqual) {
|
|
|
424
432
|
}
|
|
425
433
|
|
|
426
434
|
function zip(...arrs) {
|
|
427
|
-
|
|
435
|
+
let rowCount = 0;
|
|
436
|
+
for (let i = 0; i < arrs.length; i++) {
|
|
437
|
+
if (arrs[i].length > rowCount) {
|
|
438
|
+
rowCount = arrs[i].length;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
428
441
|
const columnCount = arrs.length;
|
|
429
442
|
const result = Array(rowCount);
|
|
430
443
|
for (let i = 0; i < rowCount; ++i) {
|
|
@@ -481,6 +494,7 @@ exports.intersection = intersection;
|
|
|
481
494
|
exports.intersectionBy = intersectionBy;
|
|
482
495
|
exports.intersectionWith = intersectionWith;
|
|
483
496
|
exports.isSubset = isSubset;
|
|
497
|
+
exports.isSubsetWith = isSubsetWith;
|
|
484
498
|
exports.keyBy = keyBy;
|
|
485
499
|
exports.last = last;
|
|
486
500
|
exports.maxBy = maxBy;
|
package/dist/array/at.mjs
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
function at(arr, indices) {
|
|
2
2
|
const result = new Array(indices.length);
|
|
3
|
+
const length = arr.length;
|
|
3
4
|
for (let i = 0; i < indices.length; i++) {
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
let index = indices[i];
|
|
6
|
+
index = Number.isInteger(index) ? index : Math.trunc(index) || 0;
|
|
7
|
+
if (index < 0) {
|
|
8
|
+
index += length;
|
|
9
|
+
}
|
|
10
|
+
result[i] = arr[index];
|
|
6
11
|
}
|
|
7
12
|
return result;
|
|
8
13
|
}
|
package/dist/array/index.d.mts
CHANGED
|
@@ -22,6 +22,7 @@ export { intersection } from './intersection.mjs';
|
|
|
22
22
|
export { intersectionBy } from './intersectionBy.mjs';
|
|
23
23
|
export { intersectionWith } from './intersectionWith.mjs';
|
|
24
24
|
export { isSubset } from './isSubset.mjs';
|
|
25
|
+
export { isSubsetWith } from './isSubsetWith.mjs';
|
|
25
26
|
export { keyBy } from './keyBy.mjs';
|
|
26
27
|
export { last } from './last.mjs';
|
|
27
28
|
export { maxBy } from './maxBy.mjs';
|
package/dist/array/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export { intersection } from './intersection.js';
|
|
|
22
22
|
export { intersectionBy } from './intersectionBy.js';
|
|
23
23
|
export { intersectionWith } from './intersectionWith.js';
|
|
24
24
|
export { isSubset } from './isSubset.js';
|
|
25
|
+
export { isSubsetWith } from './isSubsetWith.js';
|
|
25
26
|
export { keyBy } from './keyBy.js';
|
|
26
27
|
export { last } from './last.js';
|
|
27
28
|
export { maxBy } from './maxBy.js';
|
package/dist/array/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const zipWith = require('../_chunk/zipWith-
|
|
5
|
+
const zipWith = require('../_chunk/zipWith-Bb2eZI.js');
|
|
6
6
|
|
|
7
7
|
function compareValues(a, b, order) {
|
|
8
8
|
if (a < b) {
|
|
@@ -60,6 +60,7 @@ exports.intersection = zipWith.intersection;
|
|
|
60
60
|
exports.intersectionBy = zipWith.intersectionBy;
|
|
61
61
|
exports.intersectionWith = zipWith.intersectionWith;
|
|
62
62
|
exports.isSubset = zipWith.isSubset;
|
|
63
|
+
exports.isSubsetWith = zipWith.isSubsetWith;
|
|
63
64
|
exports.keyBy = zipWith.keyBy;
|
|
64
65
|
exports.last = zipWith.last;
|
|
65
66
|
exports.maxBy = zipWith.maxBy;
|
package/dist/array/index.mjs
CHANGED
|
@@ -22,6 +22,7 @@ export { intersection } from './intersection.mjs';
|
|
|
22
22
|
export { intersectionBy } from './intersectionBy.mjs';
|
|
23
23
|
export { intersectionWith } from './intersectionWith.mjs';
|
|
24
24
|
export { isSubset } from './isSubset.mjs';
|
|
25
|
+
export { isSubsetWith } from './isSubsetWith.mjs';
|
|
25
26
|
export { keyBy } from './keyBy.mjs';
|
|
26
27
|
export { last } from './last.mjs';
|
|
27
28
|
export { maxBy } from './maxBy.mjs';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the `subset` array is entirely contained within the `superset` array based on a custom equality function.
|
|
3
|
+
*
|
|
4
|
+
* This function takes two arrays and a custom comparison function. It returns a boolean indicating
|
|
5
|
+
* whether all elements in the subset array are present in the superset array, as determined by the provided
|
|
6
|
+
* custom equality function.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of elements contained in the arrays.
|
|
9
|
+
* @param {T[]} superset - The array that may contain all elements of the subset.
|
|
10
|
+
* @param {T[]} subset - The array to check against the superset.
|
|
11
|
+
* @param {(x: T, y: T) => boolean} areItemsEqual - A function to determine if two items are equal.
|
|
12
|
+
* @returns {boolean} - Returns `true` if all elements of the subset are present in the superset
|
|
13
|
+
* according to the custom equality function, otherwise returns `false`.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const superset = [{ id: 1 }, { id: 2 }, { id: 3 }];
|
|
18
|
+
* const subset = [{ id: 2 }, { id: 1 }];
|
|
19
|
+
* const areItemsEqual = (a, b) => a.id === b.id;
|
|
20
|
+
* isSubsetWith(superset, subset, areItemsEqual); // true
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const superset = [{ id: 1 }, { id: 2 }, { id: 3 }];
|
|
26
|
+
* const subset = [{ id: 4 }];
|
|
27
|
+
* const areItemsEqual = (a, b) => a.id === b.id;
|
|
28
|
+
* isSubsetWith(superset, subset, areItemsEqual); // false
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
declare function isSubsetWith<T>(superset: readonly T[], subset: readonly T[], areItemsEqual: (x: T, y: T) => boolean): boolean;
|
|
32
|
+
|
|
33
|
+
export { isSubsetWith };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the `subset` array is entirely contained within the `superset` array based on a custom equality function.
|
|
3
|
+
*
|
|
4
|
+
* This function takes two arrays and a custom comparison function. It returns a boolean indicating
|
|
5
|
+
* whether all elements in the subset array are present in the superset array, as determined by the provided
|
|
6
|
+
* custom equality function.
|
|
7
|
+
*
|
|
8
|
+
* @template T - The type of elements contained in the arrays.
|
|
9
|
+
* @param {T[]} superset - The array that may contain all elements of the subset.
|
|
10
|
+
* @param {T[]} subset - The array to check against the superset.
|
|
11
|
+
* @param {(x: T, y: T) => boolean} areItemsEqual - A function to determine if two items are equal.
|
|
12
|
+
* @returns {boolean} - Returns `true` if all elements of the subset are present in the superset
|
|
13
|
+
* according to the custom equality function, otherwise returns `false`.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const superset = [{ id: 1 }, { id: 2 }, { id: 3 }];
|
|
18
|
+
* const subset = [{ id: 2 }, { id: 1 }];
|
|
19
|
+
* const areItemsEqual = (a, b) => a.id === b.id;
|
|
20
|
+
* isSubsetWith(superset, subset, areItemsEqual); // true
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const superset = [{ id: 1 }, { id: 2 }, { id: 3 }];
|
|
26
|
+
* const subset = [{ id: 4 }];
|
|
27
|
+
* const areItemsEqual = (a, b) => a.id === b.id;
|
|
28
|
+
* isSubsetWith(superset, subset, areItemsEqual); // false
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
declare function isSubsetWith<T>(superset: readonly T[], subset: readonly T[], areItemsEqual: (x: T, y: T) => boolean): boolean;
|
|
32
|
+
|
|
33
|
+
export { isSubsetWith };
|
package/dist/array/without.mjs
CHANGED
package/dist/array/zip.mjs
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
function zip(...arrs) {
|
|
2
|
-
|
|
2
|
+
let rowCount = 0;
|
|
3
|
+
for (let i = 0; i < arrs.length; i++) {
|
|
4
|
+
if (arrs[i].length > rowCount) {
|
|
5
|
+
rowCount = arrs[i].length;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
3
8
|
const columnCount = arrs.length;
|
|
4
9
|
const result = Array(rowCount);
|
|
5
10
|
for (let i = 0; i < rowCount; ++i) {
|