sorted-joyo-kanji
v0.2.0
Published
Sorted array of the Joyo Kanji
Downloads
31,024
Readme
sorted-joyo-kanji
Sorted array of joyo-kanji
Installation
npm:
npm install sorted-joyo-kanji
Usage
var assert = require('power-assert')
var joyoKanji = require('sorted-joyo-kanji')
var each = require('amp-each')
var codePoint = require('code-point')
describe('JoyoKanjiTest', () => {
it('array length check', () => {
var kanji = joyoKanji.kanji
var codepoint = joyoKanji.codepoint
assert(kanji.length === 2136)
assert(codepoint.length === 2136)
})
it('array sort check', () => {
var codepoint = joyoKanji.codepoint
each(codepoint, (item, index) => {
if (index < codepoint.length - 1) {
assert(codepoint[index] < codepoint[index + 1])
}
})
})
it('isJoyo', () => {
assert(joyoKanji.isJoyo('聡') === false)
assert(joyoKanji.isJoyo('明') === true)
assert(joyoKanji.isJoyo('推') === true)
assert(joyoKanji.isJoyo('敲') === false)
})
})
API
sorted-joyo-kanji.kanji
kanji
— Sorted array of the Joyo Kanji.["一","丁","七","万","丈","三","上","下","不","与","且","世", ...]
sorted-joyo-kanji.codepoint
codepoint
— Sorted array of UTF-16-encoded code point number.[19968,19969,19971,19975,19976,19977,19978,19979,19981, ...]
sorted-joyo-kanji.isJoyo(value)
- Joyo Kanji check using sorted codepoint array and binary search.
Parameters
value
— a kanji character.