Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kebab-case

Package Overview
Dependencies
Maintainers
0
Versions
5
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.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
197K
decreased by-17.32%
Maintainers
0
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

FAQs

Package last updated on 28 Jun 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc