kansuji
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 = ; console;// => "百二十三" console;// => "一万二千三百四十五" console;// => "一二三四五" console;// => "一〇〇一" console;// => "一万千百十一" console;// => "一万一千一百一十一" console;// => "一万一千一百十一" console;// => "十二・三四" console;// => "百二十三" console;// => "百二十三" console;// => "百二十三" console;// => "〇一二三" console;// => "百二十三・四五六" console;// => TypeError("Non-number string can't be converted") console;// => "百弐拾参" console;// => "拾弐億参千四百五拾六万七千八百九拾" console;// => "壱弐参" console;// => "拾弐億参阡肆佰伍拾陸萬漆阡捌佰玖拾" console;// => TypeError("Non-number string can't be converted") console;// => "百二十三" console;// => TypeError("Infinity can't be converted") console;// => TypeError("NaN can't be converted")
Testing
npm test
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
License
MIT (See LICENSE)