# lc-camel-to-hyphen

> This is an npm package that converts text in camel case into text in kebab case.

Latest version **1.1.0** (published 2025-01-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install lc-camel-to-hyphen
pnpm add lc-camel-to-hyphen
yarn add lc-camel-to-hyphen
bun add lc-camel-to-hyphen
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2025-01-02 |
| First published | 2017-11-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | JamesYin |
| Maintainers | elantion |
| Keywords | camel, case |

## Links

- npm: https://www.npmjs.com/package/lc-camel-to-hyphen
- Repository: https://github.com/lazycoffee/lc-camel-to-hyphen
- Homepage: https://github.com/lazycoffee/lc-camel-to-hyphen#readme
- Issues: https://github.com/lazycoffee/lc-camel-to-hyphen/issues
- npm.io page: https://npm.io/package/lc-camel-to-hyphen

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2025-01-02
- 1.0.0 — 2017-11-21

## README

# lc-camel-to-hyphen
This is an npm package that converts text in camel case into text in kebab case.
<br />
这是一个把驼峰写法的文本转换为中横线写法（烤肉串写法）的npm包。

## usage 使用方法

1. In most scenarios, that is, when there are no consecutive capital letters, we will change the capitalized first letter to lowercase and add a hyphen, for example: "CamelCase" > "camel-case".
2. If we encounter consecutive capital letters, we will regard the whole string of consecutive capital letters, except for the last one, as a complete word, change the capitalized first letter of that word to lowercase, and add a hyphen, for example "XMLParser" > "xml-parser".

<br />

1. 在大多数场景，也就是没有连着的大写字母，我们会把首字母大写改为小写，并加上中横线。如："CamelCase" > "camel-case"。
2. 如果遇到连着的大写字母，我们会把连着的整串大写字母，除最后一位，视作为一个完整的单词，把该单词首字母大写转为小字，并加上中横线，例如："XMLParser" > "xml-parser"。

See below example: <br />
参考下面样例：

```JavaScript
const camelToHyphen = require('lc-camel-to-hyphen');

let testCase = [
    'FirstUpperCase', // first-upper-case
    'standerCamelCase', // stander-camel-case
    'thisIsASingleLetterCase', // this-is-a-single-letter-case
    'XMLParser', // xml-parser
];
testCase.forEach(text=>console.log(text + ' -> ' + camelToHyphen(text)));
```

---
_Source: https://npm.io/package/lc-camel-to-hyphen · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
