Skip to the content

Hikidashi引き出し

Era dates (和暦) and kanji numerals both ways, the dictionary forms of a conjugated word, a reading shared out over its kanji, words pulled from pasted text, and how hard a sentence is to read.

Hikidashi (引き出し) is a drawer: each tool is pulled out when it is wanted. About the name

Contents

Reference

Kanji numerals

import { … } from "@johnmorrisdotca/hikidashi/numerals";

1.8 kB minified and gzipped, with everything it imports (measured with esbuild)

漢数字: numbers, in both directions between the two ways of writing them.

一億二千万 is a number a learner meets in a news headline and cannot read, and 120,000,000 is a number they can read and cannot write. Japanese counts in ten-thousands rather than thousands (万, 億, 兆, each one 10,000 times the last), which is why 120 million is "twelve thousand ten-thousands" and why reading one off a page is a different skill from reading the digits. That grouping is the whole of this module.

  • parseJapaneseNumber reads 一億二千万, 1億2000万, 2万5千 or 120000000 and gives 120000000, or null.
  • writeJapaneseNumber writes it back, and with formal the way a contract or a banknote does: 壱万.
  • readJapaneseNumber says it aloud in hiragana, with the sound changes (さんびゃく, はっぴゃく).
  • parseEnglishNumber reads "five hundred", "twenty-five" and the magnitudes in romaji ("5 man").

Whole numbers from 0 to 9,007,199,254,740,991 only: past that JavaScript stops counting exactly, and a number the runtime cannot hold is worse than one that is not offered.

Exports

NameKindWhat it is
LARGEST_JAPANESE_NUMBERconstantThe largest number this module will answer for: 9,007,199,254,740,991, JavaScript's largest safe integer.
parseEnglishNumberfunctionThe value of a number written in words, or null when it is not one.
parseJapaneseNumberfunctionThe value of a number written in Japanese, or null when it is not one.
readJapaneseNumberfunctionThe number said aloud, in hiragana, with the sound changes a learner has to know: 300 is さんびゃく, 600 ろっぴゃく, 800 はっぴゃく, 3,000 さんぜん, 8,000 はっせん, and 一兆 いっちょう.
writeJapaneseNumberfunctionThe number as Japanese writes it, in kanji.

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/hikidashi 1.1.0.