2.0.1 • Published 6 months ago

kebab-case v2.0.1

Weekly downloads
106,501
License
MIT
Repository
github
Last release
6 months ago

kebab-case

NPM version

Convert a string to kebab-case, i.e. its dash separated form

The difference between kebab-case and e.g. dashify is that this module doesn't modify the string in any other way than transforming uppercased letters to their lowercased counterparts prefixed with -. Thanks to this there's also a reverse function to do the opposite, i.e. get back the original value.

This is used in Unistyle to transform JavaScript CSS properties to their CSS counterparts without losing a possible browser prefix, e.g: WebkitTransform -> -webkit-transform.

Installation

Install kebab-case using npm:

npm install --save kebab-case

Usage

Module usage

import kebabCase from "kebab-case";

kebabCase("WebkitTransform");
// "-webkit-transform"
kebabCase.reverse("-webkit-transform");
// "WebkitTransform"
kebabCase("WebkitTransform", false);
// "webkit-transform"

API

kebabCase(str)

NameTypeDescription
strStringThe string to convert
keepLeadingDashBooleanWhether to keep the leading dash or not. Default is true.

Returns: String, the kebab cased string.

kebabCase.reverse(str)

NameTypeDescription
strStringThe string to convert back

Returns: String, the "unkebab cased" string.

License

MIT © Joakim Carlstein

@zhyao1684-cli/utils@knzn/init@zml-lerna-test/init@dong-cli/initcompat-ui-clitmp-hast-util-to-jsx@huamiao-cli/utils@c11/ui-engine@blink-cli-dev/init@czq-cli/init@wejee-lego-cli/init@ygdsj/init@der-cli-dev/init@pkq-cli/init@amar-cli-dev/utils@imooc-cli-czj/init@rice-cli/init@universal-cli-dev/init@imike-test/init@blink-cli/init@snow-lepoard/star-cli@infinitebrahmanuniverse/nolb-keb@xiaoli-cli/init@zhengke-cli-dev/initeslint-plugin-stop-use-momentepip-gen@everything-registry/sub-chunk-2009@jkhaak-solita/eslint-plugin-you-dont-need-momentjs@meow-cli/init@dada-fe-cli/init@femc/init@dragon-slayer-dev/init@dragon-slayer/init@spark-bit/init@tracktile/veritastachyons-generatortacoscripttbg-foundation-docstailwindcss-material3-pluginsystylewqas-cli-utilswwei-clishanshui-cli-custom-react-templateremark-krokirollup-plugin-fontvue-cli-plugin-nbcs-scorevoyage-cli-init@lrn-cli/init@sdw-cli/utilsmeteorite-cmsminiapp-rax-frameworkminiapp-framework-sharedminiapp-framework-webmercury-animatemercury-animationlego-template-vue3-customhandlebars-to-ecmascriptice-assetsice-layout-builderice-devtoolsmicroxleyixue-clijsx2mp-clijsx2qa-compilergui-pkghast-to-snabbdomhast-util-to-jsx-inline-scripti18next-to-fluentgoogle-remakejsx-compilerldq-clilambda-sdk-generatorlucide-svgornament-tokens-parserppd-cli-testpromet-iconsobjection-crudng6-generatorng-scriptsnode-patternlibraryreact-rnd-with-alignlinesnscssoaoreact-json2pagestylordstyieldspike-clitransactionlink-widgetv2tippecanoe@aotu-cli/init@armory/init@art-ui-cli/init@arcanis-inc/tachyons-generator@arcane-cli/init@animaapp/anima-cli@attack-i/init@auv-cli/init@alic-cli-dev/init@allow-cli-dev/init@allride-cli/init
2.0.1

6 months ago

2.0.0

6 months ago

1.0.2

2 years ago

1.0.1

4 years ago

1.0.0

9 years ago