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

@oiyonet/hangul-math

v1.0.0

Published

Zero-dependency, pure mathematical Korean Hangul Unicode engine: Choseong/Jungseong/Jongseong decomposition, automatic Josa attacher, official Revised Romanization, and Hangul search MCP.

Readme

@oiyonet/hangul-math

Zero-dependency, pure mathematical Korean Hangul Unicode engine: Choseong/Jungseong/Jongseong decomposition, automatic Josa attacher with Rieul (ㄹ) exception handling, official Revised Romanization, and Hangul search MCP server.

npm version License: MIT


Why @oiyonet/hangul-math?

When AI agents generate Korean text or build Korean search features, they consistently make grammatical postposition mistakes (홍길동를, 사과이) or struggle with initial consonant indexing (초성 검색).

Existing packages are often unmaintained, bundle massive dictionary assets, or fail in modern Edge/Cloudflare/Bun environments.

@oiyonet/hangul-math provides:

  • 100% Zero-Dependency: Ultra-lightweight (<6KB), runs purely on Unicode math ((code - 0xAC00) offset arithmetic).
  • Universal Runtime: Works in Node.js, Browsers, Cloudflare Workers, Edge runtimes, Bun, and Deno.
  • Flawless Josa Attacher: Handles regular batchim, numbers (101 -> 101은), and grammatical exceptions like the Rieul (ㄹ) rule for 으로/로 (서울 + 로 = 서울로, 부산 + 으로 = 부산으로).
  • Official Romanization: Implements the official Revised Romanization of Korean (국어의 로마자 표기법 - 문화체육관광부 고시 제2014-42호).
  • Dual MCP & CLI: Ready-to-use MCP tools for AI coding agents (hangul-mcp) and terminal CLI (hangul-math).

1. Quick Start (CLI)

# 1. Automatic Postposition (조사) attachment
npx @oiyonet/hangul-math josa "홍길동" "은/는"   # => 홍길동은
npx @oiyonet/hangul-math josa "사과" "을/를"     # => 사과를
npx @oiyonet/hangul-math josa "서울" "으로/로"   # => 서울로 (ㄹ 받침 특례!)
npx @oiyonet/hangul-math josa "부산" "으로/로"   # => 부산으로

# 2. Extract Choseong (초성)
npx @oiyonet/hangul-math choseong "인공지능 에이전트" # => ㅇㄱㅈㄴ ㅇㅇㅈㅌ

# 3. Choseong Search Matching
npx @oiyonet/hangul-math match "서울특별시 종로구" "ㅅㅇ" # => true

# 4. Official Revised Romanization
npx @oiyonet/hangul-math romanize "독도"       # => Dokdo
npx @oiyonet/hangul-math romanize "부산 해운대" # => Busan Haeundae

2. MCP Server Configuration

Add hangul-mcp to your agent configuration (~/.claude/settings.json, Cursor MCP settings, or Antigravity config):

{
  "mcpServers": {
    "hangul": {
      "command": "npx",
      "args": ["-y", "@oiyonet/hangul-math"]
    }
  }
}

Available MCP Tools:

  1. attach_josa
    • Attaches the grammatically correct Korean postposition (은/는, 이/가, 을/를, 과/와, 으로/로, 아/야, 이어/여, 이란/란).
  2. extract_choseong
    • Extracts initial consonants from text for search index generation.
  3. match_choseong_search
    • Checks if a search query matches target text using choseong search.
  4. romanize_korean
    • Converts Korean names, places, and terms into official Revised Romanization.
  5. dissect_syllable
    • Returns initial, vowel, and final consonants (choseong, jungseong, jongseong, hasBatchim) with Unicode offset indices.

3. Programmatic Usage (Node.js / TypeScript)

import {
  josa,
  hasBatchim,
  extractChoseong,
  matchChoseong,
  romanize,
  dissect,
} from '@oiyonet/hangul-math';

// 1. Grammatical Postpositions
console.log(josa('사용자', '이/가')); // "사용자가"
console.log(josa('선생님', '이/가')); // "선생님이"
console.log(josa('글로벌', '으로/로')); // "글로벌로" (ㄹ 받침)

// 2. Choseong Fuzzy Search
const contacts = ['강남역', '서울역', '홍대입구'];
const query = 'ㅅㅇ';
const filtered = contacts.filter((c) => matchChoseong(c, query));
console.log(filtered); // ['서울역']

// 3. Official Romanization
console.log(romanize('한글')); // "Hangeul"
console.log(romanize('종로')); // "Jongno"

// 4. Character Dissection
console.log(dissect('한'));
// { char: '한', isHangul: true, choseong: 'ㅎ', jungseong: 'ㅏ', jongseong: 'ㄴ', hasBatchim: true, lIndex: 18, vIndex: 0, tIndex: 4 }

Mathematical Specification

Hangul syllables are mapped via the Unicode standard formula:

SIndex = CodePoint - 0xAC00
LIndex = floor(SIndex / (21 * 28))  // Choseong (19)
VIndex = floor((SIndex % 588) / 28) // Jungseong (21)
TIndex = SIndex % 28                // Jongseong (28)
  • Total possible syllables: $19 \times 21 \times 28 = 11,172$ combinations.

License

MIT © OIYO Lab