npm's personal messenger

    jskana
    DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/jskana package

    0.1.1 • Public • Published

    jskana

    Japanese kana and romaji conversion.

    Installation

    npm install jskana --save
     
    yarn add jskana

    Documentation

    Writing system checks

    isHiragana(str, include_punctuation)

    Returns true if all characters in str is hiragana or whitespace.

    If include_punctuation is true, punctuation characters will also be accepted.

    isKatakana(str, include_punctuation)

    Returns true if all characters in str is katakana or whitespace.

    If include_punctuation is true, punctuation characters will also be accepted.

    isKanji(str, include_punctuation)

    Returns true if all characters in str is kanji or whitespace.

    If include_punctuation is true, punctuation characters will also be accepted.

    isRomaji(str, include_punctuation)

    Returns true if all characters in str is romaji or whitespace.

    If include_punctuation is true, punctuation characters will also be accepted.

    isPunctuation(str)

    Returns true if all characters in str is punctuation or whitespace.

    String split

    splitKanaString(str)

    Splits a hiragana or katakana string into separate characters, grouped with small characters.

    Example: 'あっさり' will return ['あっ', 'さ', 'り'].

    Kana conversion

    hiraganaToKatakana(str)

    Return a string based on str where all hiragana characters are replaced with katakana.

    katakanaToHiragana(str)

    Return a string based on str where all katakana characters are replaced with hiragana.

    kanaToRomaji(str)

    Returns a string based on str where all hiragana and katakana are replaced with romaji.

    romajiToHiragana(str)

    Returns a string based on str with all romaji replaced with hiragana.

    romajiToKatakana(str)

    Returns a string based on str with all romaji replaced with katakana.

    Examples

    const jskana = require('jskana');
     
    jskana.isHiragana('かに さん。 にぎりめし より')
    > true
     
    jskana.isKatakana('アメリカ XYZ')
    > false
     
    jskana.isKanji('日一大年中')
    > true
     
    jskana.isPunctuation('『モー人本あっ』')
    > false
     
    jskana.splitKanaString('あっさり')
    > ['あっ', '', '']
     
    jskana.hiraganaToKatakana('「うまい もも こっちゃ こい。 にがい もも あっちゃ いけ。」 と いったら、 ')
    > '「ウマイ モモ コッチャ コイ。 ニガイ モモ アッチャ イケ。」 ト イッタラ、 '
     
    jskana.kanaToRomaji('こちゃに れもんを いれます。')
    > 'kochani remonwo iremasu。'
     
    jskana.romajiToHiragana('kochani remonwo iremasu')
    > 'こちゃに れもんを いれます'

    Install

    npm i jskana

    DownloadsWeekly Downloads

    160

    Version

    0.1.1

    License

    MIT

    Unpacked Size

    18.8 kB

    Total Files

    8

    Last publish

    Collaborators

    • eclaesson