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

2.0.9 • Public • Published

@zerodep/case-kebab

version language types license

CodeFactor Known Vulnerabilities

A utility to convert a string to kebab-case that also strips out non-alphanumeric characters and any leading numeric characters. Non-string values will cause a ZeroDepError to be thrown.

Full documentation is available at the zerodep.app page.

Documentation

This is a standalone package export from the @zerodep ecosystem.

Full documentation for this method may be found at the zerodep.app website.

Examples

All @zerodep packages support both ESM and CJS.

import { caseKebab } from '@zerodep/case-kebab';
// or
const { caseKebab } = require('@zerodep/case-kebab');

Use Cases

caseKebab('From sentence case'); // "from-sentence-case"
caseKebab('fromCamelCase'); // "from-camel-case"
caseKebab('from.dot.case'); // "from-dot-case"
caseKebab('from_snake_case'); // "from-snake-case"
caseKebab('FromPascalCase'); // "from-pascal-case"
caseKebab(''); // ""

// with non-alphanumeric characters
caseKebab('A string with some !@#$%^& characters'); // "a-string-with-some-characters"
caseKebab('A #22 character long string'); // "a-22-character-long-string"
caseKebab("I'm a sp3c!al $741ng"); // "i-m-a-sp3c-al-741ng"

// with accented characters
caseKebab('àëîóüý Žøñç'); // "aeiouy-zonc"

// with leading special characters and numbers
caseKebab('__with    many --- spaces'); // "with-many-spaces"
caseCamel('12 monkeys see 6 bananas'); // "monkeys-see-6-bananas"

// non-string values
caseKebab({ not: 'a string' }); // throws ZeroDepError: Value is not a string

Package Sidebar

Install

npm i @zerodep/case-kebab

Homepage

zerodep.app

Weekly Downloads

2

Version

2.0.9

License

MIT

Unpacked Size

11.1 kB

Total Files

7

Last publish

Collaborators

  • cdepage