UNPKG

romanize-string

Version:

A fully typed, general-purpose utility for unidirectional string transliteration (non-Latin script => Latin script).

28 lines (27 loc) 821 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HangulTree = void 0; const unicode_js_1 = require("../constants/unicode.js"); const interval_tree_js_1 = require("./interval-tree.js"); class HangulTree extends interval_tree_js_1.IntervalTree { constructor() { super(); Object.entries(unicode_js_1.HANGUL_BLOCKS).forEach(([block, { start, end }]) => { super.insert(start, end, block); }); } isHangulChar(char) { const code = char.charCodeAt(0); return super.exists(code); } isHangul(str) { for (const char of str) { if (!this.isHangulChar(char)) { return false; } } return true; } } exports.HangulTree = HangulTree; exports.default = HangulTree;