@substrate-system/kebab-case
v0.0.0
Published
Kebab case, URL safe strings
Downloads
530
Readme
kebab case
Kebab case a string.
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'
install
npm i -S @substrate-system/kebab-case
API
This exposes ESM and common JS via package.json exports
field.
ESM
import '@substrate-system/kebab-case'
Common JS
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
cp ./node_modules/@substrate-system/kebab-case/dist/module.min.js ./public
HTML
<script type="module" src="./module.min.js"></script>
use
Take a string in any format, return a URL-safe kebab case string.
example
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'