UNPKG

@js-data-tools/js-helpers

Version:

A set of JavaScript / TypeScript helper functions for parsing, converting, transforming and formatting data.

22 lines (21 loc) 1.46 kB
export declare const CHAR_CODE_OPEN_PAREN = 40; export declare const CHAR_CODE_CLOSE_PAREN = 41; export declare const CHAR_CODE_OPEN_BRACKET = 91; export declare const CHAR_CODE_CLOSE_BRACKET = 93; export declare const CHAR_CODE_OPEN_BRACE = 123; export declare const CHAR_CODE_CLOSE_BRACE = 125; export declare const CHAR_CODE_QUOTE = 34; export declare const CHAR_CODE_APOSTROPHE = 39; export declare const CHAR_CODE_BACKTICK = 96; export declare function skipUntilClosingQuote(text: string, start: number, quote: number): number; /** * Finds the first occurrence of the specified symbol, skipping quoted strings and pairs of braces, parens and square brackets. * @category format * @param text - The string to scan. * @param start - The zero-based offset to start searching from. * @param symbol - The character to search (or a callback function that should return true if a symbol passed as parameter is the one being searched). * @param throwOnMismatch - Set to false to prevent throwing exception when opening and closing parenthesis / braces / brackets do not match. */ export declare function skipPairsUntil(text: string, start: number, symbol: number, throwOnMismatch?: boolean): number; export declare function skipPairsUntil(text: string, start: number, symbol: string, throwOnMismatch?: boolean): number; export declare function skipPairsUntil(text: string, start: number, match: ((x: number) => boolean), throwOnMismatch?: boolean): number;