🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

kebab-case

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kebab-case

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

2.0.2
latest
Source
npm
Version published
Weekly downloads
369K
-18.47%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

kebab-case

FAQs

Package last updated on 11 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts