UNPKG

typedash

Version:

modern, type-safe collection of utility functions

22 lines 948 B
//#region src/functions/constantCase/constantCase.d.ts /** * Changes the casing of a string to constant case. * @param string The input string to change the casing of. * @returns A new string with the casing changed to constant case. * @example * ```ts * constantCase('fooBar') // 'FOO_BAR' * constantCase('foo bar') // 'FOO_BAR' * constantCase('foo-bar') // 'FOO_BAR' * constantCase('fooBar42') // 'FOO_BAR42' * ``` */ declare function constantCase<S extends string>(string: S): ConstantCase<S>; /** * Changes the casing of a string to constant case. * @see {@link constantCase}. */ type ConstantCase<S extends string> = Uppercase<S extends `${infer S1}${infer S2}` ? `${S1 extends '-' ? '_' : S1 extends ' ' ? '_' : S1 extends '_' ? '_' : S1 extends Capitalize<S1> ? `_${Lowercase<S1>}` : S1}${ConstantCase<S2>}` : S>; //#endregion export { constantCase as n, ConstantCase as t }; //# sourceMappingURL=constantCase-BMaCP1dc.d.ts.map