Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

camel-to-kebab

pineapplemachine6.6kZlib1.1.2TypeScript support: included

Convert camelCase inputs to kebab-case outputs.

text, strings, naming, camel, camelCase, pascal, PascalCase, kebab, kebab-case, hyphen, spinal, lisp, case

readme

camel-to-kebab

Build Status

This is a JavaScript library implementing one function, camelToKebabCase. It accepts a camelCase string as input and outputs a kebab-case equivalent. It also works for PascalCase inputs.

This library is very lightweight at 892 bytes minified and 467 bytes gzipped. It requires no external dependencies, and it's licensed according to the permissive zlib/libpng license.

Installation

You can add camelToKebabCase to your JavaScript project by using a package manager to install the camel-to-kebab package. For example:

npm install --save camel-to-kebab

Usage

camelToKebabCase can be used in the browser, imported as a CommonJS module, or imported as an ES module.

// Import camel-to-kebab as a CommonJS module
const camelToKebabCase = require("camel-to-kebab");
// Import camel-to-kebab as an ES module
import camelToKebabCase from "camel-to-kebab";
<!-- Use camel-to-kebab in the browser -->
<script src="camel-to-kebab.min.js"></script>

Examples

const camelToKebabCase = require("camel-to-kebab");

// prints "hello-world"
console.log(camelToKebabCase("helloWorld"));

// prints "camel-to-kebab-case"
console.log(camelToKebabCase("camelToKebabCase"));

// prints "testing-123"
console.log(camelToKebabCase("testing123"));

// prints "inner-html"
console.log(camelToKebabCase("innerHTML"));

// prints "border-top-left-radius"
console.log(camelToKebabCase("borderTopLeftRadius"));

changelog

Changelog for camel-to-kebab

v1.1.2

Sixth release. 1 November 2022.

  • Fix TypeScript definitions *.d.ts file not being correctly included

v1.1.1

Fifth release. 13 April 2018.

  • Add a TypeScript definitions *.d.ts file

v1.1.0

Fourth release. 13 August 2018.

  • Improve behavior for null and undefined inputs
  • Improve behavior for input strings containing spaces

v1.0.2

Third release. 4 May 2018.

  • Add more information to readme and add readme examples as unit tests
  • Package build/publish process now works on Windows (it previously worked with unix only)

v1.0.1

Second release. 4 May 2018.

  • Document and test usage with PascalCase inputs
  • Add license, repo, and authorship info as comments in the uglified module file

v1.0.0

First release. 3 May 2018.