Browse Source

Adds array helper

main
Eric Amodio 3 years ago
parent
commit
0f27b62d0d
1 changed files with 4 additions and 0 deletions
  1. +4
    -0
      src/system/array.ts

+ 4
- 0
src/system/array.ts View File

@ -30,6 +30,10 @@ export function countUniques(source: T[], accessor: (item: T) => string): Rec
return uniqueCounts; return uniqueCounts;
} }
export function ensure<T>(source: T | T[] | undefined): T[] | undefined {
return source == null ? undefined : Array.isArray(source) ? source : [source];
}
export function filterMap<T, TMapped>( export function filterMap<T, TMapped>(
source: T[], source: T[],
predicateMapper: (item: T, index: number) => TMapped | null | undefined, predicateMapper: (item: T, index: number) => TMapped | null | undefined,

Loading…
Cancel
Save