json-schema-describes-subset
Version:
Tools for static JSON schema analysis, including functions to determine if one schema describes a subset of another or if a schema describes the empty set or to convert a schema to its disjunctive normal form (DNF).
15 lines (14 loc) • 1.16 kB
TypeScript
export declare function isNotNull<Type>(value: Type): value is Exclude<Type, null>;
export declare function isNonNullable<Type>(value: Type): value is NonNullable<Type>;
export declare function isArrayOf<ElementType>(isElementType: (element: unknown) => element is ElementType): (value: unknown) => value is ElementType[];
export declare function isNonArrayObject(value: unknown): value is Record<string, unknown>;
export declare function isRecordOf<ValueType>(isValueType: (value: unknown) => value is ValueType): (value: unknown) => value is Record<string, ValueType>;
export declare function isStringWithPrefix<const Prefix extends string>(prefix: Prefix): (string: unknown) => string is `${Prefix}${string}`;
export declare function isOneOf<const Type = never>(elements: readonly Type[]): (value: unknown) => value is Type;
/**
* Allows convenient narrowing on nullish or falsy values.
*
* @example
*/
export declare function throwError(error?: Error | string | undefined): never;
export declare function assertType<Type>(test: (value: unknown) => value is Type, error?: Error | string | ((value: unknown) => Error) | undefined): (value: unknown) => Type;