@birchill/normal-jp

中文文档
1.8.0发布于 2026/08/10ESM + CJS零依赖构建来源已验证近 30 天下载 2583

Various Japanese text conversion utilities

原始使用文档
文档目录8 节
  1. toNormalized
  2. kanaToHiragana
  3. kanaToKatakana
  4. kyuujitaiToShinjitai
  5. expandChoon
  6. countMora
  7. moraSubstring
  8. halfToFullWidthNum

Normal Japan

Various conversion utilities for Japanese text.

toNormalized

Performs the following conversions:

  • half-width katakana to full-width katakana (e.g. ガーデン → ガーデン)
  • decomposed characters to their composed equivalents (e.g. ダイエット → ダイエット)
  • various enclosed characters into their plain form (e.g. ㋕ → カ)
  • various combined characters into their expanded form (e.g. ㌀ → アパート, ㋿ → 令和)
  • variation selector characters are dropped
  • characters encoded using radical codepoints are converted to equivalent kanji codepoints (e.g. ⽂/0x2F42 → 文/0x6587)

and return the mapping from positions in the output string to the input string (using regular character indexing, not fancy codepoint indexing since the APIs we want to use these results with don't know about about surrogate pairs).

kanaToHiragana

Converts full-width katakana characters to hiragana. It doesn't handle half-width katakana so you should run the input through toNormalized first if you want to handle that.

Note that the length of the output is equal to the length of the input so this function does not returning the mapping from input string character offsets to output string positions.

kanaToKatakana

Converts hiragana characters to full-width katakana. As with kanaToHiragana the length of the input and output is equal so this function does not return the mapping between character offsets.

kyuujitaiToShinjitai

Converts various 旧字体 (kyuujitai, old character forms) to 新字体 (shinjitai, new character forms).

Based on the data in https://en.wikipedia.org/wiki/Kyūjitai but does not handle kyuujitai represented using variation selectors since these are stripped by toNormalized.

As with katakanaToHiragana the length of the input and output is equal so this function does not return the mapping between character offsets.

expandChoon

Expands ー to the various vowels it may represent.

As with katakanaToHiragana the length of the input and output is equal so this function does not return the mapping between character offsets.

countMora

Counts the number of mora in a hiragana/katakana string, e.g.

  • moraCount('とうきょう') ⇒ 4
  • moraCount('いっぱい') ⇒ 4

moraSubstring

Like String.prototype.substring but takes mora indices instead, e.g.

  • moraSubstring('しゃけ', 0, 1) ⇒ 'しゃ'
  • moraSubstring('しゃけ', 1) ⇒ 'け'

halfToFullWidthNum

Converts half-width numbers to full-width.

  • halfToFullWidthNum('第405号') ⇒ '第405号'

版本与发布记录

@birchill/normal-jp 共发布 21 个版本,首次发布于 2020/09/04;过去 12 个月发布了 4 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.8.0latest2026/08/102 个月前
1.7.22026/06/304 个月前
1.7.12026/06/015 个月前
1.7.02026/06/015 个月前
1.6.02025/01/181.8 年前
1.5.22024/10/042 年前

关于 @birchill/normal-jp 的常见问题

@birchill/normal-jp 是什么?

Various Japanese text conversion utilities

如何安装 @birchill/normal-jp?

在项目目录运行 npm install @birchill/normal-jp,或使用 pnpm add / yarn add / bun add。

@birchill/normal-jp 支持 TypeScript 吗?

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

@birchill/normal-jp 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@birchill/normal-jp 可以商用吗?

@birchill/normal-jp 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@birchill/normal-jp 的下载量有多少?

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

@birchill/normal-jp 还在维护吗?

最新版本 1.8.0 发布于 2026/08/10(2 个月前);至今共发布 21 个版本,其中过去 12 个月发布了 4 个;首次发布于 2020/09/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。