1 | import { Option, PresentArray } from '@glimmer/interfaces';
|
2 | export interface OptionalList<T> {
|
3 | map<U>(callback: (input: T) => U): MapList<T, U, AnyOptionalList<T>>;
|
4 | filter<S extends T>(predicate: (value: T, index: number, array: T[]) => value is S): AnyOptionalList<S>;
|
5 | toArray(): T[];
|
6 | toPresentArray(): Option<PresentArray<T>>;
|
7 | into<U, V>(options: {
|
8 | ifPresent: (array: PresentList<T>) => U;
|
9 | ifEmpty: () => V;
|
10 | }): U | V;
|
11 | }
|
12 | export declare class PresentList<T> implements OptionalList<T> {
|
13 | readonly list: PresentArray<T>;
|
14 | constructor(list: PresentArray<T>);
|
15 | toArray(): PresentArray<T>;
|
16 | map<U>(callback: (input: T) => U): MapList<T, U, PresentList<T>>;
|
17 | filter<S extends T>(predicate: (value: T) => value is S): AnyOptionalList<S>;
|
18 | toPresentArray(): PresentArray<T>;
|
19 | into<U, V>({ ifPresent }: {
|
20 | ifPresent: (array: PresentList<T>) => U;
|
21 | ifEmpty: () => V;
|
22 | }): U | V;
|
23 | }
|
24 | export declare class EmptyList<T> implements OptionalList<T> {
|
25 | readonly list: T[];
|
26 | map<U>(_callback: (input: T) => U): MapList<T, U, EmptyList<T>>;
|
27 | filter<S extends T>(_predicate: (value: T) => value is S): AnyOptionalList<S>;
|
28 | toArray(): T[];
|
29 | toPresentArray(): Option<PresentArray<T>>;
|
30 | into<U, V>({ ifEmpty }: {
|
31 | ifPresent: (array: PresentList<T>) => U;
|
32 | ifEmpty: () => V;
|
33 | }): U | V;
|
34 | }
|
35 | export declare function OptionalList<T>(value: readonly T[]): AnyOptionalList<T>;
|
36 | export declare type AnyOptionalList<T> = (PresentList<T> | EmptyList<T>) & OptionalList<T>;
|
37 | export declare type MapList<T, U, L extends OptionalList<T>> = L extends PresentList<T> ? PresentList<U> : L extends EmptyList<T> ? EmptyList<U> : never;
|
38 | //# sourceMappingURL=list.d.ts.map |
\ | No newline at end of file |