10 lines
180 B
TypeScript
10 lines
180 B
TypeScript
|
export function ensureArray<T>(val: unknown): T[] {
|
||
|
if (Array.isArray(val)) {
|
||
|
return val;
|
||
|
}
|
||
|
if (typeof val === "undefined") {
|
||
|
return [];
|
||
|
}
|
||
|
return [val] as T[];
|
||
|
}
|