mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-28 03:34:26 +03:00
31 lines
704 B
Markdown
31 lines
704 B
Markdown
# kebabCase
|
|
|
|
Converts a string to kebab case.
|
|
|
|
Kebab case is the naming convention in which each word is written in lowercase and separated by an dash (\-) character. For example, `kebab-case`.
|
|
|
|
## Signature
|
|
|
|
```typescript
|
|
function kebabCase(str: string): string;
|
|
```
|
|
|
|
### Parameters
|
|
|
|
- `str` (`string`): The string that is to be changed to kebab case.
|
|
|
|
### Returns
|
|
|
|
(`string`) The converted string to kebab case.
|
|
|
|
## Examples
|
|
|
|
```typescript
|
|
import { kebabCase } from 'es-toolkit/string';
|
|
|
|
kebabCase('camelCase'); // returns 'camel-case'
|
|
kebabCase('some whitespace'); // returns 'some-whitespace'
|
|
kebabCase('hyphen-text'); // returns 'hyphen-text'
|
|
kebabCase('HTTPRequest'); // returns 'http-request'
|
|
```
|