UNPKG

typedash

Version:

modern, type-safe collection of utility functions

17 lines 715 B
//#region src/functions/ensurePrefix/ensurePrefix.d.ts /** * Ensures that the string starts with the given prefix. * @param string The string to ensure the prefix of. * @param prefix The prefix to ensure. * @returns The string with the given prefix. * @example * ```ts * ensurePrefix('foo', 'bar'); // 'barfoo' * ensurePrefix('foobar', 'foo'); // 'foobar' * ``` */ declare function ensurePrefix<S extends string, Prefix extends string>(string: S, prefix: Prefix): EnsurePrefix<S, Prefix>; type EnsurePrefix<S extends string, Prefix extends string> = S extends `${Prefix}${infer _Suffix}` ? S : `${Prefix}${S}`; //#endregion export { ensurePrefix as t }; //# sourceMappingURL=ensurePrefix-Cdg7rBCw.d.ts.map