UNPKG

@react-hive/honey-utils

Version:

A lightweight TypeScript utility library providing a collection of helper functions for common programming tasks

185 lines (184 loc) 5.38 kB
export declare function assert(condition: any, message: string): asserts condition; /** * Checks if a value is null. * * @param value - The value to check. * * @returns `true` if the value is null; otherwise, `false`. */ export declare const isNull: (value: unknown) => value is null; /** * Checks if a value is null or undefined. * * @param value - The value to check. * * @returns `true` if the value is `null` or `undefined`, otherwise `false`. */ export declare const isNil: (value: unknown) => value is null | undefined; /** * Checks whether the provided value is considered "empty". * * A value is considered empty if it is: * - `null` * - `undefined` * - `''` * * @param value - The value to check. * * @returns `true` if the value is empty; otherwise, `false`. */ export declare const isNilOrEmptyString: (value: unknown) => value is null | undefined; /** * Checks if a value is neither `null` nor `undefined`. * * @param value - The value to check. * * @returns `true` if the value is defined (not `null` or `undefined`); otherwise, `false`. */ export declare const isDefined: <T>(value: T) => value is NonNullable<T>; /** * Checks if a value is a string. * * @param value - The value to check. * * @returns `true` if the value is a string; otherwise, `false`. */ export declare const isString: (value: unknown) => value is string; /** * Checks if a value is a number. * * @param value - The value to check. * * @returns `true` if the value is a number; otherwise, `false`. */ export declare const isNumber: (value: unknown) => value is number; /** * Checks if a value is a boolean. * * @param value - The value to check. * * @returns `true` if the value is a boolean; otherwise, `false`. */ export declare const isBool: (value: unknown) => value is boolean; /** * Checks if a value is an object. * * @param value - The value to check. * * @returns `true` if the value is an object; otherwise, `false`. */ export declare const isObject: (value: unknown) => value is object; /** * Checks if a value is an empty object (no own enumerable properties). * * @param value - The value to check. * * @returns `true` if the value is an empty object; otherwise, `false`. */ export declare const isEmptyObject: (value: unknown) => value is Record<string, never>; /** * Checks if a value is an array. * * @param value - The value to check. * * @returns `true` if the value is an array; otherwise, `false`. */ export declare const isArray: (value: unknown) => value is unknown[]; /** * Checks if a value is an empty array. * * @param value - The value to check. * * @returns `true` if the value is an empty array; otherwise, `false`. */ export declare const isEmptyArray: (value: unknown) => value is []; /** * Checks if a value is a function. * * @param value - The value to check. * * @returns `true` if the value is a function; otherwise, `false`. */ export declare const isFunction: (value: unknown) => value is Function; /** * Checks if a value is a Promise. * * @template T - The type of the value that the Promise resolves to. * * @param value - The value to check. * * @returns `true` if the value is a Promise; otherwise, `false`. */ export declare const isPromise: <T = unknown>(value: unknown) => value is Promise<T>; /** * Checks if a value is a Date object. * * @param value - The value to check. * * @returns `true` if the value is a Date object; otherwise, `false`. */ export declare const isDate: (value: unknown) => value is Date; /** * Checks if a value is a valid Date object (not Invalid Date). * * @param value - The value to check. * * @returns `true` if the value is a valid Date object; otherwise, `false`. */ export declare const isValidDate: (value: unknown) => value is Date; /** * Checks if a value is a RegExp object. * * @param value - The value to check. * * @returns `true` if the value is a RegExp object; otherwise, `false`. */ export declare const isRegExp: (value: unknown) => value is RegExp; /** * Checks if a value is a Map. * * @param value - The value to check. * * @returns `true` if the value is a Map; otherwise, `false`. */ export declare const isMap: (value: unknown) => value is Map<unknown, unknown>; /** * Checks if a value is a Set. * * @param value - The value to check. * * @returns `true` if the value is a Set; otherwise, `false`. */ export declare const isSet: (value: unknown) => value is Set<unknown>; /** * Checks if a value is a Symbol. * * @param value - The value to check. * * @returns `true` if the value is a Symbol; otherwise, `false`. */ export declare const isSymbol: (value: unknown) => value is symbol; /** * Checks if a value is undefined. * * @param value - The value to check. * * @returns `true` if the value is undefined; otherwise, `false`. */ export declare const isUndefined: (value: unknown) => value is undefined; /** * Checks if a value is a finite number. * * @param value - The value to check. * * @returns `true` if the value is a finite number; otherwise, `false`. */ export declare const isFiniteNumber: (value: unknown) => value is number; /** * Checks if a value is an integer. * * @param value - The value to check. * * @returns `true` if the value is an integer; otherwise, `false`. */ export declare const isInteger: (value: unknown) => value is number;