shelving
Version:
Toolkit for using data in JavaScript.
80 lines (79 loc) • 4.65 kB
TypeScript
import type { ImmutableArray } from "./array.js";
import type { Match } from "./filter.js";
import type { AnyCaller } from "./function.js";
import type { ImmutableMap } from "./map.js";
import type { ImmutableObject } from "./object.js";
/** Assert two values are equal. */
export declare function assertEqual<T>(left: unknown, right: T, caller?: AnyCaller): asserts left is T;
/** Assert two values are equal. */
export declare function assertNot<T, N>(left: T | N, right: N, caller?: AnyCaller): asserts left is T;
/** Is unknown value `left` exactly equal to `right`? */
export declare function isEqual<T>(left: unknown, right: T): left is T;
/** Is unknown value `left` not exactly equal to `right`? */
export declare function notEqual<T, N>(left: T | N, right: N): left is T;
/** Is unknown value `left` less than `right`? */
export declare function isLess(left: unknown, right: unknown): boolean;
/** Is unknown value `left` less than or equal to `right`? */
export declare function isEqualLess(left: unknown, right: unknown): boolean;
/** Is unknown value `left` greater than `right`? */
export declare function isGreater(left: unknown, right: unknown): boolean;
/** Is unknown value `left` greater than or equal to `right`? */
export declare function isEqualGreater(left: unknown, right: unknown): boolean;
/**
* Are two unknown values shallowly equal?
* - If the values are both arrays/objects, see if the items/properties are **shallowly** equal with each other.
*/
export declare function isShallowEqual<T>(left: unknown, right: T): left is T;
/** Are two unknown values not shallowly equal? */
export declare function notShallowEqual<T>(left: unknown, right: T): left is T;
/**
* Are two unknown values deeply equal?
* - If the values are both arrays/objects, see if the items/properties are **deeply** equal with each other.
*/
export declare function isDeepEqual<T>(left: unknown, right: T): left is T;
/** Are two unknown values not deeply equal? */
export declare function notDeepEqual<T>(left: unknown, right: T): left is T;
/**
* Are two maps equal (based on their items).
*/
export declare function isMapEqual<T extends ImmutableMap>(left: ImmutableMap, right: T, recursor?: Match): left is T;
/**
* Are two arrays equal based on their items?
*
* @param recursor Function that checks each item of the array.
* - Defaults to `isEqual()` to check strict equality of the items.
* - Use `isDeepEqual()` as the recursor to check to check deep equality of the items.
*/
export declare function isArrayEqual<T extends ImmutableArray>(left: ImmutableArray, right: T, recursor?: Match): left is T;
/** Is unknown value `left` in array `right`? */
export declare function isInArray<R>(left: unknown, right: ImmutableArray<R>): left is R;
/** Is unknown value `left` not in array `right`? */
export declare function notInArray(left: unknown, right: ImmutableArray): boolean;
/** Is unknown value `left` an array including `right`? */
export declare function isArrayWith<T>(left: unknown, right: T): left is ImmutableArray<T>;
/** Is unknown value `left` not an array or does not include `right`? */
export declare function notArrayWith(left: unknown, right: unknown): boolean;
/**
* Are two objects equal based on their own props?
* - `left` must have every property present in `right`
* - `left` must not have excess properties not present in `right`
*
* @param recursor Function that checks each prop of the object.
* - Defaults to `isEqual()` to check strict equality of the properties.
* - Use `isDeepEqual()` as the recursor to check to check deep equality of the properties.
*/
export declare function isObjectEqual<T extends ImmutableObject>(left: ImmutableObject, right: T, recursor?: Match): left is T;
/**
* Are two objects partially equal based on their own props?
* - `left` must have every property present in `right`
* - `left` may have have excess properties not present in `right`
*
* @param recursor Function that checks each prop of the object.
* - Defaults to `isEqual()` to check strict equality of the properties.
* - Use `isDeepEqual()` as the recursor to check to check deep equality of the properties.
*/
export declare function isObjectMatch<L extends ImmutableObject, R extends ImmutableObject>(left: L | R, right: R, recursor?: Match): left is L & R;
/** Is unknown value `left` an object with every prop from `right`? */
export declare function isObjectWith(left: unknown, right: ImmutableObject): boolean;
/** Is unknown value `left` not an object or missing one or more props from `right`? */
export declare function notObjectWith(left: unknown, right: ImmutableObject): boolean;