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

js-hira-kata-romanize

v1.0.5

Published

ひらがなとカタカナをローマ字に変換するJavaScript向けのライブラリです。

Downloads

199

Readme

js-hira-kata-romanize

ひらがなとカタカナをローマ字に変換するJavaScript向けのライブラリです。

インストール

npm i js-hira-kata-romanize

デモ

こちら で実際の挙動を確認できます

使い方

基本的な使い方は以下のとおりです。
デフォルトはヘボン式になります。

const Romanizer = require('js-hira-kata-romanize');

const r = new Romanizer();
const roman = r.romanize('ちょうきゅうめいのちょうすけ');

console.log(roman);
// 出力: Chōkyūmeinochōsuke

訓令式を使用する場合はコンストラクタにオプションを渡します。

const r = new Romanizer(Romanizer.OPTION_SET_KUNREI);
const roman = r.romanize('ちょうきゅうめいのちょうすけ');

console.log(roman);
// 出力: Tyôkyûmeinotyôsuke

オプション

mapping

ひらがな(カタカナ)とローマ字のマッピング方式を指定します。
ヘボン式または訓令式を指定できます。

const r = new Romanizer({
    mapping: Romanizer.MAPPING_KUNREI
});
const roman = r.romanize('ちょうきゅうめいのちょうすけ');

console.log(roman);
// 出力: Tyôkyûmeinotyôsuke

| 値 | 説明 | | --- | --- | | MAPPING_HEPBURN(デフォルト) | ヘボン式を使用します。 例)Chōkyūmeinochōsuke | | MAPPING_KUNREI | 訓令式を使用します。例)Tyōkyūmeinotyōsuke |

chouon

長音の変換方式を指定できます。

const r = new Romanizer({
    chouon: Romanizer.CHOUON_CIRCUMFLEX
});
const roman = r.romanize('ちょうきゅうめいのちょうすけ');

console.log(roman);
// 出力: Tyôkyûmeinotyôsuke

| 値 | 説明 | | --- | --- | | CHOUON_MACRON(デフォルト) | マクロン記号を用います。例)Tōkyō | | CHOUON_CIRCUMFLEX | サーカムフレックス記号を用います。例)Tôkyô | | CHOUON_ALPHABET | 母音のローマ字を用います。例)Toukyou | | CHOUON_SKIP | 長音を無視します。例)Tokyo | | CHOUON_HYPHEN | ハイフンを用います。例)To-kyo-|

upper

大文字化の方式を指定できます。

const r = new Romanizer({
    upper: Romanizer.UPPER_WORD_INITIAL,
});
const roman = r.romanize('ちょうきゅうめいのちょうすけ');

console.log(roman);
// 出力: Tyôkyûmeinotyôsuke

| 値 | 説明 | | --- | --- | | UPPER_WORD_INITIAL(デフォルト) | 単語の先頭の文字を大文字にします。例)Mikan Ringo, Banana Tomato. Pain | | UPPER_SENTENCE_INITIAL | 文の先頭の文字を大文字にします。例)Mikan ringo, banana tomato. Pain | | UPPER_ALL | 全ての文字を大文字にします。例)MIKAN RINGO, BANANA TOMATO. PAIN | | UPPER_NONE | 何もしません。 |

オプションセットについて

Romanizer.OPTION_SET_HEPBURNRomanizer.OPTION_SET_KUNREIは上記のオプションを組み合わせたデフォルトのセットです。

static OPTION_SET_HEPBURN = {
    mapping: Romanizer.MAPPING_HEPBURN,
    chouon: Romanizer.CHOUON_MACRON,
}
static OPTION_SET_KUNREI = {
    mapping: Romanizer.MAPPING_KUNREI,
    chouon: Romanizer.CHOUON_CIRCUMFLEX,
}

Development

Release

npm publish