npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

kanji

v0.19.3

Published

Get kanji readings, kanji composition trees, and groupings

Downloads

412

Readme

Kanji

With Kanji you can:

  • Get readings information of kanji characters.
  • Get kanji characters in an array based on categorization.
  • Get kanji composition tree.


Demo

Usage as Module

Kanji Readings

Get the readings of kanji

const kanji = require('kanji');

kanji.readings('食')
/* Result:
{
  on: [ 'ショク', 'ジキ' ],
  kun: [ 'く.う', 'く.らう', 'た.べる', 'は.む' ],
  nanori: [ 'ぐい' ]
}
*/

Kanji Collections

// Kanji Kentei
console.log(kanji.kanken.lv10());
console.log(kanji.kanken.lv09());
console.log(kanji.kanken.lv08());
console.log(kanji.kanken.lv07());
console.log(kanji.kanken.lv06());
console.log(kanji.kanken.lv05());
console.log(kanji.kanken.lv04());
console.log(kanji.kanken.lv03());
console.log(kanji.kanken.lv02pre());
console.log(kanji.kanken.lv02());
console.log(kanji.kanken.lv01pre());
console.log(kanji.kanken.lv01());

// Old JLPT
console.log(kanji.jlpt.old4());
console.log(kanji.jlpt.old3());
console.log(kanji.jlpt.old2());
console.log(kanji.jlpt.old1());

// New JLPT
console.log(kanji.jlpt.n5());
console.log(kanji.jlpt.n4());
console.log(kanji.jlpt.n3());
console.log(kanji.jlpt.n2());
console.log(kanji.jlpt.n1());

// Kyouiku Kanji
console.log(kanji.grade.g01());
console.log(kanji.grade.g02());
console.log(kanji.grade.g03());
console.log(kanji.grade.g04());
console.log(kanji.grade.g05());
console.log(kanji.grade.g06());
console.log(kanji.grade.g08()); // Remaining of Joyo Kanji
console.log(kanji.grade.g09()); // Jinmeiyo Kanji
console.log(kanji.grade.g10()); // Variant of Joyo Kanji

// Frequency 1-2501 Kanji taken from KANJIDIC
// The frequency list is made by Alexandre Girardi
console.log(kanji.freq());

// 13,108 kanji from KANJIDIC (JIS X 0208-1998, JIS X 0212-1990, JIS X 0213-2012())
console.log(kanji.all());

The kanji characters in the frequency list array are ordered from most popular to least popular. The rest of arrays are not ordered.

Related Kanji

console.log(kanji.related.antonyms());
console.log(kanji.related.lookalikes());
console.log(kanji.related.synonyms());
console.log(kanji.related.variants());

Kanji Composition Tree

const kanji = require('kanji');

console.log(kanji.kanjiTree('国'));

/* Result:
{
    element: "国",
    g: [{
            element: "囗"
        },
        {
            element: "玉",
            g: [{
                    element: "王"
                },
                {
                    element: "丶"
                }
            ]
        },
        {
            element: "囗"
        }
    ]
}
*/

Notes

Everytime you call the functions above, it reads the json file from the data or dist folder. If you call the same function frequently, please use memoization techniques to reduce file read.

Usage as CLI Tool

Install kanji tool

npm install -g kanji

Show kanji Tree

kanji-tree 焼き鳥

Output

├─ 焼
│  ├─ 火
│  └─ 尭
│     ├─ 卉
│     │  ├─ 十
│     │  └─ 廾
│     │     ├─ 十
│     │     ├─ 丿
│     │     └─ 十
│     └─ ?
│        ├─ 兀
│        │  └─ 一
│        └─ 儿
│           └─ 丿
├─ ?
└─ 鳥
   └─ 灬

Development

Preparation

npm install
npm run download-source
npm run extract-data

Watch

npm run watch

Testing

npm test

Compile

npm run compile

Acknowledgment

The items are collected from following sources:

  • JLPT Study by Peter van der Woude https://jlptstudy.net
  • Jonathan Waller JLPT Kanji List http://www.tanos.co.uk/jlpt/
  • KANJIDIC Project http://www.edrdg.org/wiki/index.php/KANJIDIC_Project
  • 日本漢字能力検定級別漢字表 https://www.kanken.or.jp/kanken/outline/degree.html
  • KanjiVG by Ulrich Apel https://github.com/KanjiVG/kanjivg
  • Kanjium by Uros Ozvatic https://github.com/mifunetoshiro/kanjium

Authors

See also the list of contributors who participated in this project.

License

Copyright © 2020 Ezzat Chamudi

Kanji code is licensed under MPL-2.0. Images, logos, docs, and articles in this project are released under CC-BY-4.0.

Libraries, dependencies, and tools used in this project are tied with their licenses.