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

jaco

v4.0.0

Published

Japanese Character Optimizer.

Downloads

6,706

Readme

jaco

Japanese Character Optimizer. [English | 日本語]

NPM version Coverage Status Build Status Dependency Status devDependency Status

これは何

日本語の文字を最適化するモジュールです。

ひらがな・カタカナの相互変換や五十音順の自然ソート、半角・全角の相互変換ができます。

全てカタカナの文字列かどうかや、一部カタカナを含んでいるかなどの判定も可能なので、フォームのバリデーションなどに利用できます。

主な機能

  • ひらがな・カタカナ判定
  • ひらがな・カタカナ相互変換
  • 半角・全角判定
  • 半角・全角相互変換
  • 五十音順の自然ソート
    • 平音・濁音、長音、繰り返し記号対応
  • ビルトイン文字列オブジェクト API 互換

インストール

NPM からのインストール

$ yarn add jaco

CI としてインストール

$ npm i -g jaco

使い方

// 部分的に関数をインポートして使用する
import toKatakana from 'jaco/fn/toKatakana';
import toHiragana from 'jaco/fn/toHiragana';

toKatakana('ニホンゴのモジなど'); // => ニホンゴノモジナド
toHiragana('ニホンゴのモジなど'); // => にほんごのもじなど
// インスタンスを生成して使用する
import Jaco from 'jaco';

new Jaco('ニホンゴのモジなど').toKatakana(); // => ニホンゴノモジナド

コマンドライン

Usage: jaco [options] <path or string>

Options:

  -V, --version                      output the version number
  -K, --katakanize <path or string>  convert to Katakana
  -H, --hiraganize <path or string>  convert to Hiragana
  -h, --help                         output usage information

関数

| 関数名 | 引数 | 内容 | | ---------------------------- | ---------------------------------- | -------------------------------------------------------------------------- | | addSemivoicedMarks | str | 半濁点を追加する | | addVoicedMarks | str | 濁点を追加する | | byteSize | str | 文字列のバイトサイズを返す | | charAt | str [, index] | 文字列から指定位置の文字を返す | | charCodeAt | str [, index] | 指定位置の Unicode コードポイントを返す | | combinateSoundMarks | str [, convertOnly] | 濁点・半濁点とひらがな・かたかなを結合させる | | concat | ...str | 再帰的に文字列連結をおこなう | | convertIterationMarks | str | 繰り返し記号をかなに置き換える | | convertProlongedSoundMarks | str | 長音符をかなに置き換える | | endWith | str, search [, position] | 引数に指定された文字列が末尾と合致するか | | has | str, characters | 該当の文字のいずれかを含んでいるかどうか | | hasSmallLetter | str | 小書き文字を含むかどうか | | hasSurrogatePair | str | サロゲートペア文字列を含んでいるかどうか | | hasUnpairedSurrogate | str | ペアになっていないサロゲートコードポイントを含んでいるかどうか | | includes | str, search [, position] | 指定された文字列が最初に現れるインデックスを返す | | indexOf | str, search [, fromIndex] | 指定された文字列が最初に現れるインデックスを返す | | is | str, target | 完全マッチ | | isEmpty | str | 文字が空かどうか | | isNumeric | str [, negative [, floatingPoint]] | 数字だけで構成されているかどうか | | isOnly | str, characters | 該当の文字だけで構成されているかどうか | | isOnlyHiragana | str | ひらがなだけで構成されているかどうか | | isOnlyKatakana | str | カタカナだけで構成されているかどうか | | lastIndexOf | str, search [, fromIndex] | 指定された文字列が最後に現れるインデックスを返す | | matches | str, regexp | 正規表現に対する文字列のマッチングの際に、そのマッチ結果を純粋な配列で得る | | naturalKanaOrder | a, b | 配列の五十音順ソートをするためのソート関数 | | naturalKanaSort | array | 配列の五十音順ソートをする | | padEnd | str, targetLength [, padString] | 最終的な文字列が指定された長さに到達するように文字列で延長する | | padStart | str, targetLength [, padString] | 最終的な文字列が指定された長さに到達するように文字列を先頭に追加する | | remove | str, pattern | 文字列を取り除く | | removeUnpairedSurrogate | str | ペアになっていないサロゲートコードポイントの削除 | | removeVoicedMarks | str [, ignoreSingleMark] | 濁点・半濁点を取り除く | | repeat | str, times | 文字列を繰り返す | | replace | str, pattern, replacement | 文字列をパターンで置換する | | replaceFromMap | str, convMap | キーがパターン・値が置換文字列のハッシュマップによって置換する | | search | str, pattern | 正規表現にマッチしたインデックスを返す | | slice | str, start [, end] | 文字位置による抽出 | | split | str, separator | 文字列の配列に分割する | | startsWith | str, search [, position] | 引数に指定された文字列が先頭と合致するか | | substr | str, start [, length] | 指定した位置から指定した数だけ文字列を抽出 | | substring | str, indexA, indexB | 指定した位置の間の文字列を抽出 | | test | str, pattern | パターンとマッチするかどうか | | toBasicLetter | str | 小書き文字を基底文字に変換する | | toHiragana | str [, isCombinate] | ひらがなに変換する | | toKatakana | str [, toWide] | カタカナに変換する | | toNarrow | str [, convertJapaneseChars] | 半角に変換 | | toNarrowAlphanumeric | str | 英数字を半角に変換 | | toNarrowJapanese | str | カタカナと日本語で使われる記号を半角に変換 | | toNarrowKatakana | str [, fromHiragana] | 半角カタカナに変換する | | toNarrowSign | str | 記号を半角に変換 | | toNarrowSymbolForJapanese | str | 日本語で使われる記号を半角に変換 | | toNumeric | str [, negative [, floatingPoint]] | 数字に変換する | | toPhoeticKana | str | よみの文字に変換する | | toWide | str | 全角に変換 | | toWideAlphanumeric | str | 英数字を全角に変換 | | toWideJapanese | str | カタカナと日本語で使われる記号を全角に変換 | | toWideKatakana | str | 全角カタカナに変換する | | toWideSign | str | 記号を全角に変換 | | toWideSymbolForJapanese | str | 日本語で使われる記号を全角に変換 |