@leonsk32/japanese-numeral-utils
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

japanese-numeral-utils

Utilities for handling Japanese numerals.

Latest NPM release MIT License

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い"

Readme

Keywords

none

Package Sidebar

Install

npm i @leonsk32/japanese-numeral-utils

Weekly Downloads

1,572

Version

1.0.1

License

MIT

Unpacked Size

10.1 kB

Total Files

6

Last publish

Collaborators

  • leonsk32