es-toolkit 1.19.0-dev.606 → 1.19.0-dev.607
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/initial.d.mts +41 -13
- package/dist/array/initial.d.ts +41 -13
- package/dist/browser.global.js.map +1 -1
- package/package.json +1 -1
package/dist/array/initial.d.mts
CHANGED
|
@@ -1,25 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns an empty array when the input is a tuple containing exactly one element.
|
|
3
|
+
*
|
|
4
|
+
* @template T The type of the single element.
|
|
5
|
+
* @param {[T]} arr - A tuple containing exactly one element.
|
|
6
|
+
* @returns {[]} An empty array since there is only one element.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const array = [100] as const;
|
|
10
|
+
* const result = initial(array);
|
|
11
|
+
* // result will be []
|
|
12
|
+
*/
|
|
13
|
+
declare function initial<T>(arr: readonly [T]): [];
|
|
14
|
+
/**
|
|
15
|
+
* Returns an empty array when the input array is empty.
|
|
16
|
+
*
|
|
17
|
+
* @returns {[]} Always returns an empty array for an empty input.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* const array = [] as const;
|
|
21
|
+
* const result = initial(array);
|
|
22
|
+
* // result will be []
|
|
23
|
+
*/
|
|
24
|
+
declare function initial(arr: readonly []): [];
|
|
25
|
+
/**
|
|
26
|
+
* Returns a new array containing all elements except the last one from a tuple with multiple elements.
|
|
27
|
+
*
|
|
28
|
+
* @template T The types of the initial elements.
|
|
29
|
+
* @template U The type of the last element in the tuple.
|
|
30
|
+
* @param {[...T[], U]} arr - A tuple with one or more elements.
|
|
31
|
+
* @returns {T[]} A new array containing all but the last element of the tuple.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* const array = ['apple', 'banana', 'cherry'] as const;
|
|
35
|
+
* const result = initial(array);
|
|
36
|
+
* // result will be ['apple', 'banana']
|
|
37
|
+
*/
|
|
38
|
+
declare function initial<T, U>(arr: readonly [...T[], U]): T[];
|
|
1
39
|
/**
|
|
2
40
|
* Returns a new array containing all elements except the last one from the input array.
|
|
3
41
|
* If the input array is empty or has only one element, the function returns an empty array.
|
|
4
42
|
*
|
|
5
43
|
* @template T The type of elements in the array.
|
|
6
|
-
* @param {T[]} arr - The input array
|
|
44
|
+
* @param {T[]} arr - The input array.
|
|
7
45
|
* @returns {T[]} A new array containing all but the last element of the input array.
|
|
8
46
|
*
|
|
9
47
|
* @example
|
|
10
48
|
* const arr = [1, 2, 3, 4];
|
|
11
|
-
* const
|
|
12
|
-
* //
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* const emptyArr: number[] = [];
|
|
16
|
-
* const newEmptyArr = initial(emptyArr);
|
|
17
|
-
* // newEmptyArr will be []
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* const singleElementArr = ['only one'];
|
|
21
|
-
* const newSingleElementArr = initial(singleElementArr);
|
|
22
|
-
* // newSingleElementArr will be []
|
|
49
|
+
* const result = initial(arr);
|
|
50
|
+
* // result will be [1, 2, 3]
|
|
23
51
|
*/
|
|
24
52
|
declare function initial<T>(arr: readonly T[]): T[];
|
|
25
53
|
|
package/dist/array/initial.d.ts
CHANGED
|
@@ -1,25 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns an empty array when the input is a tuple containing exactly one element.
|
|
3
|
+
*
|
|
4
|
+
* @template T The type of the single element.
|
|
5
|
+
* @param {[T]} arr - A tuple containing exactly one element.
|
|
6
|
+
* @returns {[]} An empty array since there is only one element.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const array = [100] as const;
|
|
10
|
+
* const result = initial(array);
|
|
11
|
+
* // result will be []
|
|
12
|
+
*/
|
|
13
|
+
declare function initial<T>(arr: readonly [T]): [];
|
|
14
|
+
/**
|
|
15
|
+
* Returns an empty array when the input array is empty.
|
|
16
|
+
*
|
|
17
|
+
* @returns {[]} Always returns an empty array for an empty input.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* const array = [] as const;
|
|
21
|
+
* const result = initial(array);
|
|
22
|
+
* // result will be []
|
|
23
|
+
*/
|
|
24
|
+
declare function initial(arr: readonly []): [];
|
|
25
|
+
/**
|
|
26
|
+
* Returns a new array containing all elements except the last one from a tuple with multiple elements.
|
|
27
|
+
*
|
|
28
|
+
* @template T The types of the initial elements.
|
|
29
|
+
* @template U The type of the last element in the tuple.
|
|
30
|
+
* @param {[...T[], U]} arr - A tuple with one or more elements.
|
|
31
|
+
* @returns {T[]} A new array containing all but the last element of the tuple.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* const array = ['apple', 'banana', 'cherry'] as const;
|
|
35
|
+
* const result = initial(array);
|
|
36
|
+
* // result will be ['apple', 'banana']
|
|
37
|
+
*/
|
|
38
|
+
declare function initial<T, U>(arr: readonly [...T[], U]): T[];
|
|
1
39
|
/**
|
|
2
40
|
* Returns a new array containing all elements except the last one from the input array.
|
|
3
41
|
* If the input array is empty or has only one element, the function returns an empty array.
|
|
4
42
|
*
|
|
5
43
|
* @template T The type of elements in the array.
|
|
6
|
-
* @param {T[]} arr - The input array
|
|
44
|
+
* @param {T[]} arr - The input array.
|
|
7
45
|
* @returns {T[]} A new array containing all but the last element of the input array.
|
|
8
46
|
*
|
|
9
47
|
* @example
|
|
10
48
|
* const arr = [1, 2, 3, 4];
|
|
11
|
-
* const
|
|
12
|
-
* //
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* const emptyArr: number[] = [];
|
|
16
|
-
* const newEmptyArr = initial(emptyArr);
|
|
17
|
-
* // newEmptyArr will be []
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* const singleElementArr = ['only one'];
|
|
21
|
-
* const newSingleElementArr = initial(singleElementArr);
|
|
22
|
-
* // newSingleElementArr will be []
|
|
49
|
+
* const result = initial(arr);
|
|
50
|
+
* // result will be [1, 2, 3]
|
|
23
51
|
*/
|
|
24
52
|
declare function initial<T>(arr: readonly T[]): T[];
|
|
25
53
|
|