@leonsk32/japanese-numeral-utils
v1.0.1
Published
Utilities for handling Japanese numerals.
Downloads
12,422
Readme
japanese-numeral-utils
Utilities for handling Japanese numerals.
Installation
$ npm install @leonsk32/japanese-numeral-utils --save
Usage
import {
fullWidthAlphabet2HalfWidthAlphabet,
isFullWidthAlphabetical,
isKanjiNumeric,
kanji2Arabic,
halfWidthText2FullWidthText
} from "@leonsk32/japanese-numeral-utils";
console.log(kanji2Arabic("九千八百七十六兆五千四百三十二億九千八百七十六万五千四百三十二"));
// "9876543298765432"
console.log(kanji2Arabic("一二三四五六七八九〇"));
// "1234567890"
console.log(kanji2Arabic("四百五千")); // invalid kanji number
// throw TypeError
console.log(isKanjiNumeric("〇一二三四五六七八九"));
// true
console.log(isKanjiNumeric("123"));
// false
console.log(fullWidthAlphabet2HalfWidthAlphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
// "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
console.log(fullWidthAlphabet2HalfWidthAlphabet("ABCD"));
// "ABCD"
console.log(isFullWidthAlphabetical("ABCabc"));
// true
console.log(isFullWidthAlphabetical("abcABC"));
// false
console.log(halfWidthText2FullWidthText("アカサABCz123abc"))
// "アカサABCz123abc"
console.log(halfWidthText2FullWidthText("あABCい"))
// "あABCい"