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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wakamejs/core

v0.2.0

Published

Readme

@wakamejs/core

Wakame のコアパッケージです。日本語テキストを意味的な単位へ分割し、自然な折り返し位置(ゼロ幅スペースの挿入位置など)を決定するための基盤インターフェースとコア機能を提供します。

特徴

  • 最小限のフットプリント: 外部依存関係を持たない軽量な設計
  • プラガブルなトークナイザー: Tokenizer インターフェースを実装することで、任意の形態素解析器やルールベースのトークナイザーを接続可能
  • 辞書インターフェース: カスタム辞書(単語セット)を扱うための正規化されたインターフェース

インストール

pnpm add @wakamejs/core
# または
npm install @wakamejs/core
# または
yarn add @wakamejs/core

通常は、形態素解析器を提供するトークナイザーパッケージ(@wakamejs/sudachi など)や、フレームワーク統合パッケージ(@wakamejs/vite、@wakamejs/astro)と一緒に利用します。

使い方

import { createWakame, type Tokenizer } from "@wakamejs/core";

// カスタムトークナイザーの例
const customTokenizer: Tokenizer<string> = {
    async tokenize(text, dictionary) {
        // 形態素解析や単語分割のロジック
        return text.split(/(?<=[、。])/);
    },
};

// Wakame インスタンスの作成
const wakame = createWakame({
    tokenizer: customTokenizer,
    dictionary: ["東京特許許可局"], // オプションのカスタム辞書
});

// テキストのトークナイズ
const tokens = await wakame.tokenize("こんにちは。今日は良い天気ですね。");
console.log(tokens);

API リファレンス

createWakame(options)

Wakame インスタンスを生成します。

オプション (CreateWakameOptions<TToken, TEntry>)

| プロパティ | 型 | 必須 | 説明 | | :----------- | :-------------------------- | :----- | :----------------------------------------------------- | | tokenizer | Tokenizer<TToken, TEntry> | はい | トークナイズ処理を行う Tokenizer 実装 | | dictionary | DictionaryInput<TEntry> | いいえ | トークナイザーに渡すカスタム辞書(Iterable<TEntry>) |

インターフェース

Wakame<TToken>

createWakame が返すオブジェクトです。

  • tokenize(text: string): Promise<readonly TToken[]>: テキストをトークナイズしてトークンの配列を返します。

Tokenizer<TToken, TEntry>

トークナイザーパッケージが実装するインターフェースです。

  • tokenize(text: string, dictionary: Dictionary<TEntry>): Promise<readonly TToken[]>: 指定されたテキストと正規化済み辞書を受け取り、トークン配列を返します。
  • runtime?: RuntimeTokenizerDescriptor: 動的な UI テキストを同期処理できる runtime factory のシリアライズ可能な descriptor(任意)です。

RuntimeTokenizerDescriptor

module、export、JSON-safe な options で runtime module の factory を指定します。factory は (options, context) を受け取り、context.dictionary には正規化済み辞書が JSON-safe な配列で渡されます。factory は RuntimeTokenizer を返し、segment(text) から同期的な文字列トークン配列を提供します。実行時にロードできない parser を注入した tokenizer では descriptor を省略してください。

Dictionary<TEntry>

トークナイザーに渡される正規化された辞書型です(ReadonlySet<TEntry>)。

DictionaryInput<TEntry>

createWakame のオプションに渡せる辞書型です(Iterable<TEntry>)。

関連パッケージ

ライセンス

MIT