typedash
Version:
modern, type-safe collection of utility functions
17 lines (15 loc) • 637 B
JavaScript
import { t as isArray } from "./isArray-DkX32HVI.js";
//#region src/functions/castArrayIfDefined/castArrayIfDefined.ts
/**
* Implementation for all overloads.
* @param value The value to convert to an array if it's not already one.
* @returns An array containing the input value, or the input value itself if it is already an array, or `null` or `undefined` if the input value is `null` or `undefined`.
*/
function castArrayIfDefined(value) {
if (value == null) return value;
if (isArray(value)) return value;
return [value];
}
//#endregion
export { castArrayIfDefined as t };
//# sourceMappingURL=castArrayIfDefined-D6hpDsFW.js.map