/** * A mirror of Python's `collections.Counter` class. */ export declare class Counter extends Map { constructor(iterable?: Iterable); update(iterable: Iterable): void; } /** * Return a global version of the given regex pattern. */ export declare const toGlobal: (pat: RegExp) => RegExp; /** * Parse a string to an integer, throwing an error if the entire string * is not formatted as an integer. */ export declare const parseIntStrict: (str: string) => number; /** * Replace the first `count` instanaces of `pat` in `inputStr` with `repl`, * which may either be a new string, or a function that takes the matched * string and returns a new string. Converts `regex` to a global regex if * it is not already so that all instances could be replaced. */ export declare const subn: (regex: RegExp, replacer: (substring: string, ...args: any[]) => string, str: string, count?: number) => [string, number]; export declare const sub: (regex: RegExp, replacer: (substring: string, ...args: any[]) => string, str: string) => string; /** * A mirror of Python's `str.isspace()` method. */ export declare const isspace: (s: string) => boolean; /** * Return `!!x`. */ export declare const bool: (x: any) => boolean; /** * Convert a boolean to 1 if true, 0 if false. */ export declare const boolToNumber: (b: boolean) => 1 | 0; /** * Return the quotient and remainder of the division of `x` by `y`. * * A mirror of Python's `divmod()` function. */ export declare const divmod: (x: number, y: number) => [number, number]; /** * Get the number of bits necessary to represent `n` in binary. * * A mirror of Python's `int.bit_length()` method. */ export declare const bitLength: (n: number | bigint) => number; /** * Number of ones in the binary representation of the absolute value of `n`. * Also known as the population count. * * A mirror of Python's `int.bit_count()` method. */ export declare const bitCount: (n: number | bigint) => number; /** * A mirror of Python's `range()` function. */ export declare function range(start: number, stop?: number, step?: number): IterableIterator; /** * A mirror of Python's `enumerate()` function. */ export declare function enumerate(iterable: Iterable, start?: number): IterableIterator<[number, T]>; /** * A mirror of Python's `itertools.chain` function. */ export declare function iterChain(...iterables: Iterable[]): IterableIterator; /** * A mirror of Python's `itertools.islice` function. */ export declare function islice(iterable: Iterable, start: number | null, stop: number | null, step?: number): IterableIterator; /** * A mirror of Python's `StopIteration` error. */ export declare class StopIteration extends Error { constructor(message?: string); } /** * A mirror of Python's `next()` function. Throws `StopIteration` if the * iterable is exhausted. */ export declare const iterNext: (iterable: IterableIterator) => T; /** * Return `true` if `value` is equal to any element in the iterable according to `equalityCheck`. */ export declare const iterIncludes: (iterable: Iterable, value: T, equalityCheck?: (a: T, b: T) => boolean) => boolean; /** * Return `true` if any element of the iterable is truthy according to `isTruthy`. * If none are true or the iterable is empty, return `false`. */ export declare const iterAny: (iterable: Iterable, isTruthy?: (value: T) => boolean) => boolean; /** * Return `true` if all elements of the iterable are truthy according to `isTruthy`. * Returns `true` for an empty iterable. */ export declare const iterAll: (iterable: Iterable, isTruthy?: (value: T) => boolean) => boolean; /** * Yield the elements of `iterable` that are truthy against `predicate`. */ export declare function iterFilter(iterable: Iterable, predicate?: (value: T) => boolean): IterableIterator; /** * Maps each element of `iterable` to a new value using `callback`. */ export declare function iterMap(iterable: IterableIterator, callback: (value: T1) => T2): IterableIterator; /** * Remove the first occurrence of `element` from `src` in-place. */ export declare const remove: (src: T[], element: T) => void; declare const _default: { Counter: typeof Counter; toGlobal: (pat: RegExp) => RegExp; parseIntStrict: (str: string) => number; subn: (regex: RegExp, replacer: (substring: string, ...args: any[]) => string, str: string, count?: number) => [string, number]; sub: (regex: RegExp, replacer: (substring: string, ...args: any[]) => string, str: string) => string; isspace: (s: string) => boolean; bool: (x: any) => boolean; boolToNumber: (b: boolean) => 0 | 1; divmod: (x: number, y: number) => [number, number]; bitLength: (n: number | bigint) => number; bitCount: (n: number | bigint) => number; range: typeof range; enumerate: typeof enumerate; iterChain: typeof iterChain; islice: typeof islice; StopIteration: typeof StopIteration; iterNext: (iterable: IterableIterator) => T; iterIncludes: (iterable: Iterable, value: T_1, equalityCheck?: (a: T_1, b: T_1) => boolean) => boolean; iterAny: (iterable: Iterable, isTruthy?: (value: T_2) => boolean) => boolean; iterAll: (iterable: Iterable, isTruthy?: (value: T_3) => boolean) => boolean; iterFilter: typeof iterFilter; iterMap: typeof iterMap; remove: (src: T_4[], element: T_4) => void; }; export default _default; //# sourceMappingURL=utils.d.ts.map