@altostra/core
Version:
Core library for shared types and logic
37 lines (36 loc) • 1.42 kB
TypeScript
declare const rxLiteralSym: unique symbol;
/** A values that isn't being escaped when passed to `regexp` tagged-template */
export interface RegExpPatternLiteral {
[rxLiteralSym]: RegExp | string;
toString(): string;
}
declare const rxFlagsSym: unique symbol;
/**
* A values that specifies the `RegExp`'s flags when passed as the last argument
* to `regexp` tagged-template
*/
export interface RegExpFlags {
[rxFlagsSym]: string;
}
/**
* A tagged-template that allow generating regexes where parts of the pattern (or the flags)
* are passed as arguments
* @param patternTemplate Literal strings
* @param values Values to escape, literals and flags
* @returns A regex where the provided values are escaped
*/
export declare function regexp(patternTemplate: TemplateStringsArray, ...values: unknown[]): RegExp;
/**
* Generates a values that isn't being escaped when is passed the `regexp` tagged-template
* @param value The literal
* @returns A regex literal value
*/
export declare function regexpLiteral(value: RegExp | string): RegExpPatternLiteral;
/**
* Creates a values that specifies `RegExp`'s flags when passed as last argument
* to `regexp` tagged-template
* @param flagsStr A string that specifies the flags for the generated `RegExp`
* @returns A value that specifies the flags for a generated `RegExp`
*/
export declare function flags(flagsStr: string): RegExpFlags;
export {};