toKebabCase

Commons
stable

Convert any string (camelCase, PascalCase, etc.) to kebab-case by replacing non-alpha characters with hyphens and inserting a hyphen before each uppercase letter. Results are cached for performance.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

str
string
''
The input string to convert. Defaults to an empty string when omitted.

API

Return value

The value returned by this util.

A lowercase, hyphen-separated string. Results are memoised in an internal Map so repeated calls with the same input are O(1).

Usage

Examples

Ready-to-paste usage snippets.

Convert different case conventions

typescript