npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

chinese-number-format

v1.0.2

Published

中文數字轉換Chinese numeral conversion

Downloads

25

Readme

chinese-number-format

Features

  • 數字轉中文 Convert numbers to Chinese
  • 數字轉中文含單位 Convert numbers to Chinese including units
  • 中文轉數字 Convert Chinese to numbers
  • 中文數字轉大寫 Conversion of Chinese numerals to uppercase

Quick start

  • Install with npm: npm install chinese-number-format
  • Clone the repo: git clone https://github.com/garylin0969/chinese-number-format.git

Example

import {
    toChinese, // 數字轉中文
    toChineseWithUnits, // 數字轉中文含單位
    toNumber, // 中文轉數字
    toUpperCase, // 中文數字轉大寫
} from 'chinese-number-format';

// 預設為zh-TW

console.log(toChinese(1234567890, 'zh-TW')); // 一二三四五六七八九〇
console.log(toChinese(9876543210, 'zh-CN')); // 九八七六五四三二一〇

console.log(toChineseWithUnits(1234567890, 'zh-TW')); // 一十二億三千四百五十六萬七千八百九十
console.log(toChineseWithUnits(1234567890, 'zh-CN')); // 一十二亿三千四百五十六万七千八百九十
console.log(toChineseWithUnits(123.45, 'zh-TW')); // 一百二十三點四五
console.log(toChineseWithUnits(123.45, 'zh-CN')); // 一百二十三点四五

console.log(toNumber('一二三四五六七八九〇')); // 1234567890
console.log(toNumber('壹貳參肆伍陸柒捌玖零')); // 1234567890
console.log(toNumber('一二三點四五')); // 123.45
console.log(toNumber('一二三点四五')); // 123.45

console.log(toUpperCase('一二三', 'zh-TW')); // 壹貳參
console.log(toUpperCase('123', 'zh-TW')); // 壹貳參
console.log(toUpperCase('一二三', 'zh-CN')); // 壹贰叁
console.log(toUpperCase('123', 'zh-CN')); // 壹贰叁

備註

  • 預設為 zh-TW
  • toChineseWithUnits 最大支援單位為千兆,其餘無限制
  • toNumber 不支援帶有單位的轉換