Documentation
Introduction

Introduction to es-hangul

npm version (opens in a new tab) npm (opens in a new tab)

When developing products that handle Hangul, tasks such as initial consonant search and accurate particle attachment often need to be performed. In addition, there are cases where you need to separate or combine Hangul elements like initial consonants, vowels, and final consonants. es-hangul helps to easily and quickly implement these frequently occurring Hangul-related functions in business.

es-hangul provides an interface for complex Hangul string processing, including extraction and conversion of initial, medial, and final consonants. By combining the functions of es-hangul with basic JavaScript methods, you can handle all cases of Hangul string processing.


Key features

Lightweight and Tree-shakable

By using ECMAScript Modules, you can include only the functions you use in your application. For example, if you use the josa function, only the related logic is included in the application. Additionally, by providing the minimum necessary code for handling Hangul, you can reduce the size of the JavaScript downloaded by users. es-hangul's bundle size (opens in a new tab)

Battle-tested

We strive to test all features with the goal of achieving 100% coverage.

codecov (opens in a new tab)

TypeScript Support

Our library provides strong typing, allowing for easy detection of type errors during the development phase.

Full Support for Hangul-related Features

Our library provides a modern API that can be conveniently used in various applications.

First Consonant Search (getChoseong)

It can get choseong from specific word. For example, you can easily find out if the word '라면' (ramyeon) contains the choseong 'ㄹㅁ'.

import { getChoseong } from 'es-hangul';
 
const searchWord = '라면';
const userInput = 'ㄹㅁ';
 
const result = getChoseong(searchWord); // ㄹㅁ
 
// Check if the 'choseong' of the search word match the user input
if (result === userInput) {
  something();
}

Disassembling Hangul Characters (disassemble)

You can decompose a given Hangul string into initial consonants, vowels, and final consonants, and return it in array form to allow for more detailed analysis or modification of the string.

import { disassemble } from 'es-hangul';
 
const word = '안녕하세요';
const disassembled = disassemble(word);
console.log(disassembled); // 'ㅇㅏㄴㄴㅕㅇㅎㅏㅅㅔㅇㅛ'

Handling Particles (josa)

It automatically selects the appropriate particle based on whether the last letter of a word has a final consonant or not.

import { josa } from 'es-hangul';
 
const word1 = '사과';
const sentence1 = josa(word1, '을/를') + ' 먹었습니다.';
console.log(sentence1); // '사과를 먹었습니다.'
 
const word2 = '바나나';
const sentence2 = josa(word2, '이/가') + ' 맛있습니다.';
console.log(sentence2); // '바나나가 맛있습니다.'

Fast

es-hangul boasts top-notch performance, efficiently handling complex tasks such as Korean character composition and decomposition with incredible speed. Benchmark tests against other libraries have shown that es-hangul delivers overwhelmingly superior performance.

If you have a good idea for handling Hangul well, please let us know. Suggest a feature via GitHub Issue (opens in a new tab)

Who's using?


Please add the logo of the organization using es-hangul. We are creating this library together. Add user with GitHub PR (opens in a new tab)