source: node_modules/es-toolkit/dist/array/tail.d.mts

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/**
2 * Returns an empty array when the input is a single-element array.
3 *
4 * @template T - The type of the single element in the array.
5 * @param {[T]} arr - The single-element array to process.
6 * @returns {[]} An empty array.
7 *
8 * @example
9 * const arr = [1];
10 * const result = tail(arr);
11 * // result will be []
12 */
13declare function tail<T>(arr: readonly [T]): [];
14/**
15 * Returns an empty array when the input is an empty array.
16 *
17 * @template T - The type of elements in the array.
18 * @param {[]} arr - The empty array to process.
19 * @returns {[]} An empty array.
20 *
21 * @example
22 * const arr = [];
23 * const result = tail(arr);
24 * // result will be []
25 */
26declare function tail(arr: readonly []): [];
27/**
28 * Returns a new array with all elements except for the first when the input is a tuple array.
29 *
30 * @template T - The type of the first element in the tuple array.
31 * @template U - The type of the remaining elements in the tuple array.
32 * @param {[T, ...U[]]} arr - The tuple array to process.
33 * @returns {U[]} A new array containing all elements of the input array except for the first one.
34 *
35 * @example
36 * const arr = [1, 2, 3];
37 * const result = tail(arr);
38 * // result will be [2, 3]
39 */
40declare function tail<T, U>(arr: readonly [T, ...U[]]): U[];
41/**
42 * Returns a new array with all elements except for the first.
43 *
44 * This function takes an array and returns a new array containing all the elements
45 * except for the first one. If the input array is empty or has only one element,
46 * an empty array is returned.
47 *
48 * @template T - The type of elements in the array.
49 * @param {T[]} arr - The array to get the tail of.
50 * @returns {T[]} A new array containing all elements of the input array except for the first one.
51 *
52 * @example
53 * const arr1 = [1, 2, 3];
54 * const result = tail(arr1);
55 * // result will be [2, 3]
56 *
57 * const arr2 = [1];
58 * const result2 = tail(arr2);
59 * // result2 will be []
60 *
61 * const arr3 = [];
62 * const result3 = tail(arr3);
63 * // result3 will be []
64 */
65declare function tail<T>(arr: readonly T[]): T[];
66
67export { tail };
Note: See TracBrowser for help on using the repository browser.