UNPKG

798 BPlain TextView Raw
1// (C) 2007-2020 GoodData Corporation
2import { IGuidColorItem, IRGBColorItem, IColorItem } from "./interfaces";
3import { ApiExecutionResponseError } from "./execution/execute-afm";
4
5const isValidColorItem = (value: IColorItem | undefined | null): value is IColorItem =>
6 !!(value && value.type && value.value !== undefined);
7
8export const isGuidColorItem = (color: IColorItem | undefined | null): color is IGuidColorItem =>
9 isValidColorItem(color) && color.type === "guid";
10export const isRgbColorItem = (color: IColorItem | undefined | null): color is IRGBColorItem =>
11 isValidColorItem(color) && color.type === "rgb";
12
13export function isApiExecutionResponseError(error: Error): error is ApiExecutionResponseError {
14 return !!(error as ApiExecutionResponseError).executionResponse;
15}