import type { DataStream, DataType } from '../data-module/types'; import type { DurationViewport, HistoricalViewport, Viewport } from '../data-module/data-cache/requestTypes'; /** * Predicate Utilities * * A place for generic predicates. Useful when needing predicates which play nicely * with typescript, or other non-trivial predicate logic. * * Providing smart predicates with built in type guards can give us stronger typing in our business logic. * https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types * * Example: * * Without Type Guards (to be avoided): * ``` * const maybeItems : (Item | null)[] = SOME_MAYBE_ITEMS; * const items: Item[] = maybeItems.filter(x => x != null) as Item[]; * ``` * * With Type Guards: * ``` * const maybeItems : (Item | null)[] = SOME_MAYBE_ITEMS; * const items: Item[] = maybeItems.filter(isDefined); * ``` * * No type casting necessary :-) all you have to do is trust that the shared predicate properly * type guards. * */ export declare const isDefined: (value: T | null | undefined) => value is T; export declare const isValid: (predicate: (t: Partial) => boolean) => (t: Partial) => t is T; export declare const isSupportedDataType: (supportsString: boolean) => ({ dataType }: { dataType: DataType; }) => boolean; export declare const isNumberDataStream: (stream: DataStream) => stream is DataStream; export declare const isNumber: (val: T | number) => val is number; export declare const isHistoricalViewport: (viewport: Viewport) => viewport is HistoricalViewport; export declare const isDurationViewport: (viewport: Viewport) => viewport is DurationViewport; //# sourceMappingURL=predicates.d.ts.map