@dfoverdx/tocamelcase

中文文档
1.0.7发布于 2018/11/28ISCCommonJS零依赖近 30 天下载 11.7万

Adds a comprehensive Camel-Case (and Pascal-Case) converter to the String's prototype

原始使用文档
文档目录4 节
  1. Installation
  2. Usage
  3. ES5
  4. ES6

toCamelCase

A simple JavaScript script that adds a comprehensive toCamelCase function to String.prototype. toCamelCase() includes an optional boolean parameter to output PascalCase instead of CamelCase.

This "pollutes" the String prototype which may or may not be an issue for you. It will not, however, overwrite String.prototype.toCamelCase if it is already defined.

If performance is an issue and you're running this over millions of strings, there are probably faster modules out there. This one uses three Regex passes over the string. For the majority of cases, however, this is not an issue.

Installation

For NPM:

npm install @dfoverdx/tocamelcase

Without NPM:

  1. Download /dist/index.min.js from this repository and name it something like tocamelcase.min.js

  2. Place it somewhere your webpage can access (e.g. /scripts/)

  3. Add it to your HTML file

    <body>
        <!-- ... -->
        <script src="/scripts/tocamelcase.min.js" type="text/javascript"></script>
        <!-- scripts that use .toCamelCase() -->
    </body>
    

Usage

ES5

require('@dfoverdx/tocamelcase');

console.log('This is camel-case'.toCamelCase()); // outputs: 'thisIsCamelCase'
console.log('This is pascal-case'.toCamelCase(true)); // outputs 'ThisIsPascalCase'

ES6

import '@dfoverdx/tocamelcase';

console.log('This is camel-case'.toCamelCase()); // outputs: 'thisIsCamelCase'
console.log('This is pascal-case'.toCamelCase(true)); // outputs 'ThisIsPascalCase'

版本与发布记录

@dfoverdx/tocamelcase 共发布 8 个版本,首次发布于 2018/10/11;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.7latest2018/11/287 年前
1.0.62018/11/287 年前
1.0.52018/11/287 年前
1.0.42018/11/287 年前
1.0.32018/10/118 年前
1.0.22018/10/118 年前

关于 @dfoverdx/tocamelcase 的常见问题

@dfoverdx/tocamelcase 是什么?

Adds a comprehensive Camel-Case (and Pascal-Case) converter to the String's prototype

如何安装 @dfoverdx/tocamelcase?

在项目目录运行 npm install @dfoverdx/tocamelcase,或使用 pnpm add / yarn add / bun add。

@dfoverdx/tocamelcase 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/dfoverdx__tocamelcase 是否存在。

@dfoverdx/tocamelcase 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@dfoverdx/tocamelcase 可以商用吗?

@dfoverdx/tocamelcase 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dfoverdx/tocamelcase 的下载量有多少?

根据 npm 官方下载统计,@dfoverdx/tocamelcase 在 2026/10/12 – 2026/11/10 这 30 天内被下载 116,572 次,日均约 3,886 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dfoverdx/tocamelcase 还在维护吗?

最新版本 1.0.7 发布于 2018/11/28(7 年前);至今共发布 8 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/10/11。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。