UNPKG

typedash

Version:

modern, type-safe collection of utility functions

22 lines (20 loc) 622 B
import { t as castArrayIfDefined } from "./castArrayIfDefined-D6hpDsFW.js"; //#region src/functions/castArray/castArray.ts /** * Implementation for all overloads. * @param value The input value to cast to an array. * @returns An array containing the input value, or the input value itself if it is already an array. * @example * ```ts * castArray('foo'); // ['foo'] * castArray(['foo']); // ['foo'] * castArray(null); // [] * castArray(undefined); // [] * ``` */ function castArray(value) { return castArrayIfDefined(value ?? []); } //#endregion export { castArray as t }; //# sourceMappingURL=castArray-BlJadbg0.js.map