https://github.com/substrate-system/kebab-case
Kebab case
https://github.com/substrate-system/kebab-case
Last synced: about 1 year ago
JSON representation
Kebab case
- Host: GitHub
- URL: https://github.com/substrate-system/kebab-case
- Owner: substrate-system
- License: other
- Created: 2024-11-26T20:49:20.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-09T00:58:44.000Z (about 1 year ago)
- Last Synced: 2025-06-11T05:17:57.967Z (about 1 year ago)
- Language: TypeScript
- Homepage: https://substrate-system.github.io/kebab-case/
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# kebab case

[](README.md)
[](README.md)
[](https://semver.org/)
[](./CHANGELOG.md)
[](https://packagephobia.com/result?p=@nichoth/session-cookie)
[](package.json)
[](LICENSE)
Kebab case a string.
```js
import { kebabCase } from '@substrate-system/kebab-case'
kebabCase('the quick brown fox'); // 'the-quick-brown-fox'
kebabCase('the-quick-brown-fox'); // 'the-quick-brown-fox'
kebabCase('the_quick_brown_fox'); // 'the-quick-brown-fox'
kebabCase('theQuickBrownFox'); // 'the-quick-brown-fox'
kebabCase('theQuickBrown Fox'); // 'the-quick-brown-fox'
kebabCase('thequickbrownfox'); // 'thequickbrownfox'
kebabCase('the - quick * brown# fox'); // 'the-quick-brown-fox'
kebabCase('theQUICKBrownFox'); // 'the-quick-brown-fox'
```
Contents
- [install](#install)
- [API](#api)
* [ESM](#esm)
* [Common JS](#common-js)
* [pre-built JS](#pre-built-js)
- [use](#use)
* [example](#example)
## install
```sh
npm i -S @substrate-system/kebab-case
```
## API
This exposes ESM and common JS via [package.json `exports` field](https://nodejs.org/api/packages.html#exports).
### ESM
```js
import { kebabCase } from '@substrate-system/kebab-case'
```
### Common JS
```js
const { kebabCase } = require('@substrate-system/kebab-case')
```
### pre-built JS
This package exposes minified JS files too. Copy them to a location that is
accessible to your web server, then link to them in HTML.
#### copy
```sh
cp ./node_modules/@substrate-system/kebab-case/dist/module.min.js ./public
```
#### HTML
```html
```
## use
Take a string in any format, return a URL-safe kebab case string.
### example
```js
import { kebabCase } from '@substrate-system/kebab-case'
kebabCase('the quick brown fox'); // 'the-quick-brown-fox'
kebabCase('the-quick-brown-fox'); // 'the-quick-brown-fox'
kebabCase('the_quick_brown_fox'); // 'the-quick-brown-fox'
kebabCase('theQuickBrownFox'); // 'the-quick-brown-fox'
kebabCase('theQuickBrown Fox'); // 'the-quick-brown-fox'
kebabCase('thequickbrownfox'); // 'thequickbrownfox'
kebabCase('the - quick * brown# fox'); // 'the-quick-brown-fox'
kebabCase('theQUICKBrownFox'); // 'the-quick-brown-fox'
```