source: node_modules/es-toolkit/dist/compat/array/castArray.d.mts@ a762898

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

Added visualizations

  • Property mode set to 100644
File size: 720 bytes
Line 
1/**
2 * Casts value as an array if it's not one.
3 *
4 * @template T The type of elements in the array.
5 * @param {T | T[]} value The value to be cast to an array.
6 * @returns {T[]} An array containing the input value if it wasn't an array, or the original array if it was.
7 *
8 * @example
9 * const arr1 = castArray(1);
10 * // Returns: [1]
11 *
12 * const arr2 = castArray([1]);
13 * // Returns: [1]
14 *
15 * const arr3 = castArray({'a': 1});
16 * // Returns: [{'a': 1}]
17 *
18 * const arr4 = castArray(null);
19 * // Returns: [null]
20 *
21 * const arr5 = castArray(undefined);
22 * // Returns: [undefined]
23 *
24 * const arr6 = castArray();
25 * // Returns: []
26 */
27declare function castArray<T>(value?: T | readonly T[]): T[];
28
29export { castArray };
Note: See TracBrowser for help on using the repository browser.