diginext-utils
Version:
README.md
20 lines • 581 B
TypeScript
/**
* Converts a value to an array.
* If the value is already an array, returns it as-is.
* If the value is null/undefined, returns an empty array.
* Otherwise, wraps the value in an array.
*
* @template T - The type of the value
* @param value - The value to convert
* @returns An array containing the value
*
* @example
* ```ts
* toArray(5); // [5]
* toArray([1, 2, 3]); // [1, 2, 3]
* toArray(null); // []
* toArray('hello'); // ['hello']
* ```
*/
export declare function toArray<T>(value: T | T[] | null | undefined): T[];
//# sourceMappingURL=toArray.d.ts.map