@monstermann/fn
Version:
A utility library for TypeScript.
22 lines • 635 B
TypeScript
//#region src/string/indexOfOrThrow.d.ts
/**
* `indexOfOrThrow(target, source)`
*
* Returns the index of the first occurrence of `source` string in `target` string, or throws an error if not found.
*
* ```ts
* indexOfOrThrow("hello world", "world"); // 6
* indexOfOrThrow("hello world", "foo"); // throws FnError
* ```
*
* ```ts
* pipe("hello world", indexOfOrThrow("world")); // 6
* pipe("hello world", indexOfOrThrow("foo")); // throws FnError
* ```
*/
declare const indexOfOrThrow: {
(source: string): (target: string) => number;
(target: string, source: string): number;
};
//#endregion
export { indexOfOrThrow };