nhb-toolbox
Version:
A versatile collection of smart, efficient, and reusable utility functions, classes and types for everyday development needs.
86 lines (85 loc) • 3.57 kB
TypeScript
import type { FalsyPrimitive, NormalPrimitive, Primitive } from '../types/index';
/**
* * Type guard to check whether a value is a finite number (excluding `NaN` and `Infinity`).
* @param value - The value to test.
* @returns `true` if the value is a finite number; otherwise `false`.
*/
export declare function isNumber(value: unknown): value is number;
/**
* * Type guard to check if a value is a string.
* @param value - The value to check.
* @returns `true` if the value is a string, otherwise `false`.
*/
export declare function isString(value: unknown): value is string;
/**
* * Type guard to check if a value is an integer.
* @param value - The value to check.
* @returns `true` if the value is an integer, otherwise `false`.
*/
export declare function isInteger(value: unknown): value is number;
/**
* * Type guard to check if a value is a positive integer.
* @param value - The value to check.
* @returns `true` if the value is a positive integer, otherwise `false`.
*/
export declare function isPositiveInteger(value: unknown): value is number;
/**
* * Type guard to check if a value is a boolean.
* @param value - The value to check.
* @returns `true` if the value is a boolean, otherwise `false`.
*/
export declare function isBoolean(value: unknown): value is boolean;
/**
* * Type guard to check if a value is null.
* @param value - The value to check.
* @returns `true` if the value is null, otherwise `false`.
*/
export declare function isNull(value: unknown): value is null;
/**
* * Type guard to check if a value is undefined.
* @param value - The value to check.
* @returns `true` if the value is undefined, otherwise `false`.
*/
export declare function isUndefined(value: unknown): value is undefined;
/**
* * Type guard to check if a value is a symbol.
* @param value - The value to check.
* @returns `true` if the value is a symbol, otherwise `false`.
*/
export declare function isSymbol(value: unknown): value is symbol;
/**
* * Type guard to check if a value is a BigInt.
* @param value - The value to check.
* @returns `true` if the value is a BigInt, otherwise `false`.
*/
export declare function isBigInt(value: unknown): value is bigint;
/**
* * Type guard to check if a value is a primitive (i.e. `string | number | boolean | symbol | bigint | null | undefined`).
* @param value - The value to check.
* @returns `true` if the value is a primitive, otherwise `false`.
*/
export declare function isPrimitive(value: unknown): value is Primitive;
/**
* * Type guard to check if a value is a normal primitive (i.e. `string | number | boolean | null | undefined`).
* @param value - The value to check.
* @returns `true` if the value is a primitive, otherwise `false`.
*/
export declare function isNormalPrimitive(value: unknown): value is NormalPrimitive;
/**
* * Type guard to check if a value is a non-empty string.
* @param value - The value to check.
* @returns `true` if the value is a non-empty string, otherwise `false`.
*/
export declare function isNonEmptyString(value: unknown): value is string;
/**
* * Type guard to check if a value is falsy.
* @param value - The value to check.
* @returns `true` if the value is falsy, otherwise `false`.
*/
export declare function isFalsy(value: unknown): value is FalsyPrimitive;
/**
* * Type guard to check if a value is truthy.
* @param value - The value to check.
* @returns `true` if the value is truthy (not null or undefined), otherwise `false`.
*/
export declare function isTruthy<T>(value: T): value is Exclude<T, FalsyPrimitive>;