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-numbering

v1.0.0

Published

format numbers as chinese words

Downloads

525

Readme

chinese-numbering

npm package chinese-numbering GitHub package.json dependency version (dev dep on branch) semantic-release

format numbers as chinese words and ordinals

Install

npm install chinese-numbering
yarn add chinese-numbering

Usage

import

  • Node.js

    const cn = require("chinese-numbering");
    console.log(cn.numberToChinese(11));
  • Browser

    • with iife / umd bundle:

      <script src="https://unpkg.com/[email protected]/bundle/iife.js"></script>
      <script>
        const cn = window.ChineseNumbering;
        alert("ChineseNumbering is formatting 11 to " + cn.numberToChinese(11));
      </script>
    • with es module bundle:

      <script type="module">
        import * as cn from "https://unpkg.com/[email protected]/bundle/es.js";
        alert("ChineseNumbering is formatting 11 to " + cn.numberToChinese(11));
      </script>
  • ES Modules

    import * as cn from "chinese-numbering";
    console.log(cn.numberToChinese(11));

number to Simplified / Traditional Chinese

// Simplified Chinese 简体中文
// 一万零一点六
cn.numberToChinese(10001.6);
cn.numberToChinese(10001.6, "s");
cn.numberToChinese(10001.6, "simplified");
cn.numberToChinese(10001.6, { chineseType: "simplified" });

// Tradition Chinese 繁體中文
// 一萬零一點六
cn.numberToChinese(10001.6, "t");
cn.numberToChinese(10001.6, "traditional");
cn.numberToChinese(10001.6, { chineseType: "traditional" });

// negative numbers 负数
cn.numberToChinese(-1200); // 负一千二百
cn.numberToChinese(-0.5, "t"); // 負零點五

Keep the first One

// not keep the first `One`
cn.numberToChinese(12); // 十二
// Keep the first `One`
cn.numberToChinese(12, { keepOne: true }); // 一十二

Ordinal

cn.numberToChineseOrdinal(12); // 第十二
cn.numberToChineseOrdinal(12, { keepOne: true }); // 第一十二
cn.numberToChineseOrdinal(10000, { chineseType: "t" }); // 第一萬

// with Arabic numerals
cn.numberToChineseOrdinalWithArabic(12); // 第12

License

MIT © Equal Ma

The algorithm to format number as Chinese words is inspired by digi3studio/number-to-chinese-words. Great Thanks to digi3studio.