import { commandOptions } from 'redis';

/**
 * Wraps a Promise with a timeout, rejecting the Promise if it does not resolve within the specified time.
 *
 * @param operation - The Promise to wrap with a timeout.
 * @param timeoutMs - Optional. The timeout period in milliseconds.
 * If this is not a positive number, the function will simply return the original Promise.
 *
 * @returns A new Promise that behaves like the original Promise,
 * but will be rejected if the original Promise does not resolve within the specified timeout.
 *
 * @throws If the operation does not complete within the specified timeout,
 * the returned Promise will be rejected with an Error that has a message indicating the timeout period.
 */
declare function promiseWithTimeout<T>(operation: Promise<T>, timeoutMs?: number): Promise<T>;

/**
 * Checks if a given tag is an implicit tag.
 *
 * @param tag - The tag to check.
 *
 * @returns A boolean indicating whether the tag is an implicit tag.
 */
declare function isImplicitTag(tag: string): boolean;

type CommandOptions = ReturnType<typeof commandOptions>;
declare function getTimeoutRedisCommandOptions(timeoutMs: number): CommandOptions;

export { getTimeoutRedisCommandOptions, isImplicitTag, promiseWithTimeout };
