toidentifier

中文文档
1.0.1发布于 2021/11/15MIT零依赖近 30 天下载 5.2亿

Convert a string of words to a JavaScript identifier

原始使用文档
文档目录5 节
  1. Install
  2. Example
  3. API
  4. toIdentifier(string)
  5. License

toidentifier

NPM Version NPM Downloads Build Status Test Coverage

Convert a string of words to a JavaScript identifier

Install

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

$ npm install toidentifier

Example

var toIdentifier = require('toidentifier')

console.log(toIdentifier('Bad Request'))
// => "BadRequest"

API

This CommonJS module exports a single default function: toIdentifier.

toIdentifier(string)

Given a string as the argument, it will be transformed according to the following rules and the new string will be returned:

  1. Split into words separated by space characters (0x20).
  2. Upper case the first character of each word.
  3. Join the words together with no separator.
  4. Remove all non-word ([0-9a-z_]) characters.

License

MIT

版本与发布记录

toidentifier 共发布 3 个版本,首次发布于 2017/12/19;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.1latest2021/11/154 年前
1.0.02018/07/098 年前
0.0.12017/12/198 年前

关于 toidentifier 的常见问题

toidentifier 是什么?

Convert a string of words to a JavaScript identifier

如何安装 toidentifier?

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

toidentifier 支持 TypeScript 吗?

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

toidentifier 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=0.6。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

toidentifier 可以商用吗?

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

toidentifier 的下载量有多少?

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

toidentifier 还在维护吗?

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