//#region src/lib/Format.d.ts type TimestampFormat = 'date-only' | 'with-hour' | 'with-second' | 'relative'; type TimestampFormatOptions = { format?: TimestampFormat; /** * Omit suffixes from relative timestamps * @default false */ noSuffix?: boolean; }; declare function formatTimestamp(time: number | Date, { format, noSuffix }: TimestampFormatOptions): string; /** * Format an environment variable that should result in either true or false. * * @example * FOO=0 // false * FOO=false // false * FOO=abc // true */ declare function getEnvironmentFlag(variable: keyof typeof process.env): boolean; /** * Fetch an entry from the environment variables, throwing an error if it is not found. */ declare function requiredEnv(env: TKey): NonNullable; /** * Create an object of the provided environment variables, throwing an error if any are not found. * @param environmentVariables */ declare function requiredEnvironmentVariables(environmentVariables: TVariables[]): { [key in TVariables]: string }; declare function pluralize(word: string, count: number, inclusive?: boolean): string; /** * Convert an object to a query param string * @example * objectToUrlParams({ foo: 'bar', hello: 123 } * // "foo=bar&hello=123" */ declare function objectToUrlParams(object: Record, options?: { colorize: boolean; }): string; /** * Take a query string and convert it to an object. * @example * urlParamsToObject('?hello=world&foo=bar') * // -> { hello: 'world', foo: 'bar' } * @param query URL query string/parameters */ declare function urlParamsToObject(query: string): Record; /** * Helper function for parsing env flags to true/false/null based on its string value. * Useful for preventing environment flags like DISABLE_FOO="false" from coercing to true. * @param key */ declare function envFlag(key: keyof NodeJS.ProcessEnv): boolean | null; type EnvironmentVariable = keyof NodeJS.ProcessEnv; //#endregion //#region src/lib/Timers.d.ts /** * Async sleep. * @param ms Number of milliseconds before the promise resolves */ declare function sleep(ms: number): Promise; /** * Works like setInterval, just that it will not permit another callback from being fired until the previous call has * resolved. * @param callback (Async) function to execute at the provided interval. * @param intervalMs Frequency in milliseconds for how often the callback should be fired. */ declare function sequentialInterval(callback: SequentialIntervalConfig['callback'], intervalMs: SequentialIntervalConfig['intervalMs']): SequentialInterval; /** * Sequential and controllable implementation of Node's setInterval function. Prevents interval hooks from being fired * until the previous call has completed. */ declare class SequentialInterval { readonly config: SequentialIntervalConfig; protected timer: NodeJS.Timeout | undefined; get callback(): () => void | Promise; get intervalMs(): number; constructor(config: SequentialIntervalConfig); protected run(): Promise; protected scheduleRun(): void; start(): void; stop(): void; } interface SequentialIntervalConfig { callback: () => void | Promise; intervalMs: number; startImmediately?: boolean; } //#endregion //#region src/lib/Queue.d.ts interface BatchConfig { interval: number; run: (entries: T[]) => Promise; } /** * Create a task scheduler that will trigger at the provided timeout/interval. * Used to batch a series of Meilisearch document update requests into a single task * to prevent excessive single-task indexing jobs on Meilisearch. */ declare function defineBatchableTask(config: BatchConfig): { intervalReached(): boolean; add(entry: T): Promise; }; //#endregion //#region src/lib/Conversion.d.ts declare function daysToMilliseconds(days: number): number; declare function weeksToMilliseconds(weeks: number): number; declare function monthsToMilliseconds(months: number): number; /** * Serialize a currency amount from its lowest denomination to the standard denomination. * @example * 100 = $1 * $49.99 = 4999 */ declare function formatCentsToDollars(amount: number, { currencySymbol, currencyCode, maxLength, currencyCodePrefix }?: { currencySymbol?: boolean | undefined; currencyCode?: string | undefined; maxLength?: number | undefined; currencyCodePrefix?: boolean | undefined; }): string; /** * Take an integer in US cents and convert it to a dollar amount in decimal. * @param amount Amount in cents * @example * formatCentsToFloat(1337) // -> $13.37 */ declare function formatCentsToFloat(amount: number): number; //#endregion export { pluralize as _, weeksToMilliseconds as a, urlParamsToObject as b, sequentialInterval as c, TimestampFormat as d, TimestampFormatOptions as f, objectToUrlParams as g, getEnvironmentFlag as h, monthsToMilliseconds as i, sleep as l, formatTimestamp as m, formatCentsToDollars as n, defineBatchableTask as o, envFlag as p, formatCentsToFloat as r, SequentialInterval as s, daysToMilliseconds as t, EnvironmentVariable as u, requiredEnv as v, requiredEnvironmentVariables as y }; //# sourceMappingURL=index-DKsYvRq2.d.cts.map