/** * returns a promise that will resolve in the specified number of * milliseconds */ export declare function sleep(milliseconds?: number): Promise; /** * generates a random string guaranteed to start with an alpha * character, which makes it suitable for HTML `id` attribute */ export declare function randomid(length?: number): string; /** * useful for checking for empty strings, though in modern javascript * optional chaining may be easier: if (!str?.trim().length) ... */ export declare function isBlank(str: string | undefined | null): str is '' | undefined | null; /** * useful for checking for empty strings, though in modern javascript * optional chaining may be easier: if (str?.trim().length) ... */ export declare function isNotBlank(str: T): str is Exclude; /** * useful for chaining Array.filter(isTruthy).map when using typescript; the map * variable will no longer be marked as optional * * also see: isNotNull */ export declare function isTruthy(str: T): str is Exclude; /** * undefined and null both treated as null */ export declare function isNull(obj: any): obj is undefined | null; /** * undefined and null both treated as null */ export declare function isNotNull(obj: T): obj is Exclude; /** * only checks for valid syntax */ export declare function isEmail(email: T): email is Exclude; interface Stringable { toString: (...args: any) => string; } /** * Convert something to a string but convert null|undefined to undefined instead of creating * 'undefined' and 'null' strings */ export declare function optionalString(str: number | string | boolean | Stringable): string; export declare function optionalString(str: undefined | null): undefined; export declare function optionalString(str: any): string | undefined; /** * Print a variable if a condition is met * * Optionally provide a boolean as the first parameter to control whether to print anything. * For example, `printIf(mystate.showcontent, mystate.content)` will print the contents of * mystate.content only if mystate.showcontent is truthy. * * Always outputs an empty string instead of 'undefined' or 'null', so you do not have to * explicitly check mystate.content against null. * * Generally shorter/easier than (mystate.showcontent && mystate.content != null ? mystate.content : '') * * @note This isn't intended for use with string interpolation passed to `str` as the interpolation will evaluate * as a parameter to the function before entering this function and testing the conditional. */ export declare function printIf(condition: any, str: number | string | boolean | Stringable | undefined | null): string; export declare function printIf(str: number | string | boolean | Stringable | undefined | null): string; export declare function roundTo(num: number, digits?: number): number; export declare function bytesToHuman(bytes: number): string; export {};