Wondering what’s next for npm?Check out our public roadmap! »

    sorted-joyo-kanji

    0.2.0 • Public • Published

    sorted-joyo-kanji js-standard-style

    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.

    Related

    License

    MIT

    Install

    npm i sorted-joyo-kanji

    DownloadsWeekly Downloads

    5,151

    Version

    0.2.0

    License

    MIT

    Last publish

    Collaborators

    • avatar