diff --git a/src/system/array.ts b/src/system/array.ts index c20ffda..0e3e947 100644 --- a/src/system/array.ts +++ b/src/system/array.ts @@ -30,6 +30,10 @@ export function countUniques(source: T[], accessor: (item: T) => string): Rec return uniqueCounts; } +export function ensure(source: T | T[] | undefined): T[] | undefined { + return source == null ? undefined : Array.isArray(source) ? source : [source]; +} + export function filterMap( source: T[], predicateMapper: (item: T, index: number) => TMapped | null | undefined,