@nostr-fetch/kernel
Version:
Kernel of nostr-fetch
38 lines • 1.29 kB
TypeScript
/**
* Current unxitime in milliseconds.
*/
export declare const currUnixtimeMilli: (now?: Date) => number;
/**
* Current unixtime in seconds.
*/
export declare const currUnixtimeSec: (now?: Date) => number;
/**
* Normalizes single URL of relay (WebSocket endpoint).
* @param urlStr
* @returns
*/
export declare const normalizeRelayUrl: (urlStr: string) => string;
/**
* Normalizes all relay URLs, then removes duplications.
*
* It also filters out malformed URLs.
*/
export declare const normalizeRelayUrlSet: (relayUrls: string[]) => string[];
/**
* Empty AsyncGenerator
*/
export declare function emptyAsyncGen(): AsyncGenerator<never, void, unknown>;
/**
* Abbreviates strings as:
* <first `affixLen` chars of `s`> + ":" + <last `affixLen` chars of `s`>
*
* if `s.length` is less than `affixLen * 2` or `affixLen` is not positive, just returns original string.
*/
export declare const abbreviate: (s: string, affixLen: number) => string;
/**
* Attaches timeout to the `promise`.
*
* If the `promise` is not settled by the time limit, returned promise rejects with the error which has the specified message.
*/
export declare const withTimeout: <T>(promise: Promise<T>, timeoutMs: number, msgOnTimeout: string) => Promise<T>;
//# sourceMappingURL=utils.d.ts.map