es-toolkit 1.39.7-dev.1480 → 1.39.7-dev.1482

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.
@@ -0,0 +1,3 @@
1
+ type IsWritable<T> = Equals<{ [K in keyof T]: T[K] }, { -readonly [K in keyof T]: T[K] }>;
2
+
3
+ export type { IsWritable };
@@ -0,0 +1,3 @@
1
+ type IsWritable<T> = Equals<{ [K in keyof T]: T[K] }, { -readonly [K in keyof T]: T[K] }>;
2
+
3
+ export type { IsWritable };
@@ -0,0 +1,6 @@
1
+ interface MutableList<T> {
2
+ length: number;
3
+ [k: number]: T;
4
+ }
5
+
6
+ export type { MutableList };
@@ -0,0 +1,6 @@
1
+ interface MutableList<T> {
2
+ length: number;
3
+ [k: number]: T;
4
+ }
5
+
6
+ export type { MutableList };
@@ -0,0 +1,6 @@
1
+ import { IsWritable } from './IsWritable.d.mjs';
2
+ import { MutableList } from './MutableList.d.mjs';
3
+
4
+ type RejectReadonly<T extends MutableList<unknown>> = IsWritable<T> extends true ? T : never;
5
+
6
+ export type { RejectReadonly };
@@ -0,0 +1,6 @@
1
+ import { IsWritable } from './IsWritable.d.js';
2
+ import { MutableList } from './MutableList.d.js';
3
+
4
+ type RejectReadonly<T extends MutableList<unknown>> = IsWritable<T> extends true ? T : never;
5
+
6
+ export type { RejectReadonly };
@@ -1,3 +1,6 @@
1
+ import { MutableList } from '../_internal/MutableList.d.mjs';
2
+ import { RejectReadonly } from '../_internal/RejectReadonly.d.mjs';
3
+
1
4
  /**
2
5
  * Fills an array with a value.
3
6
  * @template T
@@ -11,15 +14,15 @@
11
14
  declare function fill<T>(array: any[] | null | undefined, value: T): T[];
12
15
  /**
13
16
  * Fills an array-like object with a value.
14
- * @template T, U
15
- * @param {U extends readonly any[] ? never : U | null | undefined} array - The array-like object to fill
17
+ * @template T, AL
18
+ * @param {RejectReadonly<AL> | null | undefined} array - The array-like object to fill
16
19
  * @param {T} value - The value to fill array with
17
20
  * @returns {ArrayLike<T>} Returns the filled array-like object
18
21
  * @example
19
22
  * fill({ length: 3 }, 2)
20
23
  * // => { 0: 2, 1: 2, 2: 2, length: 3 }
21
24
  */
22
- declare function fill<T, U extends ArrayLike<any>>(array: U extends readonly any[] ? never : U | null | undefined, value: T): ArrayLike<T>;
25
+ declare function fill<T, AL extends MutableList<any>>(array: RejectReadonly<AL> | null | undefined, value: T): ArrayLike<T>;
23
26
  /**
24
27
  * Fills an array with a value from start up to end.
25
28
  * @template T, U
@@ -45,6 +48,6 @@ declare function fill<T, U>(array: U[] | null | undefined, value: T, start?: num
45
48
  * fill({ 0: 1, 1: 2, 2: 3, length: 3 }, 'a', 1, 2)
46
49
  * // => { 0: 1, 1: 'a', 2: 3, length: 3 }
47
50
  */
48
- declare function fill<T, U extends ArrayLike<any>>(array: U extends readonly any[] ? never : U | null | undefined, value: T, start?: number, end?: number): ArrayLike<T | U[0]>;
51
+ declare function fill<T, U extends MutableList<any>>(array: RejectReadonly<U> | null | undefined, value: T, start?: number, end?: number): ArrayLike<T | U[0]>;
49
52
 
50
53
  export { fill };
@@ -1,3 +1,6 @@
1
+ import { MutableList } from '../_internal/MutableList.d.js';
2
+ import { RejectReadonly } from '../_internal/RejectReadonly.d.js';
3
+
1
4
  /**
2
5
  * Fills an array with a value.
3
6
  * @template T
@@ -11,15 +14,15 @@
11
14
  declare function fill<T>(array: any[] | null | undefined, value: T): T[];
12
15
  /**
13
16
  * Fills an array-like object with a value.
14
- * @template T, U
15
- * @param {U extends readonly any[] ? never : U | null | undefined} array - The array-like object to fill
17
+ * @template T, AL
18
+ * @param {RejectReadonly<AL> | null | undefined} array - The array-like object to fill
16
19
  * @param {T} value - The value to fill array with
17
20
  * @returns {ArrayLike<T>} Returns the filled array-like object
18
21
  * @example
19
22
  * fill({ length: 3 }, 2)
20
23
  * // => { 0: 2, 1: 2, 2: 2, length: 3 }
21
24
  */
22
- declare function fill<T, U extends ArrayLike<any>>(array: U extends readonly any[] ? never : U | null | undefined, value: T): ArrayLike<T>;
25
+ declare function fill<T, AL extends MutableList<any>>(array: RejectReadonly<AL> | null | undefined, value: T): ArrayLike<T>;
23
26
  /**
24
27
  * Fills an array with a value from start up to end.
25
28
  * @template T, U
@@ -45,6 +48,6 @@ declare function fill<T, U>(array: U[] | null | undefined, value: T, start?: num
45
48
  * fill({ 0: 1, 1: 2, 2: 3, length: 3 }, 'a', 1, 2)
46
49
  * // => { 0: 1, 1: 'a', 2: 3, length: 3 }
47
50
  */
48
- declare function fill<T, U extends ArrayLike<any>>(array: U extends readonly any[] ? never : U | null | undefined, value: T, start?: number, end?: number): ArrayLike<T | U[0]>;
51
+ declare function fill<T, U extends MutableList<any>>(array: RejectReadonly<U> | null | undefined, value: T, start?: number, end?: number): ArrayLike<T | U[0]>;
49
52
 
50
53
  export { fill };
@@ -1,3 +1,6 @@
1
+ import { MutableList } from '../_internal/MutableList.d.mjs';
2
+ import { RejectReadonly } from '../_internal/RejectReadonly.d.mjs';
3
+
1
4
  /**
2
5
  * This method is like `_.pull` except that it accepts an array of values to remove.
3
6
  *
@@ -22,8 +25,8 @@ declare function pullAll<T>(array: T[], values?: ArrayLike<T>): T[];
22
25
  * **Note:** Unlike `_.difference`, this method mutates `array`.
23
26
  *
24
27
  * @template L
25
- * @param {L} array - The array to modify.
26
- * @param {ArrayLike<L[0]>} [values] - The values to remove.
28
+ * @param {RejectReadonly<L>} array - The array to modify.
29
+ * @param {List<L[0]>} [values] - The values to remove.
27
30
  * @returns {L} Returns `array`.
28
31
  *
29
32
  * @example
@@ -33,6 +36,6 @@ declare function pullAll<T>(array: T[], values?: ArrayLike<T>): T[];
33
36
  * console.log(array);
34
37
  * // => [1, 1]
35
38
  */
36
- declare function pullAll<L extends ArrayLike<any>>(array: L extends readonly any[] ? never : L, values?: ArrayLike<L[0]>): L;
39
+ declare function pullAll<L extends MutableList<any>>(array: RejectReadonly<L>, values?: ArrayLike<L[0]>): L;
37
40
 
38
41
  export { pullAll };
@@ -1,3 +1,6 @@
1
+ import { MutableList } from '../_internal/MutableList.d.js';
2
+ import { RejectReadonly } from '../_internal/RejectReadonly.d.js';
3
+
1
4
  /**
2
5
  * This method is like `_.pull` except that it accepts an array of values to remove.
3
6
  *
@@ -22,8 +25,8 @@ declare function pullAll<T>(array: T[], values?: ArrayLike<T>): T[];
22
25
  * **Note:** Unlike `_.difference`, this method mutates `array`.
23
26
  *
24
27
  * @template L
25
- * @param {L} array - The array to modify.
26
- * @param {ArrayLike<L[0]>} [values] - The values to remove.
28
+ * @param {RejectReadonly<L>} array - The array to modify.
29
+ * @param {List<L[0]>} [values] - The values to remove.
27
30
  * @returns {L} Returns `array`.
28
31
  *
29
32
  * @example
@@ -33,6 +36,6 @@ declare function pullAll<T>(array: T[], values?: ArrayLike<T>): T[];
33
36
  * console.log(array);
34
37
  * // => [1, 1]
35
38
  */
36
- declare function pullAll<L extends ArrayLike<any>>(array: L extends readonly any[] ? never : L, values?: ArrayLike<L[0]>): L;
39
+ declare function pullAll<L extends MutableList<any>>(array: RejectReadonly<L>, values?: ArrayLike<L[0]>): L;
37
40
 
38
41
  export { pullAll };
@@ -1,3 +1,5 @@
1
+ import { MutableList } from '../_internal/MutableList.d.mjs';
2
+ import { RejectReadonly } from '../_internal/RejectReadonly.d.mjs';
1
3
  import { ValueIteratee } from '../_internal/ValueIteratee.mjs';
2
4
 
3
5
  /**
@@ -27,9 +29,9 @@ declare function pullAllBy<T>(array: T[], values?: ArrayLike<T>, iteratee?: Valu
27
29
  * If you want to remove values without modifying the original array, use `differenceBy`.
28
30
  *
29
31
  * @template L
30
- * @param {L} array - The array to modify.
32
+ * @param {RejectReadonly<L>} array - The array to modify.
31
33
  * @param {ArrayLike<L[0]>} [values] - The values to remove.
32
- * @param {((value: L[0]) => unknown) | PropertyKey | [PropertyKey, any] | Partial<L[0]>} [iteratee] - The iteratee invoked per element.
34
+ * @param {ValueIteratee<L[0]>} [iteratee] - The iteratee invoked per element.
33
35
  * @returns {L} Returns `array`.
34
36
  *
35
37
  * @example
@@ -39,7 +41,7 @@ declare function pullAllBy<T>(array: T[], values?: ArrayLike<T>, iteratee?: Valu
39
41
  * console.log(array);
40
42
  * // => [{ 'x': 2 }]
41
43
  */
42
- declare function pullAllBy<L extends ArrayLike<any>>(array: L extends readonly any[] ? never : L, values?: ArrayLike<L[0]>, iteratee?: ValueIteratee<L[0]>): L;
44
+ declare function pullAllBy<L extends MutableList<any>>(array: RejectReadonly<L>, values?: ArrayLike<L[0]>, iteratee?: ValueIteratee<L[0]>): L;
43
45
  /**
44
46
  * Removes all specified values from an array using an iteratee function.
45
47
  *
@@ -1,3 +1,5 @@
1
+ import { MutableList } from '../_internal/MutableList.d.js';
2
+ import { RejectReadonly } from '../_internal/RejectReadonly.d.js';
1
3
  import { ValueIteratee } from '../_internal/ValueIteratee.js';
2
4
 
3
5
  /**
@@ -27,9 +29,9 @@ declare function pullAllBy<T>(array: T[], values?: ArrayLike<T>, iteratee?: Valu
27
29
  * If you want to remove values without modifying the original array, use `differenceBy`.
28
30
  *
29
31
  * @template L
30
- * @param {L} array - The array to modify.
32
+ * @param {RejectReadonly<L>} array - The array to modify.
31
33
  * @param {ArrayLike<L[0]>} [values] - The values to remove.
32
- * @param {((value: L[0]) => unknown) | PropertyKey | [PropertyKey, any] | Partial<L[0]>} [iteratee] - The iteratee invoked per element.
34
+ * @param {ValueIteratee<L[0]>} [iteratee] - The iteratee invoked per element.
33
35
  * @returns {L} Returns `array`.
34
36
  *
35
37
  * @example
@@ -39,7 +41,7 @@ declare function pullAllBy<T>(array: T[], values?: ArrayLike<T>, iteratee?: Valu
39
41
  * console.log(array);
40
42
  * // => [{ 'x': 2 }]
41
43
  */
42
- declare function pullAllBy<L extends ArrayLike<any>>(array: L extends readonly any[] ? never : L, values?: ArrayLike<L[0]>, iteratee?: ValueIteratee<L[0]>): L;
44
+ declare function pullAllBy<L extends MutableList<any>>(array: RejectReadonly<L>, values?: ArrayLike<L[0]>, iteratee?: ValueIteratee<L[0]>): L;
43
45
  /**
44
46
  * Removes all specified values from an array using an iteratee function.
45
47
  *
@@ -1,3 +1,6 @@
1
+ import { MutableList } from '../_internal/MutableList.d.mjs';
2
+ import { RejectReadonly } from '../_internal/RejectReadonly.d.mjs';
3
+
1
4
  /**
2
5
  * This method is like `_.pullAll` except that it accepts `comparator` which is
3
6
  * invoked to compare elements of array to values. The comparator is invoked with
@@ -27,9 +30,9 @@ declare function pullAllWith<T>(array: T[], values?: ArrayLike<T>, comparator?:
27
30
  * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
28
31
  *
29
32
  * @template L
30
- * @param {L} array - The array to modify.
31
- * @param {ArrayLike<L[0]>} [values] - The values to remove.
32
- * @param {(a: L[0], b: L[0]) => boolean} [comparator] - The comparator invoked per element.
33
+ * @param {RejectReadonly<L>} array - The array to modify.
34
+ * @param {List<L[0]>} [values] - The values to remove.
35
+ * @param {Comparator<L[0]>} [comparator] - The comparator invoked per element.
33
36
  * @returns {L} Returns `array`.
34
37
  *
35
38
  * @example
@@ -39,7 +42,7 @@ declare function pullAllWith<T>(array: T[], values?: ArrayLike<T>, comparator?:
39
42
  * console.log(array);
40
43
  * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
41
44
  */
42
- declare function pullAllWith<L extends ArrayLike<any>>(array: L extends readonly any[] ? never : L, values?: ArrayLike<L[0]>, comparator?: (a: L[0], b: L[0]) => boolean): L;
45
+ declare function pullAllWith<L extends MutableList<any>>(array: RejectReadonly<L>, values?: ArrayLike<L[0]>, comparator?: (a: L[0], b: L[0]) => boolean): L;
43
46
  /**
44
47
  * This method is like `_.pullAll` except that it accepts `comparator` which is
45
48
  * invoked to compare elements of array to values. The comparator is invoked with
@@ -68,11 +71,11 @@ declare function pullAllWith<T, U>(array: T[], values: ArrayLike<U>, comparator:
68
71
  *
69
72
  * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
70
73
  *
71
- * @template L, U
72
- * @param {L} array - The array to modify.
73
- * @param {ArrayLike<U>} values - The values to remove.
74
- * @param {(a: L[0], b: U) => boolean} comparator - The comparator invoked per element.
75
- * @returns {L} Returns `array`.
74
+ * @template L1, L2
75
+ * @param {RejectReadonly<L1>} array - The array to modify.
76
+ * @param {List<L2>} values - The values to remove.
77
+ * @param {Comparator2<L1[0], L2>} comparator - The comparator invoked per element.
78
+ * @returns {L1} Returns `array`.
76
79
  *
77
80
  * @example
78
81
  * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
@@ -81,6 +84,6 @@ declare function pullAllWith<T, U>(array: T[], values: ArrayLike<U>, comparator:
81
84
  * console.log(array);
82
85
  * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
83
86
  */
84
- declare function pullAllWith<L extends ArrayLike<any>, U>(array: L extends readonly any[] ? never : L, values: ArrayLike<U>, comparator: (a: L[0], b: U) => boolean): L;
87
+ declare function pullAllWith<L1 extends MutableList<any>, L2>(array: RejectReadonly<L1>, values: ArrayLike<L2>, comparator: (a: L1[0], b: L2) => boolean): L1;
85
88
 
86
89
  export { pullAllWith };
@@ -1,3 +1,6 @@
1
+ import { MutableList } from '../_internal/MutableList.d.js';
2
+ import { RejectReadonly } from '../_internal/RejectReadonly.d.js';
3
+
1
4
  /**
2
5
  * This method is like `_.pullAll` except that it accepts `comparator` which is
3
6
  * invoked to compare elements of array to values. The comparator is invoked with
@@ -27,9 +30,9 @@ declare function pullAllWith<T>(array: T[], values?: ArrayLike<T>, comparator?:
27
30
  * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
28
31
  *
29
32
  * @template L
30
- * @param {L} array - The array to modify.
31
- * @param {ArrayLike<L[0]>} [values] - The values to remove.
32
- * @param {(a: L[0], b: L[0]) => boolean} [comparator] - The comparator invoked per element.
33
+ * @param {RejectReadonly<L>} array - The array to modify.
34
+ * @param {List<L[0]>} [values] - The values to remove.
35
+ * @param {Comparator<L[0]>} [comparator] - The comparator invoked per element.
33
36
  * @returns {L} Returns `array`.
34
37
  *
35
38
  * @example
@@ -39,7 +42,7 @@ declare function pullAllWith<T>(array: T[], values?: ArrayLike<T>, comparator?:
39
42
  * console.log(array);
40
43
  * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
41
44
  */
42
- declare function pullAllWith<L extends ArrayLike<any>>(array: L extends readonly any[] ? never : L, values?: ArrayLike<L[0]>, comparator?: (a: L[0], b: L[0]) => boolean): L;
45
+ declare function pullAllWith<L extends MutableList<any>>(array: RejectReadonly<L>, values?: ArrayLike<L[0]>, comparator?: (a: L[0], b: L[0]) => boolean): L;
43
46
  /**
44
47
  * This method is like `_.pullAll` except that it accepts `comparator` which is
45
48
  * invoked to compare elements of array to values. The comparator is invoked with
@@ -68,11 +71,11 @@ declare function pullAllWith<T, U>(array: T[], values: ArrayLike<U>, comparator:
68
71
  *
69
72
  * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
70
73
  *
71
- * @template L, U
72
- * @param {L} array - The array to modify.
73
- * @param {ArrayLike<U>} values - The values to remove.
74
- * @param {(a: L[0], b: U) => boolean} comparator - The comparator invoked per element.
75
- * @returns {L} Returns `array`.
74
+ * @template L1, L2
75
+ * @param {RejectReadonly<L1>} array - The array to modify.
76
+ * @param {List<L2>} values - The values to remove.
77
+ * @param {Comparator2<L1[0], L2>} comparator - The comparator invoked per element.
78
+ * @returns {L1} Returns `array`.
76
79
  *
77
80
  * @example
78
81
  * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
@@ -81,6 +84,6 @@ declare function pullAllWith<T, U>(array: T[], values: ArrayLike<U>, comparator:
81
84
  * console.log(array);
82
85
  * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
83
86
  */
84
- declare function pullAllWith<L extends ArrayLike<any>, U>(array: L extends readonly any[] ? never : L, values: ArrayLike<U>, comparator: (a: L[0], b: U) => boolean): L;
87
+ declare function pullAllWith<L1 extends MutableList<any>, L2>(array: RejectReadonly<L1>, values: ArrayLike<L2>, comparator: (a: L1[0], b: L2) => boolean): L1;
85
88
 
86
89
  export { pullAllWith };
@@ -1,4 +1,6 @@
1
1
  import { Many } from '../_internal/Many.mjs';
2
+ import { MutableList } from '../_internal/MutableList.d.mjs';
3
+ import { RejectReadonly } from '../_internal/RejectReadonly.d.mjs';
2
4
 
3
5
  /**
4
6
  * Removes elements from array corresponding to the given indexes and returns an array of the removed elements.
@@ -43,6 +45,6 @@ declare function pullAt<T>(array: T[], ...indexes: Array<Many<number>>): T[];
43
45
  * console.log(evens);
44
46
  * // => [10, 20]
45
47
  */
46
- declare function pullAt<L extends ArrayLike<any>>(array: L extends readonly any[] ? never : L, ...indexes: Array<Many<number>>): L;
48
+ declare function pullAt<L extends MutableList<any>>(array: RejectReadonly<L>, ...indexes: Array<Many<number>>): L;
47
49
 
48
50
  export { pullAt };
@@ -1,4 +1,6 @@
1
1
  import { Many } from '../_internal/Many.js';
2
+ import { MutableList } from '../_internal/MutableList.d.js';
3
+ import { RejectReadonly } from '../_internal/RejectReadonly.d.js';
2
4
 
3
5
  /**
4
6
  * Removes elements from array corresponding to the given indexes and returns an array of the removed elements.
@@ -43,6 +45,6 @@ declare function pullAt<T>(array: T[], ...indexes: Array<Many<number>>): T[];
43
45
  * console.log(evens);
44
46
  * // => [10, 20]
45
47
  */
46
- declare function pullAt<L extends ArrayLike<any>>(array: L extends readonly any[] ? never : L, ...indexes: Array<Many<number>>): L;
48
+ declare function pullAt<L extends MutableList<any>>(array: RejectReadonly<L>, ...indexes: Array<Many<number>>): L;
47
49
 
48
50
  export { pullAt };
@@ -1,10 +1,12 @@
1
1
  import { ListIteratee } from '../_internal/ListIteratee.mjs';
2
+ import { MutableList } from '../_internal/MutableList.d.mjs';
3
+ import { RejectReadonly } from '../_internal/RejectReadonly.d.mjs';
2
4
 
3
5
  /**
4
6
  * Removes all elements from array that predicate returns truthy for and returns an array of the removed elements.
5
7
  *
6
8
  * @template L
7
- * @param {L extends readonly any[] ? never : L} array - The array to modify.
9
+ * @param {RejectReadonly<L>} array - The array to modify.
8
10
  * @param {ListIteratee<L[0]>} [predicate] - The function invoked per iteration.
9
11
  * @returns {Array<L[0]>} Returns the new array of removed elements.
10
12
  *
@@ -14,6 +16,6 @@ import { ListIteratee } from '../_internal/ListIteratee.mjs';
14
16
  * console.log(array); // => [1, 3]
15
17
  * console.log(evens); // => [2, 4]
16
18
  */
17
- declare function remove<L extends ArrayLike<any>>(array: L extends readonly any[] ? never : L, predicate?: ListIteratee<L[0]>): Array<L[0]>;
19
+ declare function remove<L extends MutableList<any>>(array: RejectReadonly<L>, predicate?: ListIteratee<L[0]>): Array<L[0]>;
18
20
 
19
21
  export { remove };
@@ -1,10 +1,12 @@
1
1
  import { ListIteratee } from '../_internal/ListIteratee.js';
2
+ import { MutableList } from '../_internal/MutableList.d.js';
3
+ import { RejectReadonly } from '../_internal/RejectReadonly.d.js';
2
4
 
3
5
  /**
4
6
  * Removes all elements from array that predicate returns truthy for and returns an array of the removed elements.
5
7
  *
6
8
  * @template L
7
- * @param {L extends readonly any[] ? never : L} array - The array to modify.
9
+ * @param {RejectReadonly<L>} array - The array to modify.
8
10
  * @param {ListIteratee<L[0]>} [predicate] - The function invoked per iteration.
9
11
  * @returns {Array<L[0]>} Returns the new array of removed elements.
10
12
  *
@@ -14,6 +16,6 @@ import { ListIteratee } from '../_internal/ListIteratee.js';
14
16
  * console.log(array); // => [1, 3]
15
17
  * console.log(evens); // => [2, 4]
16
18
  */
17
- declare function remove<L extends ArrayLike<any>>(array: L extends readonly any[] ? never : L, predicate?: ListIteratee<L[0]>): Array<L[0]>;
19
+ declare function remove<L extends MutableList<any>>(array: RejectReadonly<L>, predicate?: ListIteratee<L[0]>): Array<L[0]>;
18
20
 
19
21
  export { remove };
@@ -1,3 +1,6 @@
1
+ import { MutableList } from '../_internal/MutableList.d.mjs';
2
+ import { RejectReadonly } from '../_internal/RejectReadonly.d.mjs';
3
+
1
4
  /**
2
5
  * Reverses `array` so that the first element becomes the last, the second element becomes the second to last, and so on.
3
6
  *
@@ -10,6 +13,6 @@
10
13
  * reverse(array);
11
14
  * // => [3, 2, 1]
12
15
  */
13
- declare function reverse<L extends ArrayLike<any>>(array: L extends readonly any[] ? never : L): L;
16
+ declare function reverse<L extends MutableList<any>>(array: RejectReadonly<L>): L;
14
17
 
15
18
  export { reverse };
@@ -1,3 +1,6 @@
1
+ import { MutableList } from '../_internal/MutableList.d.js';
2
+ import { RejectReadonly } from '../_internal/RejectReadonly.d.js';
3
+
1
4
  /**
2
5
  * Reverses `array` so that the first element becomes the last, the second element becomes the second to last, and so on.
3
6
  *
@@ -10,6 +13,6 @@
10
13
  * reverse(array);
11
14
  * // => [3, 2, 1]
12
15
  */
13
- declare function reverse<L extends ArrayLike<any>>(array: L extends readonly any[] ? never : L): L;
16
+ declare function reverse<L extends MutableList<any>>(array: RejectReadonly<L>): L;
14
17
 
15
18
  export { reverse };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "es-toolkit",
3
3
  "description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
4
- "version": "1.39.7-dev.1480+10a2afac",
4
+ "version": "1.39.7-dev.1482+58f53a77",
5
5
  "homepage": "https://es-toolkit.dev",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {
@@ -286,7 +286,7 @@
286
286
  "@types/broken-link-checker": "^0",
287
287
  "@types/eslint": "^9",
288
288
  "@types/jscodeshift": "^0.12.0",
289
- "@types/lodash": "^4.17.18",
289
+ "@types/lodash": "^4.17.20",
290
290
  "@types/node": "^22.7.4",
291
291
  "@types/tar": "^6.1.13",
292
292
  "@typescript-eslint/parser": "^8.26.1",
@@ -0,0 +1 @@
1
+ export type Equals<T, U> = (<X>() => X extends T ? 1 : 2) extends <X>() => X extends U ? 1 : 2 ? true : false;
@@ -0,0 +1 @@
1
+ export type IsWritable<T> = Equals<{ [K in keyof T]: T[K] }, { -readonly [K in keyof T]: T[K] }>;
@@ -0,0 +1,4 @@
1
+ export interface MutableList<T> {
2
+ length: number;
3
+ [k: number]: T;
4
+ }
@@ -0,0 +1,4 @@
1
+ import { IsWritable } from './IsWritable.d.ts';
2
+ import { MutableList } from './MutableList.d.ts';
3
+
4
+ export type RejectReadonly<T extends MutableList<unknown>> = IsWritable<T> extends true ? T : never;