UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

22 lines 796 B
//#region src/string/matchOrThrow.d.ts /** * `matchOrThrow(target, source)` * * Returns the result of matching `target` string against `source` string or regular expression, or throws an error if no match is found. * * ```ts * matchOrThrow("hello world", "world"); // ["world", index: 6, input: "hello world", groups: undefined] * matchOrThrow("hello world", /\d+/); // throws FnError * ``` * * ```ts * pipe("hello world", matchOrThrow("world")); // ["world", index: 6, input: "hello world", groups: undefined] * pipe("hello world", matchOrThrow(/\d+/)); // throws FnError * ``` */ declare const matchOrThrow: { (source: string | RegExp): (target: string) => RegExpMatchArray; (target: string, source: string | RegExp): RegExpMatchArray; }; //#endregion export { matchOrThrow };