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

kansuji-ts

v1.0.3

Published

Convert numbers into Japanese Kansuji string (number in Chinese characters)

Downloads

3

Readme

kansuji

wercker status

Node module to convert numbers into Japanese Kansuji string (number in Chinese characters).

Install

npm install kansuji

Usage

kansuji(n, options = {})

Convert a number into Japanese Kansuji string.

n can be a Number or a String in Arabic numerals.

Options

| Key | Description | Default | | ------- | ----------- | ------- | | unit | If set to false, don't use units and just convert each digit | true | | ichi | If set to true, don't omit (ichi) before , , If set to Array, don't omit before each member like 1000 of the array | false | | daiji | If set to true, use Daiji numbers like 壱弐参, If set to "old", use old-style Daiji numbers like 零壱弐参肆伍陸漆捌玖, 拾佰阡萬 | false | | wide | If set to true, allow wide-character numbers like 123 for input | false |

Example

var kansuji = require("kansuji");

console.log(kansuji(123));
// => "百二十三"

console.log(kansuji(12345));
// => "一万二千三百四十五"

console.log(kansuji(12345, { unit: false }));
// => "一二三四五"

console.log(kansuji(1001, { unit: false }));
// => "一〇〇一"

console.log(kansuji(11111));
// => "一万千百十一"

console.log(kansuji(11111, { ichi: true }));
// => "一万一千一百一十一"

console.log(kansuji(11111, { ichi: [1000, 100] }));
// => "一万一千一百十一"

console.log(kansuji(12.34));
// => "十二・三四"

console.log(kansuji("123"));
// => "百二十三"

console.log(kansuji("0123"));
// => "百二十三"

console.log(kansuji("123ABC"));
// => "百二十三"

console.log(kansuji("0123", { unit: false }));
// => "〇一二三"

console.log(kansuji("123.456"));
// => "百二十三・四五六"

console.log(kansuji("ABC"));
// => TypeError("Non-number string can't be converted")

console.log(kansuji(123, { daiji: true }));
// => "百弐拾参"

console.log(kansuji(1234567890, { daiji: true }));
// => "拾弐億参千四百五拾六万七千八百九拾"

console.log(kansuji(123, { daiji: true, unit: false }));
// => "壱弐参"

console.log(kansuji(1234567890, { daiji: "old" }));
// => "拾弐億参阡肆佰伍拾陸萬漆阡捌佰玖拾"

console.log(kansuji("123"));
// => TypeError("Non-number string can't be converted")

console.log(kansuji("123", { wide: true }));
// => "百二十三"

console.log(kansuji(Infinity));
// => TypeError("Infinity can't be converted")

console.log(kansuji(NaN));
// => TypeError("NaN can't be converted")

Testing

npm test

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT (See LICENSE)