/** * A no-operation function. */ declare const NOOP: () => void; /** * A function that always returns `false`. */ declare const FALSE: () => false; /** * A function that always returns `true`. */ declare const TRUE: () => false; /** * Equivalent of `Object.prototype.toString.call(value)` * * @alias {@link Object.prototype.toString.call} */ declare const toString: (value: unknown) => string; /** * Equivalent of `Object.prototype.hasOwnProperty.call(value, key)` * * @alias {@link Object.prototype.hasOwnProperty.call} */ declare const hasOwnProperty: (value: unknown, key: PropertyKey) => boolean; /** * Equivalent of `Object.prototype.isPrototypeOf.call(value, obj)` * * @alias {@link Object.prototype.isPrototypeOf.call} */ declare const isPrototypeOf: (obj: unknown, value: unknown) => boolean; /** * Equivalent of `{}.propertyIsEnumerable.call(value, key)` * * @alias {@link Object.prototype.propertyIsEnumerable.call} */ declare const propertyIsEnumerable: (value: unknown, key: PropertyKey) => boolean; /** * Check if the value is `T`. * * @alias {@link Object.is} */ declare const is: (value: unknown, type: T) => value is T; /** * @alias {@link Object.values} */ declare const values: { (o: { [s: string]: T; } | ArrayLike): T[]; (o: {}): any[]; }; /** * @alias {@link Object.entries} */ declare const entries: { (o: { [s: string]: T; } | ArrayLike): [string, T][]; (o: {}): [string, any][]; }; /** * Check if the value is `T[]`. * * @alias {@link Array.isArray} */ declare const isArray: (value: unknown) => value is T[]; /** * Check if the value is an integer `number`. * * @alias {@link Number.isInteger} */ declare const isInteger: (value: unknown) => value is number; /** * Check if the value is a safe integer `number`. * * @alias {@link Number.isSafeInteger} */ declare const isSafeInteger: (value: unknown) => value is number; /** * Check if the value is a finite `number`. * * @alias {@link Number.isFinite} */ declare const isFinite: (value: unknown) => value is number; /** * Check if the value is `NaN`. * * @alias {@link Number.isNaN} */ declare const isNaN: (value: unknown) => value is number; /** * ## Note: * This function throws {@link TypeError} when: * - The argument is a {@link Symbol}. * - The argument is a `object` without [{@link Symbol.toPrimitive}], {@link Object.valueOf} or {@link Object.toString}. * - Resolving a primitive either throw or return a non primitive value. * * @alias {@link Number.parseInt} */ declare const parseInt: (value: unknown, radix?: number | undefined) => number; /** * ## Note: * This function throws {@link TypeError} when: * - The argument is a {@link Symbol}. * - The argument is a `object` without [{@link Symbol.toPrimitive}], {@link Object.valueOf} or {@link Object.toString}. * - Resolving a primitive either throw or return a non primitive value. * * @alias {@link Number.parseFloat} */ declare const parseFloat: (value: unknown, radix?: number | undefined) => number; declare function isInfinity(value: unknown): value is number; declare function isPositiveInfinity(value: unknown): value is number; declare function isNegativeInfinity(value: unknown): value is number; declare function isZero(value: unknown): value is 0; declare function isNegativeZero(value: unknown): value is -0; /** * Check if the value is a `symbol`. */ declare function isSymbol(value: unknown): value is symbol; /** * Check if the value is a `string`. */ declare function isString(value: unknown): value is string; /** * Check if the value type is a `number`, {@link Infinity} and {@link NaN} are considered numbers. */ declare function isNumber(value: unknown): value is number; /** * Check if the value is a finite `number`. * * Note: to check for `typeof value === 'number'`, use {@link isNumberType}. * * _This function uses {@link isFinite}_ */ declare function isFiniteNumber(value: unknown): value is number; /** * Coerce a type to valid finite numeric string or number (`number` | `string`). * * _This function uses {@link isFinite}, {@link parseFloat}_ */ declare function isNumeric(val: unknown): val is number | string; /** * Check if the value is a `function`. */ declare function isFunction unknown>(value: unknown): value is T; /** * Check if the value is a **non null** `object`. */ declare function isObject>(value: unknown): value is T; declare function isPlainObject(value: unknown): value is object; /** * Check if the value is a {@link Date}. */ declare function isDate(value: unknown): value is Date; /** * Check if the value is a finite {@link Date}. * * _This function uses {@link isFinite}_ */ declare function isFiniteDate(value: unknown): value is Date; /** * Check if the value is a `Promise` instance. */ declare function isPromise(value: unknown): value is Promise; /** * Check if the value is a `PromiseLike`. */ declare function isPromiseLike(value: unknown): value is PromiseLike; /** * Alias of isPromiseLike */ declare function isAwaitable(value: unknown): value is PromiseLike; /** * Check if the value is an `AsyncIterable`. */ declare function isAsyncIterable(value: unknown): value is AsyncIterable; /** * Returns a boolean indicating whether or not an absolute URL, or a relative URL combined with a base URL, are parsable and valid. */ declare function canParseUrl(url: string | URL, base?: string | URL): boolean; declare function asUrl(url: unknown, base?: unknown): URL | null; declare function asUrlString(value: unknown, base?: unknown): string | null; /** * Coerce the value. * * _This function uses {@link parseInt}, {@link isSafeInteger}_ */ declare function asSafeInteger(value: unknown): number | undefined; /** * Coerce the value. * * _This function uses {@link parseFloat}, {@link isFinite}_ */ declare function asNumber(value: unknown): number | undefined; /** * Coerce the value. * * - On `undefined` or `null`, returns an empty string `""` * - On `typeof value === 'string'`, returns `value` * - On a {@link isFinite} number, returns the finite number as a string * - On a **non** finite number, returns an empty string `""` * * _This function uses {@link isFinite}_ * * ### Note * * This function is not a replacement for `String()` */ declare function asString(value: unknown): string; /** * Coerce the value. * * _This function uses {@link isArray}_ */ declare function asArray(value: unknown): T[]; /** * Coerce the value. * * _This function uses {@link isObject}_ */ declare function asObject>(value: unknown): T | undefined; /** * Coerce the value. * * _This function uses {@link isFunction}_ */ declare function asFunction unknown>(value: unknown): T | undefined; declare function sleep(timeout: number): Promise; declare function timeout(timeout: number): Promise; declare function hasMethod(value: unknown, method: PropertyKey): value is object; /** * Represents a deferred promise. */ interface DeferredPromise { /** * The deferred promise, you can use this promise to await on the result. */ promise: Promise; /** * Invoke this function to resolve the promise. */ resolve: (value: T | PromiseLike) => void; /** * Invoke this function to reject the promise. */ reject: (reason?: any) => void; } /** * Defer a promise. * * #### Note * _This is an advanced hack, use it with extreme caution!_ */ declare function deferPromise(): DeferredPromise; /** * Represents an asynchronous operation that can be resolved or rejected. */ interface Task extends Promise { /** * Invoke this function to resolve the promise. */ resolve: (value: T | PromiseLike) => void; /** * Invoke this function to reject the promise. */ reject: (reason?: any) => void; } /** * Creates a {@link Task}. * * #### Note * _This is even a more advanced hack then {@link deferPromise}, use it with extreme caution!_ */ declare function task(): Task; declare function omitUndefined>(obj: T): { [K in keyof T as Exclude extends never ? never : K]: Exclude; }; declare function nonNullable(value: T): value is NonNullable; declare function nullo(): object; export { FALSE, NOOP, TRUE, asArray, asFunction, asNumber, asObject, asSafeInteger, asString, asUrl, asUrlString, canParseUrl, deferPromise, entries, hasMethod, hasOwnProperty, is, isArray, isAsyncIterable, isAwaitable, isDate, isFinite, isFiniteDate, isFiniteNumber, isFunction, isInfinity, isInteger, isNaN, isNegativeInfinity, isNegativeZero, isNumber, isNumeric, isObject, isPlainObject, isPositiveInfinity, isPromise, isPromiseLike, isPrototypeOf, isSafeInteger, isString, isSymbol, isZero, nonNullable, nullo, omitUndefined, parseFloat, parseInt, propertyIsEnumerable, sleep, task, timeout, toString, values }; export type { DeferredPromise, Task };