import { HttpError, ProcessError } from "../types/index.ts"; import type { Response } from "../services/fetcher.ts"; export declare const isDevelopment: () => boolean; export declare const isNode: () => boolean; export declare const isBrowser: () => boolean; export declare function isCustomError(error: unknown): error is HttpError | ProcessError; export declare const sanitizeMessage: (value: string) => string; export declare const minutesToMilliseconds: (minutes: number) => number; export declare const hoursToMilliseconds: (hours: number) => number; export declare const secondsToMilliseconds: (seconds: number) => number; export declare function customParseInt(input: string | undefined): number; export declare function commaSplitter(input: string | undefined): string[]; export declare function delay(ms: number): Promise; /** Calculate the row number based on the total number of retries. * @param attempts - The total number of retries . * @param retryScore - retries margin meaning how many retries is counted as 1. * @param maxAttempts - The maximum number of retries. * @returns - The row number. */ export declare function retriesCount(attempts: number, maxAttempts: number, retryScore?: number): number; /** Run a function with retries and delay between attempts */ export declare function excuteWithRetries(fn: () => Promise, maxAttempts?: number, backoffDelay?: number): Promise; /** * Asynchronous merge sort implementation that allows for an asynchronous comparison function. * Algorithm: Merge Sort * Time Complexity: O(n log n) on average and worst case, O(n) in the best case (when the array is already sorted) * Space Complexity: O(n) due to the temporary arrays used during merging */ export declare function sorter(items: T[], compareFn: (a: T, b: T) => number | Promise): Promise; /** * Normalize a headers object so that duplicate keys differing only by case * are collapsed into a single entry. When two keys map to the same * lower-case form (e.g. `Accept` and `accept`), the **last** value wins * while the **first** casing encountered is preserved. * * @example * normalizeHeaders({ Accept: 'text/html', accept: 'application/json' }) * // => { Accept: 'application/json' } */ export declare function normalizeHeaders>(headers: T): { [K in string]: string; }; /** Creates a cookie string from the "Set-Cookie" headers. * @param headers - The headers object containing "Set-Cookie" entries. * @returns A string suitable for the "Cookie" header in subsequent requests. * @argument headers - Set-Cookie can only contain one cookie per header line * Example: * Input: { * "Set-Cookie": [ * "sessionId=abc123; Path=/; HttpOnly", * "userId=xyz789; Path=/; HttpOnly" * ] * } * Output: "sessionId=abc123; userId=xyz789" */ export declare function createCookiesFromSet(headers: Response["headers"] | Record): string; /** Joins existing cookies with new cookies, ensuring no duplicates and proper formatting.*/ export declare function joinCookies(existingCookies: string | undefined, newCookies: string): string; /** Attach a file extension to a URL or file path, replacing any existing extension if present. * @param extension - The file extension to attach (with or without a leading dot) * @param urlOrPath - The URL or file path to which the extension should be attached * - If urlOrPath is empty, the function will return the extension itself (normalized to remove any leading dot) * - If urlOrPath has an existing extension, it will be replaced with the new extension * - Trailing slashes and dots in urlOrPath will be stripped before attaching the extension * - The function will handle both absolute URLs and relative file paths correctly * - Can be used to ensure that a URL or file path has the correct extension for media processing or downloading * - Example usage: * ```ts * attachExtension("m3u8", "/path/to/video.mp4"); // Returns: "/path/to/video.m3u8" * attachExtension(".ts", "video"); // Returns: "video.ts" * attachExtension("mp4", "https://example.com/stream/"); // Returns: "https://example.com/stream.mp4" * attachExtension("m3u8", "https://example.com/stream.mp4"); // Returns: "https://example.com/stream.m3u8" * attachExtension("m3u8", "https://example.com/stream"); // Returns: "https://example.com/stream.m3u8" * attachExtension("m3u8", "https://example.com/stream/"); // Returns: "https://example.com/stream.m3u8" * ``` */ export declare function attachExtension(extension: string, urlOrPath: string): string; export declare function shuffleArray(array: T[]): T[]; export declare function deduplicateArray(array: T[]): T[];