/// /// import type { POJO, FileSystem, Timer, PromiseDeconstructed, Callback } from '../types.js'; import type { ContextTimedInput } from '@matrixai/contexts'; import { PromiseCancellable } from '@matrixai/async-cancellable'; declare const AsyncFunction: Function; declare const GeneratorFunction: Function; declare const AsyncGeneratorFunction: Function; declare function getDefaultNodePath(): string | undefined; declare function never(message: string): never; declare function mkdirExists(fs: FileSystem, path: any, ...args: any[]): Promise; /** * Checks if a directory is empty * If the path does not exist, also returns true */ declare function dirEmpty(fs: FileSystem, path: any): Promise; /** * Test whether a path includes another path * This will return true when path 1 is the same as path 2 */ declare function pathIncludes(p1: string, p2: string): boolean; declare function sleep(ms: number): Promise; declare function sleepCancellable(ms: number): PromiseCancellable; /** * Checks if value is an object. * Arrays are also considered objects. * At that point `'x' in o` checks become type guards that * can assert the property's existence. */ declare function isObject(o: unknown): o is object; declare function isEmptyObject(o: any): boolean; /** * Filters out all undefined properties recursively */ declare function filterEmptyObject(o: any): any; declare function filterObject, K extends string, V>(obj: T, f: (element: [K, V], index: number, arr: Array<[K, V]>) => boolean): Partial; /** * Merges an input object to a default object. */ declare function mergeObjects(object1: POJO, object2: POJO): POJO; declare function getUnixtime(date?: Date): number; /** * Poll execution and use condition to accept or reject the results */ declare function poll(f: () => T | PromiseLike, condition: { (e: E, result?: undefined): boolean; (e: null, result: T): boolean; }, interval?: number, ctx?: Partial): PromiseCancellable; /** * Convert callback-style to promise-style * If this is applied to overloaded function * it will only choose one of the function signatures to use */ declare function promisify, P extends Array, R extends T extends [] ? void : T extends [unknown] ? T[0] : T>(f: (...args: [...params: P, callback: Callback]) => unknown): (...params: P) => Promise; /** * Deconstructed promise */ declare function promise(): PromiseDeconstructed; /** * Promise constructed from signal * This rejects when the signal is aborted */ declare function signalPromise(signal: AbortSignal): PromiseCancellable; declare function timerStart(timeout: number): Timer; declare function timerStop(timer: Timer): void; declare function arraySet(items: Array, item: T): void; declare function arrayUnset(items: Array, item: T): void; declare function arrayZip(a: Array, b: Array): Array<[T1, T2]>; declare function arrayZipWithPadding(a: Array, b: Array): Array<[T1 | undefined, T2 | undefined]>; declare function asyncIterableArray(iterable: AsyncIterable): Promise>; declare function bufferSplit(input: Buffer, delimiter?: Buffer, limit?: number, remaining?: boolean): Array; /** * Zero-copy wraps ArrayBuffer-like objects into Buffer * This supports ArrayBuffer, TypedArrays and the NodeJS Buffer */ declare function bufferWrap(array: BufferSource, offset?: number, length?: number): Buffer; /** * Checks if data is an ArrayBuffer-like object * This includes ArrayBuffer, TypedArrays and the NodeJS Buffer */ declare function isBufferSource(data: unknown): data is BufferSource; declare function debounce

(f: (...params: P) => any, timeout?: number): (...param: P) => void; declare function isPromise(v: any): v is Promise; declare function isPromiseLike(v: any): v is PromiseLike; /** * Is generator object * Use this to check for generators */ declare function isGenerator(v: any): v is Generator; /** * Is async generator object * Use this to check for async generators */ declare function isAsyncGenerator(v: any): v is AsyncGenerator; /** * Encodes whole numbers (inc of 0) to lexicographic buffers */ declare function lexiPackBuffer(n: number): Buffer; /** * Decodes lexicographic buffers to whole numbers (inc of 0) */ declare function lexiUnpackBuffer(b: Buffer): number; /** * Used to yield to the event loop to allow other micro tasks to process */ declare function yieldMicro(): Promise; /** * Increases the total number of registered event handlers before a node warning is emitted. * In most cases this is not needed but in the case where you have one event emitter for multiple handlers you'll need * to increase the limit. * @param target - The specific `EventTarget` or `EventEmitter` to increase the warning for. * @param limit - The limit before the warning is emitted, defaults to 100000. */ declare function setMaxListeners(target: EventTarget | NodeJS.EventEmitter, limit?: number): void; declare function importFS(fs?: FileSystem): Promise; /** * Races a promise against a context. If the context is aborted, then the promise * rejects with the reason. Otherwise, the original value is returned upon * resolving. * @param prom The promise to resolve * @param ctx The ctx with which to race the promise against * @returns A promise which resolves to the prom value or errors if ctx aborts */ declare function raceSignal(prom: Promise, abortSignal: AbortSignal): Promise; export { AsyncFunction, GeneratorFunction, AsyncGeneratorFunction, getDefaultNodePath, never, mkdirExists, dirEmpty, pathIncludes, sleep, sleepCancellable, isObject, isEmptyObject, filterEmptyObject, filterObject, mergeObjects, getUnixtime, poll, promisify, promise, signalPromise, timerStart, timerStop, arraySet, arrayUnset, arrayZip, arrayZipWithPadding, asyncIterableArray, bufferSplit, debounce, isPromise, isPromiseLike, isGenerator, isAsyncGenerator, lexiPackBuffer, lexiUnpackBuffer, bufferWrap, isBufferSource, yieldMicro, setMaxListeners, importFS, raceSignal, };