-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Rename casing functions and deprecate old ones
- Loading branch information
1 parent
46c6af8
commit b5c7621
Showing
36 changed files
with
244 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { type PascalCase, pascalCase } from './pascal-case.js' | ||
import { uncapitalize } from '../uncapitalize.js' | ||
|
||
/** | ||
* Transforms a string to camelCase. | ||
*/ | ||
export type CamelCase<T extends string> = Uncapitalize<PascalCase<T>> | ||
|
||
/** | ||
* A strongly typed version of `camelCase` that works in both runtime and type level. | ||
* @param str the string to convert to camel case. | ||
* @returns the camel cased string. | ||
* @example camelCase('hello world') // 'helloWorld' | ||
*/ | ||
export function camelCase<T extends string>(str: T): CamelCase<T> { | ||
return uncapitalize(pascalCase(str)) | ||
} | ||
|
||
/** | ||
* @deprecated | ||
* Use `camelCase` instead. | ||
* Read more about the deprecation [here](https://github.com/gustavoguichard/string-ts/issues/44). | ||
*/ | ||
export const toCamelCase = camelCase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { type DelimiterCase, delimiterCase } from './delimiter-case.js' | ||
import { toUpperCase } from '../../native/to-upper-case.js' | ||
|
||
/** | ||
* Transforms a string to CONSTANT_CASE. | ||
*/ | ||
export type ConstantCase<T extends string> = Uppercase<DelimiterCase<T, '_'>> | ||
/** | ||
* A strongly typed version of `constantCase` that works in both runtime and type level. | ||
* @param str the string to convert to constant case. | ||
* @returns the constant cased string. | ||
* @example constantCase('hello world') // 'HELLO_WORLD' | ||
*/ | ||
export function constantCase<T extends string>(str: T): ConstantCase<T> { | ||
return toUpperCase(delimiterCase(str, '_')) | ||
} | ||
|
||
/** | ||
* @deprecated | ||
* Use `constantCase` instead. | ||
* Read more about the deprecation [here](https://github.com/gustavoguichard/string-ts/issues/44). | ||
*/ | ||
export const toConstantCase = constantCase |
Oops, something went wrong.