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).
89 lines (88 loc) • 2.35 kB
TypeScript
/**
* Returns whether the given value is (almost) zero.
*
*/
export declare function isCloseToZero(value: number): boolean;
/**
* Returns the (rounded) value if it is (almost) an integer. Otherwise returns
* `null`.
*
*/
export declare function assertInteger(value: number): number | null;
export declare function isInteger(value: number): boolean;
export declare function floor(value: number): number;
export declare function ceil(value: number): number;
/**
* Finds the greatest common divisor using the Euclidean algorithm
*
* @param a A non negative finite integer
*
* @param b Another non negative finite integer
*
* @returns The greatest common divisor of a and b
*
*/
export declare function gcd(a: number, b: number): number;
/**
* Finds the least common multiple
*
* @param a A non negative integer
*
* @param b Another non negative integer
*
* @returns The least common multiple of a and b
*
*/
export declare function lcm(a: number, b: number): number;
/**
* @param a A non negative real number
*
* @param b Another non negative real number
*
* @returns The non negative least common multiple of a and b
*
*/
export declare function nonNegativeRealLCM(a: number, b: number): number;
/**
* @param a A real number
*
* @param b Another real number
*
* @returns The non negative least common multiple of a and b
*
*/
export declare function realLCM(a: number, b: number): number;
export declare function multiRealLCM(...values: number[]): number | undefined;
export declare function isValidMultiple(multipleOf: number, minimum?: number, maximum?: number): (value: unknown) => value is number;
/**
* Finds the cardinality of
*
* ```
* { x |
* x ≥ `minimum` AND
* x ≤ `maximum` AND
* x is multiple of `multipleOf`
* }
* ```
*
*/
export declare function findMultipleOfCardinality(multipleOf: number, minimum: number, maximum: number): {
cardinality: number;
singleElement?: number | undefined;
};
/**
* Finds the cardinality of
*
* ```
* { x |
* x ≥ minimum AND
* x ≤ maximum AND
* (
* x is multiple of one of the values in multipleUnionOf OR
* x is one of the values in constUnion
* )
* }
* ```
*
*/
export declare function findMultipleOfUnionCardinality(minimum: number, maximum: number, multipleOfUnion: number[], constUnion: number[]): number;