es-toolkit 1.20.0-dev.644 → 1.20.0-dev.647

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.
@@ -1,13 +1,13 @@
1
- type NotFalsey<T> = Exclude<T, false | null | 0 | '' | undefined>;
1
+ type NotFalsey<T> = Exclude<T, false | null | 0 | 0n | '' | undefined>;
2
2
  /**
3
- * Removes falsey values (false, null, 0, '', undefined, NaN) from an array.
3
+ * Removes falsey values (false, null, 0, 0n, '', undefined, NaN) from an array.
4
4
  *
5
5
  * @template T - The type of elements in the array.
6
6
  * @param {T[]} arr - The input array to remove falsey values.
7
- * @returns {Array<Exclude<T, false | null | 0 | '' | undefined>>} - A new array with all falsey values removed.
7
+ * @returns {Array<Exclude<T, false | null | 0 | 0n | '' | undefined>>} - A new array with all falsey values removed.
8
8
  *
9
9
  * @example
10
- * compact([0, 1, false, 2, '', 3, null, undefined, 4, NaN, 5]);
10
+ * compact([0, 0n, 1, false, 2, '', 3, null, undefined, 4, NaN, 5]);
11
11
  * Returns: [1, 2, 3, 4, 5]
12
12
  */
13
13
  declare function compact<T>(arr: readonly T[]): Array<NotFalsey<T>>;
@@ -1,13 +1,13 @@
1
- type NotFalsey<T> = Exclude<T, false | null | 0 | '' | undefined>;
1
+ type NotFalsey<T> = Exclude<T, false | null | 0 | 0n | '' | undefined>;
2
2
  /**
3
- * Removes falsey values (false, null, 0, '', undefined, NaN) from an array.
3
+ * Removes falsey values (false, null, 0, 0n, '', undefined, NaN) from an array.
4
4
  *
5
5
  * @template T - The type of elements in the array.
6
6
  * @param {T[]} arr - The input array to remove falsey values.
7
- * @returns {Array<Exclude<T, false | null | 0 | '' | undefined>>} - A new array with all falsey values removed.
7
+ * @returns {Array<Exclude<T, false | null | 0 | 0n | '' | undefined>>} - A new array with all falsey values removed.
8
8
  *
9
9
  * @example
10
- * compact([0, 1, false, 2, '', 3, null, undefined, 4, NaN, 5]);
10
+ * compact([0, 0n, 1, false, 2, '', 3, null, undefined, 4, NaN, 5]);
11
11
  * Returns: [1, 2, 3, 4, 5]
12
12
  */
13
13
  declare function compact<T>(arr: readonly T[]): Array<NotFalsey<T>>;
@@ -9,6 +9,14 @@
9
9
  * @example
10
10
  * maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 }
11
11
  * maxBy([], x => x.a); // Returns: undefined
12
+ * maxBy(
13
+ * [
14
+ * { name: 'john', age: 30 },
15
+ * { name: 'jane', age: 28 },
16
+ * { name: 'joe', age: 26 },
17
+ * ],
18
+ * x => x.age
19
+ * ); // Returns: { name: 'john', age: 30 }
12
20
  */
13
21
  declare function maxBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
14
22
  /**
@@ -22,6 +30,14 @@ declare function maxBy<T>(items: readonly [T, ...T[]], getValue: (element: T) =>
22
30
  * @example
23
31
  * maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 }
24
32
  * maxBy([], x => x.a); // Returns: undefined
33
+ * maxBy(
34
+ * [
35
+ * { name: 'john', age: 30 },
36
+ * { name: 'jane', age: 28 },
37
+ * { name: 'joe', age: 26 },
38
+ * ],
39
+ * x => x.age
40
+ * ); // Returns: { name: 'john', age: 30 }
25
41
  */
26
42
  declare function maxBy<T>(items: readonly T[], getValue: (element: T) => number): T | undefined;
27
43
 
@@ -9,6 +9,14 @@
9
9
  * @example
10
10
  * maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 }
11
11
  * maxBy([], x => x.a); // Returns: undefined
12
+ * maxBy(
13
+ * [
14
+ * { name: 'john', age: 30 },
15
+ * { name: 'jane', age: 28 },
16
+ * { name: 'joe', age: 26 },
17
+ * ],
18
+ * x => x.age
19
+ * ); // Returns: { name: 'john', age: 30 }
12
20
  */
13
21
  declare function maxBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
14
22
  /**
@@ -22,6 +30,14 @@ declare function maxBy<T>(items: readonly [T, ...T[]], getValue: (element: T) =>
22
30
  * @example
23
31
  * maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 3 }
24
32
  * maxBy([], x => x.a); // Returns: undefined
33
+ * maxBy(
34
+ * [
35
+ * { name: 'john', age: 30 },
36
+ * { name: 'jane', age: 28 },
37
+ * { name: 'joe', age: 26 },
38
+ * ],
39
+ * x => x.age
40
+ * ); // Returns: { name: 'john', age: 30 }
25
41
  */
26
42
  declare function maxBy<T>(items: readonly T[], getValue: (element: T) => number): T | undefined;
27
43
 
@@ -9,6 +9,14 @@
9
9
  * @example
10
10
  * minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }
11
11
  * minBy([], x => x.a); // Returns: undefined
12
+ * minBy(
13
+ * [
14
+ * { name: 'john', age: 30 },
15
+ * { name: 'jane', age: 28 },
16
+ * { name: 'joe', age: 26 },
17
+ * ],
18
+ * x => x.age
19
+ * ); // Returns: { name: 'joe', age: 26 }
12
20
  */
13
21
  declare function minBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
14
22
  /**
@@ -22,6 +30,14 @@ declare function minBy<T>(items: readonly [T, ...T[]], getValue: (element: T) =>
22
30
  * @example
23
31
  * minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }
24
32
  * minBy([], x => x.a); // Returns: undefined
33
+ * minBy(
34
+ * [
35
+ * { name: 'john', age: 30 },
36
+ * { name: 'jane', age: 28 },
37
+ * { name: 'joe', age: 26 },
38
+ * ],
39
+ * x => x.age
40
+ * ); // Returns: { name: 'joe', age: 26 }
25
41
  */
26
42
  declare function minBy<T>(items: readonly T[], getValue: (element: T) => number): T | undefined;
27
43
 
@@ -9,6 +9,14 @@
9
9
  * @example
10
10
  * minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }
11
11
  * minBy([], x => x.a); // Returns: undefined
12
+ * minBy(
13
+ * [
14
+ * { name: 'john', age: 30 },
15
+ * { name: 'jane', age: 28 },
16
+ * { name: 'joe', age: 26 },
17
+ * ],
18
+ * x => x.age
19
+ * ); // Returns: { name: 'joe', age: 26 }
12
20
  */
13
21
  declare function minBy<T>(items: readonly [T, ...T[]], getValue: (element: T) => number): T;
14
22
  /**
@@ -22,6 +30,14 @@ declare function minBy<T>(items: readonly [T, ...T[]], getValue: (element: T) =>
22
30
  * @example
23
31
  * minBy([{ a: 1 }, { a: 2 }, { a: 3 }], x => x.a); // Returns: { a: 1 }
24
32
  * minBy([], x => x.a); // Returns: undefined
33
+ * minBy(
34
+ * [
35
+ * { name: 'john', age: 30 },
36
+ * { name: 'jane', age: 28 },
37
+ * { name: 'joe', age: 26 },
38
+ * ],
39
+ * x => x.age
40
+ * ); // Returns: { name: 'joe', age: 26 }
25
41
  */
26
42
  declare function minBy<T>(items: readonly T[], getValue: (element: T) => number): T | undefined;
27
43