kebab-case
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

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

var kebabCase = require("kebab-case");

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

API

kebabCase(str)

Name Type Description
str String The string to convert

Returns: String, the kebab cased string.

kebabCase.reverse(str)

Name Type Description
str String The string to convert back

Returns: String, the "unkebab cased" string.

License

MIT © Joakim Carlstein

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    205,809
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    205,809
  • 1.0.1
    214,308
  • 1.0.0
    126,493

Package Sidebar

Install

npm i kebab-case

Weekly Downloads

206,624

Version

1.0.2

License

MIT

Unpacked Size

7.03 kB

Total Files

10

Last publish

Collaborators

  • joakimbeng