es-toolkit 1.6.1-dev.138 → 1.6.1-dev.140
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/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/index.d.mts +2 -0
- package/dist/array/index.d.ts +2 -0
- package/dist/array/index.js +20 -0
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +24 -16
- package/dist/array/sampleSize.mjs +2 -2
- 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/chunk-4CA2UN6V.mjs +1 -0
- package/dist/chunk-4CA2UN6V.mjs.map +1 -0
- package/dist/chunk-C4WE4GLC.mjs +14 -0
- package/dist/chunk-C4WE4GLC.mjs.map +1 -0
- package/dist/chunk-PYEYV7BY.mjs +10 -0
- package/dist/chunk-PYEYV7BY.mjs.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -34
- package/dist/math/index.mjs +6 -6
- package/dist/object/index.mjs +3 -3
- package/dist/predicate/index.mjs +6 -6
- package/package.json +1 -1
- package/dist/chunk-D735JOLS.mjs +0 -1
- /package/dist/{chunk-D735JOLS.mjs.map → array/fill.mjs.map} +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates an array that excludes all specified values.
|
|
3
|
+
*
|
|
4
|
+
* It correctly excludes `NaN`, as it compares values using [SameValueZero](https://tc39.es/ecma262/multipage/abstract-operations.html#sec-samevaluezero).
|
|
5
|
+
*
|
|
6
|
+
* @template T The type of elements in the array.
|
|
7
|
+
* @param {T[]} array - The array to filter.
|
|
8
|
+
* @param {...T[]} values - The values to exclude.
|
|
9
|
+
* @returns {T[]} A new array without the specified values.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Removes the specified values from the array
|
|
13
|
+
* without([1, 2, 3, 4, 5], 2, 4);
|
|
14
|
+
* // Returns: [1, 3, 5]
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Removes specified string values from the array
|
|
18
|
+
* without(['a', 'b', 'c', 'a'], 'a');
|
|
19
|
+
* // Returns: ['b', 'c']
|
|
20
|
+
*/
|
|
21
|
+
declare function without<T>(array: readonly T[], ...values: T[]): T[];
|
|
22
|
+
|
|
23
|
+
export { without };
|
|
@@ -0,0 +1,34 @@
|
|
|
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/without.ts
|
|
21
|
+
var without_exports = {};
|
|
22
|
+
__export(without_exports, {
|
|
23
|
+
without: () => without
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(without_exports);
|
|
26
|
+
function without(array, ...values) {
|
|
27
|
+
const valuesSet = new Set(values);
|
|
28
|
+
return array.filter((item) => !valuesSet.has(item));
|
|
29
|
+
}
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
without
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=without.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/array/without.ts"],"sourcesContent":["/**\n * Creates an array that excludes all specified values.\n *\n * It correctly excludes `NaN`, as it compares values using [SameValueZero](https://tc39.es/ecma262/multipage/abstract-operations.html#sec-samevaluezero).\n *\n * @template T The type of elements in the array.\n * @param {T[]} array - The array to filter.\n * @param {...T[]} values - The values to exclude.\n * @returns {T[]} A new array without the specified values.\n *\n * @example\n * // Removes the specified values from the array\n * without([1, 2, 3, 4, 5], 2, 4);\n * // Returns: [1, 3, 5]\n *\n * @example\n * // Removes specified string values from the array\n * without(['a', 'b', 'c', 'a'], 'a');\n * // Returns: ['b', 'c']\n */\nexport function without<T>(array: readonly T[], ...values: T[]): T[] {\n const valuesSet = new Set(values);\n return array.filter(item => !valuesSet.has(item));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBO,SAAS,QAAW,UAAwB,QAAkB;AACnE,QAAM,YAAY,IAAI,IAAI,MAAM;AAChC,SAAO,MAAM,OAAO,UAAQ,CAAC,UAAU,IAAI,IAAI,CAAC;AAClD;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-4CA2UN6V.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// src/array/fill.ts
|
|
2
|
+
function fill(arr, value, start = 0, end = arr.length) {
|
|
3
|
+
start = Math.max(start, 0);
|
|
4
|
+
end = Math.min(end, arr.length);
|
|
5
|
+
for (let i = start; i < end; i++) {
|
|
6
|
+
arr[i] = value;
|
|
7
|
+
}
|
|
8
|
+
return arr;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
fill
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=chunk-C4WE4GLC.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/array/fill.ts"],"sourcesContent":["/**\n * Fills elements of an array with a specified value from the start position up to, but not including, the end position.\n *\n * This function mutates the original array and replaces its elements with the provided value, starting from the specified\n * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the\n * entire array. Negative indices can be used to specify positions from the end of the array.\n *\n * @param {Array<T | P>} arr - The array to fill.\n * @param {P} value - The value to fill the array with.\n * @param {number} [start=0] - The start position. Defaults to 0.\n * @param {number} [end=arr.length] - The end position. Defaults to the array's length.\n * @returns {Array<T | P>} The array with the filled values.\n *\n * @example\n * const array = [1, 2, 3];\n * const result = fill(array, 'a');\n * // => ['a', 'a', 'a']\n *\n * const result = fill(Array(3), 2);\n * // => [2, 2, 2]\n *\n * const result = fill([4, 6, 8, 10], '*', 1, 3);\n * // => [4, '*', '*', 10]\n */\n\nexport function fill<T>(arr: unknown[], value: T): T[];\nexport function fill<T, P>(arr: Array<T | P>, value: P, start: number): Array<T | P>;\nexport function fill<T, P>(arr: Array<T | P>, value: P, start: number, end: number): Array<T | P>;\nexport function fill<T, P>(arr: Array<T | P>, value: P, start = 0, end = arr.length): Array<T | P> {\n start = Math.max(start, 0);\n end = Math.min(end, arr.length);\n\n for (let i = start; i < end; i++) {\n arr[i] = value;\n }\n\n return arr;\n}\n"],"mappings":";AA4BO,SAAS,KAAW,KAAmB,OAAU,QAAQ,GAAG,MAAM,IAAI,QAAsB;AACjG,UAAQ,KAAK,IAAI,OAAO,CAAC;AACzB,QAAM,KAAK,IAAI,KAAK,IAAI,MAAM;AAE9B,WAAS,IAAI,OAAO,IAAI,KAAK,KAAK;AAChC,QAAI,CAAC,IAAI;AAAA,EACX;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/array/without.ts"],"sourcesContent":["/**\n * Creates an array that excludes all specified values.\n *\n * It correctly excludes `NaN`, as it compares values using [SameValueZero](https://tc39.es/ecma262/multipage/abstract-operations.html#sec-samevaluezero).\n *\n * @template T The type of elements in the array.\n * @param {T[]} array - The array to filter.\n * @param {...T[]} values - The values to exclude.\n * @returns {T[]} A new array without the specified values.\n *\n * @example\n * // Removes the specified values from the array\n * without([1, 2, 3, 4, 5], 2, 4);\n * // Returns: [1, 3, 5]\n *\n * @example\n * // Removes specified string values from the array\n * without(['a', 'b', 'c', 'a'], 'a');\n * // Returns: ['b', 'c']\n */\nexport function without<T>(array: readonly T[], ...values: T[]): T[] {\n const valuesSet = new Set(values);\n return array.filter(item => !valuesSet.has(item));\n}\n"],"mappings":";AAoBO,SAAS,QAAW,UAAwB,QAAkB;AACnE,QAAM,YAAY,IAAI,IAAI,MAAM;AAChC,SAAO,MAAM,OAAO,UAAQ,CAAC,UAAU,IAAI,IAAI,CAAC;AAClD;","names":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -28,12 +28,14 @@ export { unionWith } from './array/unionWith.mjs';
|
|
|
28
28
|
export { uniq } from './array/uniq.mjs';
|
|
29
29
|
export { uniqBy } from './array/uniqBy.mjs';
|
|
30
30
|
export { uniqWith } from './array/uniqWith.mjs';
|
|
31
|
+
export { without } from './array/without.mjs';
|
|
31
32
|
export { xor } from './array/xor.mjs';
|
|
32
33
|
export { xorBy } from './array/xorBy.mjs';
|
|
33
34
|
export { xorWith } from './array/xorWith.mjs';
|
|
34
35
|
export { zip } from './array/zip.mjs';
|
|
35
36
|
export { zipWith } from './array/zipWith.mjs';
|
|
36
37
|
export { zipObject } from './array/zipObject.mjs';
|
|
38
|
+
export { fill } from './array/fill.mjs';
|
|
37
39
|
export { AbortError } from './error/AbortError.mjs';
|
|
38
40
|
export { debounce } from './function/debounce.mjs';
|
|
39
41
|
export { noop } from './function/noop.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -28,12 +28,14 @@ export { unionWith } from './array/unionWith.js';
|
|
|
28
28
|
export { uniq } from './array/uniq.js';
|
|
29
29
|
export { uniqBy } from './array/uniqBy.js';
|
|
30
30
|
export { uniqWith } from './array/uniqWith.js';
|
|
31
|
+
export { without } from './array/without.js';
|
|
31
32
|
export { xor } from './array/xor.js';
|
|
32
33
|
export { xorBy } from './array/xorBy.js';
|
|
33
34
|
export { xorWith } from './array/xorWith.js';
|
|
34
35
|
export { zip } from './array/zip.js';
|
|
35
36
|
export { zipWith } from './array/zipWith.js';
|
|
36
37
|
export { zipObject } from './array/zipObject.js';
|
|
38
|
+
export { fill } from './array/fill.js';
|
|
37
39
|
export { AbortError } from './error/AbortError.js';
|
|
38
40
|
export { debounce } from './function/debounce.js';
|
|
39
41
|
export { noop } from './function/noop.js';
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,7 @@ __export(src_exports, {
|
|
|
47
47
|
dropRight: () => dropRight,
|
|
48
48
|
dropRightWhile: () => dropRightWhile,
|
|
49
49
|
dropWhile: () => dropWhile,
|
|
50
|
+
fill: () => fill,
|
|
50
51
|
groupBy: () => groupBy,
|
|
51
52
|
intersection: () => intersection,
|
|
52
53
|
intersectionBy: () => intersectionBy,
|
|
@@ -86,6 +87,7 @@ __export(src_exports, {
|
|
|
86
87
|
uniq: () => uniq,
|
|
87
88
|
uniqBy: () => uniqBy,
|
|
88
89
|
uniqWith: () => uniqWith,
|
|
90
|
+
without: () => without,
|
|
89
91
|
xor: () => xor,
|
|
90
92
|
xorBy: () => xorBy,
|
|
91
93
|
xorWith: () => xorWith,
|
|
@@ -452,6 +454,12 @@ function uniqBy(arr, mapper) {
|
|
|
452
454
|
return Array.from(map.values());
|
|
453
455
|
}
|
|
454
456
|
|
|
457
|
+
// src/array/without.ts
|
|
458
|
+
function without(array, ...values) {
|
|
459
|
+
const valuesSet = new Set(values);
|
|
460
|
+
return array.filter((item) => !valuesSet.has(item));
|
|
461
|
+
}
|
|
462
|
+
|
|
455
463
|
// src/array/xor.ts
|
|
456
464
|
function xor(arr1, arr2) {
|
|
457
465
|
return difference(union(arr1, arr2), intersection(arr1, arr2));
|
|
@@ -507,6 +515,16 @@ function zipObject(keys, values) {
|
|
|
507
515
|
return result;
|
|
508
516
|
}
|
|
509
517
|
|
|
518
|
+
// src/array/fill.ts
|
|
519
|
+
function fill(arr, value, start = 0, end = arr.length) {
|
|
520
|
+
start = Math.max(start, 0);
|
|
521
|
+
end = Math.min(end, arr.length);
|
|
522
|
+
for (let i = start; i < end; i++) {
|
|
523
|
+
arr[i] = value;
|
|
524
|
+
}
|
|
525
|
+
return arr;
|
|
526
|
+
}
|
|
527
|
+
|
|
510
528
|
// src/error/AbortError.ts
|
|
511
529
|
var AbortError = class extends Error {
|
|
512
530
|
constructor(message = "The operation was aborted") {
|
|
@@ -669,6 +687,7 @@ function delay(ms, { signal } = {}) {
|
|
|
669
687
|
dropRight,
|
|
670
688
|
dropRightWhile,
|
|
671
689
|
dropWhile,
|
|
690
|
+
fill,
|
|
672
691
|
groupBy,
|
|
673
692
|
intersection,
|
|
674
693
|
intersectionBy,
|
|
@@ -708,6 +727,7 @@ function delay(ms, { signal } = {}) {
|
|
|
708
727
|
uniq,
|
|
709
728
|
uniqBy,
|
|
710
729
|
uniqWith,
|
|
730
|
+
without,
|
|
711
731
|
xor,
|
|
712
732
|
xorBy,
|
|
713
733
|
xorWith,
|