https://github.com/shresht7/case-convert
Utility functions to determine and convert the case of strings.
https://github.com/shresht7/case-convert
string-case string-manipulation
Last synced: 2 months ago
JSON representation
Utility functions to determine and convert the case of strings.
- Host: GitHub
- URL: https://github.com/shresht7/case-convert
- Owner: Shresht7
- License: mit
- Created: 2022-06-28T14:30:29.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-21T20:54:39.000Z (4 months ago)
- Last Synced: 2025-01-27T09:09:45.929Z (4 months ago)
- Topics: string-case, string-manipulation
- Language: TypeScript
- Homepage:
- Size: 53.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `case-convert`
Utility functions to determine and convert the case of strings.
## Usage
```ts
import { toCamelCase } from 'case-convert'const result = toCamelCase('a-new-hope') // aNewHope
```## API Reference
### `Case`
```ts
export enum Case {
Camel = 'CAMEL', // camelCase
Snake = 'SNAKE', // snake_case
Kebab = 'KEBAB', // kebab-case
Title = 'TITLE', // TitleCase
}
```### `convert`
Convert the string to the given case type
```ts
import { Case, convert } from 'case-convert'const result = convert('a-new-hope', Case.Camel) // aNewHope
```### `check`
Check if the string is of the given case type
```ts
import { check, Case } from 'case-convert'check('a-new-hope', Case.Camel) // false
check('a_new_hope', Case.Snake) // true
```### `determineCase`
Determine the case type of the string
```ts
import { determineCase } from 'case-convert'const result = determineCase('ANewHope') // Case.Title = "TITLE"
```### `capitalize` and `uncapitalize`
Capitalize or uncapitalize a string
```ts
import { capitalize, uncapitalize } from 'case-convert'capitalize('a new hope') // A new hope
uncapitalize('A New Hope') // a New Hope
```### `toCamelCase`, `toSnakeCase`, `toKebabCase` and `toTitleCase`
Convert the string to the given format
```ts
import { toCamelCase, toSnakeCase, toKebabCase, toTitleCase } from 'case-convert'toCamelCase("some-string") // someString
toSnakeCase("someString") // some_string
toKebabCase("SomeString") // some-string
toTitleCase("some_string") // SomeString
```---
## 📑 License
This project is licensed under the [MIT License](./LICENSE).