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

@bryanadamss/num2chn

v1.1.2

Published

Convert numbers to Chinese

Downloads

8

Readme

num2chn

🚄 Convert numbers to Chinese


NPM GitHub issues

Links

https://github.com/BryanAdamss/num2chn

Install

npm i @bryanadamss/num2chn

or

<script src="https://unpkg.com/@bryanadamss/num2chn@latest/dist/num2chn.umd.js"></script>

How to use

import Num2Chn from '@bryanadamss/num2chn'

const instance= new Num2Chn()

instance.transform(123)

Demos

  • https://github.com/BryanAdamss/num2chn/tree/master/examples

API

Num2Chn(options)

  • options is not required

  • default options

// 默认参数
{
  unitChars:['', '十', '百', '千'], // 节内权位
  sectionUnitChars: ['', '万', '亿', '万亿', '亿亿'], // 节权位
  numChars:['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'], // 数字映射表
  dotChar:'点', // 小数点
  signChar:'负' // 符号
}
 
  • methods
  • 😂Most of the scenes, you only need to use instance.transform() method
  /**
   * 获取数字对应中文
   *
   * @param {number} n 数字
   * @returns {string} 数字对应中文
   * @memberof Num2Chn
   */
  getNumChar(n: number): string {}

  /**
   * 获取节内权位
   *
   * @param {number} i 索引
   * @returns {string} 对应中文
   * @memberof Num2Chn
   */
  getUnitChar(i: number): string {}

  /**
   * 获取节权位
   *
   * @param {number} i 索引
   * @returns {string} 对应中文
   * @memberof Num2Chn
   */
  getSectionUnitChar(i: number): string {}

  /**
   * 获取点号对应中文
   *
   * @param {string} dotPart 点号部分
   * @returns {string} 点号对应中文
   * @memberof Num2Chn
   */
  getDotPartChn(dotPart: string): string {}

  /**
   * 获取符号对应中文
   *
   * @param {string} signPart 符号部分
   * @returns {string} 符号对应中文
   * @memberof Num2Chn
   */
  getSignPartChn(signPart: string): string {}

  /**
   * 获取小数部分的中文表示
   *
   * @param {(number | string)} n 小数部分
   * @returns {string} 小数部分的中文表示
   * @memberof Num2Chn
   */
  getDecimalPartChn(n: number | string): string {}

  /**
   * 获取整数部分小节
   *
   * @param {(number | string)} n 整数
   * @returns {number[]} 小节数组
   * @memberof Num2Chn
   */
  getIntergerSections(n: number | string): number[] {}

  /**
   * 翻译小节
   *
   * @param {(number|string)} section 4位长度的小节
   * @returns {string} 小节对应中文
   * @memberof Num2Chn
   */
  getSectionsChn(section: number | string): string {}

  /**
   * 获取整数部分对应中文
   *
   * @param {(number|string)} intergerPart 整数部分
   * @returns {string} 整数部分对应中文
   * @memberof Num2Chn
   */
  getIntergetPartChn(intergerPart: number | string): string {}

  /**
   * 浮点数转中文数字
   *
   * @export
   * @param {(number | string)} n 需要转换的数字
   * @returns {string} 数字对应中文
   */
  transform(n: number | string): string {}

Changelog

changelog

Detailed changes for each release are documented in the release notes.

License

MIT

Copyright (c) 2019-present, bryanadamss GuangHui.