From 7777478895478d1e92d2d21df866130d84b84bdb Mon Sep 17 00:00:00 2001 From: Coalpha Date: Tue, 28 Aug 2018 01:38:01 -0700 Subject: [PATCH] Migration --- .gitignore | 2 + README.md | 3 + dev/bundle.js | 1710 --------------------------------------- dev/index.html | 15 - dist/cjs/Hangul.js | 1702 -------------------------------------- dist/cjs/Hangul.min.js | 1 - dist/iife/Hangul.js | 1705 -------------------------------------- dist/iife/Hangul.min.js | 1 - dist/umd/Hangul.js | 1708 -------------------------------------- dist/umd/Hangul.min.js | 1 - rollup.config.js | 9 +- 11 files changed, 8 insertions(+), 6849 deletions(-) delete mode 100644 dev/bundle.js delete mode 100644 dev/index.html delete mode 100644 dist/cjs/Hangul.js delete mode 100644 dist/cjs/Hangul.min.js delete mode 100644 dist/iife/Hangul.js delete mode 100644 dist/iife/Hangul.min.js delete mode 100644 dist/umd/Hangul.js delete mode 100644 dist/umd/Hangul.min.js diff --git a/.gitignore b/.gitignore index 153bb99..4083e11 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,5 @@ typings/ # next.js build output .next *.map +.vscode +dev \ No newline at end of file diff --git a/README.md b/README.md index 74c4686..f52c69a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ # Hangul Full disclosure: I cannot speak Korean and I can't write hangul. This library takes a lot of inspiration from hangul-js by Jaemin Jo. + +# Usage +You can download the minified library \ No newline at end of file diff --git a/dev/bundle.js b/dev/bundle.js deleted file mode 100644 index 74dc773..0000000 --- a/dev/bundle.js +++ /dev/null @@ -1,1710 +0,0 @@ -(function(l, i, v, e) { v = l.createElement(i); v.async = 1; v.src = '//' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1'; e = l.getElementsByTagName(i)[0]; e.parentNode.insertBefore(v, e)})(document, 'script'); -var Hangul = (function (exports) { - 'use strict'; - - const consonants = { - ㄱ: 1, - ㄴ: 1, - ㄷ: 1, - ㄹ: 1, - ㅁ: 1, - ㅂ: 1, - ㅅ: 1, - ㅇ: 1, - ㅈ: 1, - ㅊ: 1, - ㅋ: 1, - ㅌ: 1, - ㅍ: 1, - ㅎ: 1, - ㆁ: 1, // apparently this is now "ㅇ" - ㆄ: 1, - ㅱ: 1, - ㅿ: 1, - }; - const vowels = { - ㅏ: 1, - ㅐ: 1, - ㅑ: 1, - ㅓ: 1, - ㅔ: 1, - ㅕ: 1, - ㅖ: 1, - ㅗ: 1, - ㅛ: 1, - ㅜ: 1, - ㅠ: 1, - ㅡ: 1, - ㅣ: 1, - ㆍ: 1, - }; - const hangulToKey = { - ㅂ: 'q', - ㅃ: 'Q', - ㅈ: 'w', - ㅉ: 'W', - ㄷ: 'e', - ㄸ: 'E', - ㄱ: 'r', - ㄲ: 'R', - ㅅ: 't', - ㅆ: 'T', - ㅛ: 'y', - ㅕ: 'u', - ㅑ: 'i', - ㅐ: 'o', - ㅒ: 'O', - ㅔ: 'p', - ㅖ: 'P', - ㅁ: 'a', - ㄴ: 's', - ㅇ: 'd', - ㄹ: 'f', - ㅎ: 'g', - ㅗ: 'h', - ㅓ: 'j', - ㅏ: 'k', - ㅣ: 'l', - ㅋ: 'z', - ㅌ: 'x', - ㅊ: 'c', - ㅍ: 'v', - ㅠ: 'b', - ㅜ: 'n', - ㅡ: 'm', - }; - const keyToHangul = { - q: 'ㅂ', - Q: 'ㅃ', - w: 'ㅈ', - W: 'ㅉ', - e: 'ㄷ', - E: 'ㄸ', - r: 'ㄱ', - R: 'ㄲ', - t: 'ㅅ', - T: 'ㅆ', - y: 'ㅛ', - u: 'ㅕ', - i: 'ㅑ', - o: 'ㅐ', - O: 'ㅒ', - p: 'ㅔ', - P: 'ㅖ', - a: 'ㅁ', - s: 'ㄴ', - d: 'ㅇ', - f: 'ㄹ', - g: 'ㅎ', - h: 'ㅗ', - j: 'ㅓ', - k: 'ㅏ', - l: 'ㅣ', - z: 'ㅋ', - x: 'ㅌ', - c: 'ㅊ', - v: 'ㅍ', - b: 'ㅠ', - n: 'ㅜ', - m: 'ㅡ', - }; - // the reason the data is stored like this is because iterating - // through an array is slower than just getting a key from an object - // In this case though, it might be faster since arrays are allocated - // on the heap instead of the stack? - - // I realize that I can programmatically reverse the key-value pairs during - // runtime but since I can just do it now, it's just a little faster. - - const cho = { - ㄱㄱ: 'ㄲ', - ㄷㄷ: 'ㄸ', - ㅅㅅ: 'ㅆ', - ㅈㅈ: 'ㅉ', - ㅂㅂ: 'ㅃ', - }; - const jung = { - ㅗㅏ: 'ㅘ', - ㅗㅐ: 'ㅙ', - ㅗㅣ: 'ㅚ', - ㅜㅓ: 'ㅝ', - ㅜㅔ: 'ㅞ', - ㅜㅣ: 'ㅟ', - ㅡㅣ: 'ㅢ', - }; - const jong = { - ㄱㄱ: 'ㄲ', - ㄱㅅ: 'ㄳ', - ㄴㅈ: 'ㄵ', - ㄴㅎ: 'ㄶ', - ㄹㄱ: 'ㄺ', - ㄹㅁ: 'ㄻ', - ㄹㅂ: 'ㄼ', - ㄹㅅ: 'ㄽ', - ㄹㅌ: 'ㄾ', - ㄹㅍ: 'ㄿ', - ㄹㅎ: 'ㅀ', - ㅂㅅ: 'ㅄ', - ㅅㅅ: 'ㅆ', - }; - const archaic = { - ㄴㄴ: 'ㅥ', - ㄴㄷ: 'ㅦ', - ㄴㅅ: 'ㅧ', - ㄴㅿ: 'ㅨ', - ㄹㄱㅅ: 'ㅩ', - ㄹㄷ: 'ㅪ', - ㄹㅂㅅ: 'ㅫ', - ㄹㅿ: 'ㅬ', - ㄹㆆ: 'ㅭ', - ㅁㅂ: 'ㅮ', - ㅁㅅ: 'ㅯ', - ㅁㅿ: 'ㅰ', - ㅂㄱ: 'ㅲ', - ㅂㄷ: 'ㅳ', - ㅂㅅㄱ: 'ㅴ', - ㅂㅅㄷ: 'ㅵ', - ㅂㅈ: 'ㅶ', - ㅂㅌ: 'ㅷ', - ㅅㄱ: 'ㅺ', - ㅅㄴ: 'ㅻ', - ㅅㄷ: 'ㅼ', - ㅅㅂ: 'ㅽ', - ㅅㅈ: 'ㅾ', - ㅇㅇ: 'ㆀ', - ㆁㅅ: 'ㆁ', - ㆁㅿ: 'ㅿ', - ㅎㅎ: 'ㆅ', - ㅛㅑ: 'ㆇ', - ㅛㅒ: 'ㆈ', - ㅛㅣ: 'ㆉ', - ㅠㅕ: 'ㆊ', - ㅠㅖ: 'ㆋ', - ㅠㅣ: 'ㆌ', - ㆍㅣ: 'ㆎ', - }; - const pairs = { - ㄲ: ['ㄱ', 'ㄱ'], - ㄳ: ['ㄱ', 'ㅅ'], - ㄵ: ['ㄴ', 'ㅈ'], - ㄶ: ['ㄴ', 'ㅎ'], - ㄸ: ['ㄷ', 'ㄷ'], - ㄻ: ['ㄹ', 'ㅁ'], - ㄺ: ['ㄹ', 'ㄱ'], - ㄼ: ['ㄹ', 'ㅂ'], - ㄽ: ['ㄹ', 'ㅅ'], - ㄾ: ['ㄹ', 'ㅌ'], - ㄿ: ['ㄹ', 'ㅍ'], - ㅀ: ['ㄹ', 'ㅎ'], - ㅃ: ['ㅂ', 'ㅂ'], - ㅄ: ['ㅂ', 'ㅅ'], - ㅆ: ['ㅅ', 'ㅅ'], - ㅉ: ['ㅈ', 'ㅈ'], - ㅘ: ['ㅗ', 'ㅏ'], - ㅙ: ['ㅗ', 'ㅐ'], - ㅚ: ['ㅗ', 'ㅣ'], - ㅝ: ['ㅜ', 'ㅓ'], - ㅞ: ['ㅜ', 'ㅔ'], - ㅟ: ['ㅜ', 'ㅣ'], - ㅢ: ['ㅡ', 'ㅣ'], - ㅥ: ['ㄴ', 'ㄴ'], - ㅦ: ['ㄴ', 'ㄷ'], - ㅧ: ['ㄴ', 'ㅅ'], - ㅨ: ['ㄴ', 'ㅿ'], - ㅩ: ['ㄹ', 'ㄱ', 'ㅅ'], - ㅪ: ['ㄹ', 'ㄷ'], - ㅫ: ['ㄹ', 'ㅂ', 'ㅅ'], - ㅬ: ['ㄹ', 'ㅿ'], - ㅭ: ['ㄹ', 'ㆆ'], - ㅮ: ['ㅁ', 'ㅂ'], - ㅯ: ['ㅁ', 'ㅅ'], - ㅰ: ['ㅁ', 'ㅿ'], - ㅲ: ['ㅂ', 'ㄱ'], - ㅳ: ['ㅂ', 'ㄷ'], - ㅴ: ['ㅂ', 'ㅅ', 'ㄱ'], - ㅵ: ['ㅂ', 'ㅅ', 'ㄷ'], - ㅶ: ['ㅂ', 'ㅈ'], - ㅷ: ['ㅂ', 'ㅌ'], - ㅺ: ['ㅅ', 'ㄱ'], - ㅻ: ['ㅅ', 'ㄴ'], - ㅼ: ['ㅅ', 'ㄷ'], - ㅽ: ['ㅅ', 'ㅂ'], - ㅾ: ['ㅅ', 'ㅈ'], - ㆀ: ['ㅇ', 'ㅇ'], - ㆂ: ['ㆁ', 'ㅅ'], - ㆃ: ['ㆁ', 'ㅿ'], - ㆅ: ['ㅎ', 'ㅎ'], - ㆇ: ['ㅛ', 'ㅑ'], - ㆈ: ['ㅛ', 'ㅒ'], - ㆉ: ['ㅛ', 'ㅣ'], - ㆊ: ['ㅠ', 'ㅕ'], - ㆋ: ['ㅠ', 'ㅖ'], - ㆌ: ['ㅠ', 'ㅣ'], - ㆎ: ['ㆍ', 'ㅣ'], - }; - const complex = { - ㄲ: 1, - ㄳ: 1, - ㄵ: 1, - ㄶ: 1, - ㄸ: 1, - ㄺ: 1, - ㄻ: 1, - ㄼ: 1, - ㄽ: 1, - ㄾ: 1, - ㄿ: 1, - ㅀ: 1, - ㅃ: 1, - ㅄ: 1, - ㅆ: 1, - ㅉ: 1, - ㅘ: 1, - ㅙ: 1, - ㅚ: 1, - ㅝ: 1, - ㅞ: 1, - ㅟ: 1, - ㅢ: 1, - }; - const irregularComplex = { - ㅥ: 1, - ㅦ: 1, - ㅧ: 1, - ㅨ: 1, - ㅩ: 1, - ㅪ: 1, - ㅫ: 1, - ㅬ: 1, - ㅭ: 1, - ㅮ: 1, - ㅯ: 1, - ㅰ: 1, - ㅱ: 1, - ㅲ: 1, - ㅳ: 1, - ㅴ: 1, - ㅵ: 1, - ㅶ: 1, - ㅷ: 1, - }; - const complexList = Object.assign({}, complex, irregularComplex); - // yes, I know that this is not a list. - const stronger = { - ㄱ: 'ㄲ', - ㅋ: 'ㄲ', - ㄷ: 'ㄸ', - ㅌ: 'ㄸ', - ㅂ: 'ㅃ', - ㅍ: 'ㅃ', - ㅅ: 'ㅆ', - ㅈ: 'ㅉ', - ㅊ: 'ㅉ', - }; - // I would add a weaker export - // except that I can't reverse the outputs - - const cho$1 = [ - 'ㄱ', 'ㄲ', 'ㄴ', 'ㄷ', 'ㄸ', 'ㄹ', 'ㅁ', - 'ㅂ', 'ㅃ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅉ', - 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ', - ]; - const jung$1 = [ - 'ㅏ', 'ㅐ', 'ㅑ', 'ㅒ', 'ㅓ', 'ㅔ', 'ㅕ', - 'ㅖ', 'ㅗ', 'ㅘ', 'ㅙ', 'ㅚ', 'ㅛ', 'ㅜ', - 'ㅝ', 'ㅞ', 'ㅟ', 'ㅠ', 'ㅡ', 'ㅢ', 'ㅣ', - ]; - const jong$1 = [ - null, 'ㄱ', 'ㄲ', 'ㄳ', 'ㄴ', 'ㄵ', 'ㄶ', - 'ㄷ', 'ㄹ', 'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', - 'ㄿ', 'ㅀ', 'ㅁ', 'ㅂ', 'ㅄ', 'ㅅ', 'ㅆ', - 'ㅇ', 'ㅈ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ', - ]; - const choNum = { - ㄱ: 0, - ㄲ: 1, - ㄴ: 2, - ㄷ: 3, - ㄸ: 4, - ㄹ: 5, - ㅁ: 6, - ㅂ: 7, - ㅃ: 8, - ㅅ: 9, - ㅆ: 10, - ㅇ: 11, - ㅈ: 12, - ㅉ: 13, - ㅊ: 14, - ㅋ: 15, - ㅌ: 16, - ㅍ: 17, - ㅎ: 18, - }; - const jungNum = { - ㅏ: 0, - ㅐ: 1, - ㅑ: 2, - ㅒ: 3, - ㅓ: 4, - ㅔ: 5, - ㅕ: 6, - ㅖ: 7, - ㅗ: 8, - ㅘ: 9, - ㅙ: 10, - ㅚ: 11, - ㅛ: 12, - ㅜ: 13, - ㅝ: 14, - ㅞ: 15, - ㅟ: 16, - ㅠ: 17, - ㅡ: 18, - ㅢ: 19, - ㅣ: 20, - }; - const jongNum = { - ㄱ: 1, - ㄲ: 2, - ㄳ: 3, - ㄴ: 4, - ㄵ: 5, - ㄶ: 6, - ㄷ: 7, - ㄹ: 8, - ㄺ: 9, - ㄻ: 10, - ㄼ: 11, - ㄽ: 12, - ㄾ: 13, - ㄿ: 14, - ㅀ: 15, - ㅁ: 16, - ㅂ: 17, - ㅄ: 18, - ㅅ: 19, - ㅆ: 20, - ㅇ: 21, - ㅈ: 22, - ㅊ: 23, - ㅋ: 24, - ㅌ: 25, - ㅍ: 26, - ㅎ: 27, - }; - - class UnicodeRange { - constructor(start, end) { - this.start = start; - this.end = end; - } - - containsCodePoint(num) { - return num >= this.start && num <= this.end; - } - - contains(char) { - return this.containsCodePoint(char.codePointAt(0)); - } - } - class CombinedRange { - constructor(ranges, codePoints = {}) { - this.ranges = ranges; - this.codePoints = codePoints; - } - - containsCodePoint(num) { - return ( - (this.codePoints && this.codePoints[num]) - || this.ranges.some(range => range.containsCodePoint(num)) - ); - } - - contains(char) { - const num = char.codePointAt(0); - return this.containsCodePoint(num); - } - } - - const jamo = new UnicodeRange(0x1100, 0x11FF); - const compatibilityJamo = new UnicodeRange(0x3130, 0x318F); - const jamoExtendedA = new UnicodeRange(0xA960, 0xA97F); - const syllables = new UnicodeRange(0xAC00, 0xD7AF); - const jamoExtendedB = new UnicodeRange(0xD7B0, 0xD7FF); - const halfwidth = new UnicodeRange(0xFFA0, 0xFFDF); - const reserved = new CombinedRange([ - new UnicodeRange(0xA97D, 0xA97F), // jamoExtendedA - new UnicodeRange(0xD7A4, 0xD7AF), // syllables - new UnicodeRange(0xD7C7, 0xD7CA), // jamoExtendedB - new UnicodeRange(0xD7FC, 0xD7FF), // jamoExtendedB - ], { 0x3130: 1, 0x318F: 1 }); - const standardHangul = new CombinedRange([compatibilityJamo, syllables]); - const hangul = new CombinedRange([ - jamo, - compatibilityJamo, - jamoExtendedA, - syllables, - jamoExtendedB, - halfwidth, - reserved, - ]); - - var composeSyllableFn = ((cho, jung, jong = 0) => ( - String.fromCodePoint(cho * 588 + jung * 28 + jong + syllables.start) - // this is the actual function that makes unicode syllable characters - // where the characters are mapped to numbers. Take a look at - // { choNum, jungNum, jongNum } from './unicode/syllable' - )); - - class Result { - constructor(result = '', remainder = []) { - this.result = result; - this.remainder = remainder; - } - } - - const Character = (val) => { - const str = `${val}`; - // not using .toString because Symbol.toPrimitive overrides when present - if (str.length !== 1) { - throw Error(`"${str}" is not a Character!`); - } - return str; - }; - // this function turns values into characters if it can - // otherwise it just fails - const ENOARYLIKE = () => { throw TypeError('The data must be an Array or a String!'); }; - const toArray = aryOrStr => (Array.isArray(aryOrStr) ? aryOrStr : aryOrStr.split('')); - // as a general note, calling .split like that instead of .split`` is faster - const isCharacterGroup = (val) => { - if (val.length < 1) { - return false; - } if (Array.isArray(val)) { - if (val.length > 1) { - return true; - } - return isCharacterGroup(val[0]); - } if (typeof val === 'string' && val.length > 1) { - return true; - } - return false; - }; - // while Characters can be a CharacterGroup, - // this function ignores characters - const identity = i => i; - const deepMap = (data, func, useToArray) => { - const modifier = useToArray ? toArray : identity; - if (Array.isArray(data)) { - return data.map(val => (isCharacterGroup(val) ? deepMap(val, func, useToArray) : modifier(func(val)))); - } if (typeof data === 'string') { - // since the data was a string, the array created from - // the string won't contain any character groups - return data.split('').map(char => modifier(func(char))); - } - ENOARYLIKE(); - }; - const deepFlatMap = (data, func) => { - let res = ''; - if (Array.isArray(data)) { - const len = data.length; - for (let i = 0; i < len; i++) { - // for is faster than forEach - // this function is used a lot so I'll - // take any optimization that I can get - const val = data[i]; - if (isCharacterGroup(val)) { - res += deepFlatMap(val, func); - } else { - const recurseRes = func(val); - if (isCharacterGroup(recurseRes)) { - res += deepFlatMap(recurseRes, identity); - } else { - res += recurseRes; - } - } - } - } else if (typeof data === 'string') { - const len = data.length; - for (let i = 0; i < len; i++) { - const recurseRes = func(data[i]); - if (isCharacterGroup(recurseRes)) { - res += deepFlatMap(recurseRes, identity); - } else { - res += recurseRes; - } - } - } else { - ENOARYLIKE(); - } - return res; - }; - const flatten = (data) => { - if (Array.isArray(data)) { - let res = ''; - const len = data.length; - for (let i = 0; i < len; i++) { - const val = data[i]; - if (isCharacterGroup(val)) { - res += flatten(val); - } else { - res += val; - } - } - return res; - } if (typeof data === 'string') { - return data; - } - ENOARYLIKE(); - }; - const deepFlatResMap = (data, func) => { - // this is different since it deals with functions that return Result objects. - // consumeLeftovers - let rem; - // remaining - let res = ''; - // result - if (Array.isArray(data)) { - rem = []; - const len = data.length; - for (let i = 0; i < len; i++) { - const val = data[i]; - if (isCharacterGroup(val)) { - rem.push(...deepFlatResMap(val, func)); - // deepFlatResMap always returns an array - // (or at least it should) - } else { - rem.push(val); - } - } - } else if (typeof data === 'string') { - rem = data.split(''); - // could have used toArray but since we already know - // the type of this, there's no need to - } else { - // it's not an Array or a String - ENOARYLIKE(); - } - while (rem.length) { - const comp = func(rem); - // func needs to return a Result like interface for this to work - // otherwise we'll get a really nasty to debug error - res += comp.result; - rem = comp.remainder; - } - return res; - }; - - // important note! - // these functions aren't going to really make any sense until - // you understand how they work in conjunction with the stuff - // that's in './types'. Read './Result' and './types' first. - // then read this. - const objCache = []; - const useComp3 = 0b001; - const useArchaic = 0b010; - const noUseJungJong = 0b100; - const noCompDouble = 0b1000; - const composeComplexBase = (mode) => { - // mode is being used as a bitfield - if (mode < 0 || mode > 8) { - throw Error('The mode cannot be less than zero or greater than eight!'); - } - const usingArchaic = mode & useArchaic; - const usingComp3 = usingArchaic && mode & useComp3; - const usingNoCompDouble = mode & noCompDouble; - let obj = objCache[mode]; - if (!obj) { - const objs = [cho]; - // there are no comp3 values in non archaic complex objects - if (!(mode & noUseJungJong)) { - // if you're usingJungJong - objs.push(jung, jong); - } if (usingArchaic) { - objs.push(archaic); - } - obj = Object.assign({}, ...objs); - objCache[mode] = obj; - // eslint got mad at me for chaining assignments - } - return (chars) => { - const len = chars.length; - if (len < 1) { - throw Error('Cannot compose array of zero characters!'); - } - const char1 = chars[0]; - if (len < 2) { - // if there aren't even two Characters to use - return new Result(char1); - } - const char2 = chars[1]; - if (usingNoCompDouble && char1 === char2) { - return new Result(char1, chars.slice(1)); - } - const comp2 = obj[char1 + char2]; - // comp2 = composition of 2 characters - if (comp2) { - if (usingComp3 && len > 2) { - // if there's more data, try to compose a tripple - const comp3 = obj[char1 + char2 + chars[2]]; - if (comp3) { - return new Result(comp3, chars.slice(3)); - } - } - // there's no more data or couldn't find a comp3 - return new Result(comp2, chars.slice(2)); - } - // couldn't find a comp2 - return new Result(char1, chars.slice(1)); - }; - }; - const composeComplex = (mode) => { - const cc = composeComplexBase(mode); - return ary => deepFlatResMap(ary, cc); - }; - const isVowel = char => char && char !== 'ㆍ' && vowels[char]; - var composeAnything = ((mode) => { - const cc = composeComplexBase(mode); - return (ary) => { - // while this function is named "composeSyllable", it actually - // can be used to compose anything, really. - if (ary.length < 2) { - return new Result(ary[0]); - // don't do extra computing for small operations - } - // the composeComplex function with the mode that is specified - const choRes = cc(ary); - // ^^ that's a Result object - const choChar = choRes.result; - // the result of the composition, should be a Character - const choRem = choRes.remainder; - // the remainder of the composition - const cho$$1 = choNum[choChar]; - // the number that the character is mapped to - if (choRem.length < 1 || !Number.isInteger(cho$$1)) { - // check if there's any more characters remaining - // also check if it's not an integer since 0 == false - // if it's not an integer, then return the potential - // complex or Character that was made from composeAnyComplex - return choRes; - // choRes is already a Result so no need to make another - } - const jungRes = cc(choRem); - - const jungChar = jungRes.result; - const jungRem = jungRes.remainder; - const jung$$1 = jungNum[jungChar]; - if (!Number.isInteger(jung$$1)) { - // there's no need to check to see if there's any more - // remaining since cho and jung are all that's needed - // to compose a syllable - return new Result(choChar, [jungChar, ...jungRem]); - // still only return choChar as a result since we want - // to try starting a syllable off with the jungChar next - // time this function is called - } if (jungRem.length) { - // there's no point in trying to add anything on to the complex - // if there aren't any characters left - if (!isVowel(jungRem[1])) { - // we need this part so that - // ㅁㅣㅇㅏ => 미아 - const jongRes = cc(jungRem); - - const jongChar = jongRes.result; - const jongRem = jongRes.remainder; - const jong$$1 = jongNum[jongChar]; - if (jong$$1) { - // if the character after the syllable is not a vowel - // and the jong character is valid - return new Result(composeSyllableFn(cho$$1, jung$$1, jong$$1), jongRem); - } - } - } - // there aren't any characters left - // or the character after the syllable is a vowel - // or the jong character isn't valid - return new Result(composeSyllableFn(cho$$1, jung$$1), jungRem); - // The last argument is optional for the Result constructor - }; - }); - - // if you're gonna copy this part, at least give me credit. - // I had to do all of this manually. - // also, I think turning all of these arrays into strings - // might speed up composition by a bit. - const jamo$1 = { - ᄀ: 'ㄱ', - ᄁ: ['ㄱ', 'ㄱ'], - ᄂ: 'ㄴ', - ᄃ: 'ㄷ', - ᄄ: ['ㄷ', 'ㄷ'], - ᄅ: 'ㄹ', - ᄆ: 'ㅁ', - ᄇ: 'ㅂ', - ᄈ: ['ㅂ', 'ㅂ'], - ᄉ: 'ㅅ', - ᄊ: ['ㅅ', 'ㅅ'], - ᄋ: 'ㅇ', - ᄌ: 'ㅈ', - ᄍ: ['ㅈ', 'ㅈ'], - ᄎ: 'ㅊ', - ᄏ: 'ㅋ', - ᄐ: 'ㅌ', - ᄑ: 'ㅍ', - ᄒ: 'ㅎ', - ᄓ: ['ㄴ', 'ㄱ'], - ᄔ: ['ㄴ', 'ㄴ'], - ᄕ: ['ㄴ', 'ㄷ'], - ᄖ: ['ㄴ', 'ㅂ'], - ᄗ: ['ㄷ', 'ㄱ'], - ᄘ: ['ㄹ', 'ㄴ'], - ᄙ: ['ㄹ', 'ㄹ'], - ᄚ: ['ㄹ', 'ㅎ'], - ᄛ: ['ㄹ', 'ㅇ'], - ᄜ: ['ㅁ', 'ㅂ'], - ᄝ: 'ㅱ', - ᄞ: ['ㅂ', 'ㄱ'], - ᄟ: ['ㅂ', 'ㄴ'], - ᄠ: ['ㅂ', 'ㄷ'], - ᄡ: ['ㅂ', 'ㅅ'], - ᄢ: ['ㅂ', 'ㅅ', 'ㄱ'], - ᄣ: ['ㅂ', 'ㅅ', 'ㄷ'], - ᄤ: ['ㅂ', 'ㅅ', 'ㅂ'], - ᄥ: ['ㅂ', 'ㅅ', 'ㅅ'], - ᄦ: ['ㅂ', 'ㅅ', 'ㅈ'], - ᄧ: ['ㅂ', 'ㅈ'], - ᄨ: ['ㅂ', 'ㅊ'], - ᄩ: ['ㅂ', 'ㅌ'], - ᄪ: ['ㅂ', 'ㅍ'], - ᄫ: ['ㅂ', 'ㅇ'], - ᄬ: [['ㅂ', 'ㅂ'], 'ㅇ'], - ᄭ: ['ㅅ', 'ㄱ'], - ᄮ: ['ㅅ', 'ㄴ'], - ᄯ: ['ㅅ', 'ㄷ'], - ᄰ: ['ㅅ', 'ㄹ'], - ᄱ: ['ㅅ', 'ㅁ'], - ᄲ: ['ㅅ', 'ㅂ'], - ᄳ: ['ㅅ', 'ㅂ', 'ㄱ'], - ᄴ: ['ㅅ', 'ㅅ', 'ㅅ'], - ᄵ: ['ㅅ', 'ㅇ'], - ᄶ: ['ㅅ', 'ㅈ'], - ᄷ: ['ㅅ', 'ㅊ'], - ᄸ: ['ㅅ', 'ㅋ'], - ᄹ: ['ㅅ', 'ㅌ'], - ᄺ: ['ㅅ', 'ㅍ'], - ᄻ: ['ㅅ', 'ㅎ'], - ᄼ: null, - ᄽ: null, - ᄾ: null, - ᄿ: null, - ᅀ: 'ㅿ', - ᅁ: ['ㅇ', 'ㄱ'], - ᅂ: ['ㅇ', 'ㄷ'], - ᅃ: ['ㅇ', 'ㅁ'], - ᅄ: ['ㅇ', 'ㅂ'], - ᅅ: ['ㅇ', 'ㅅ'], - ᅆ: ['ㅇ', 'ㅿ'], - ᅇ: ['ㅇ', 'ㅇ'], - ᅈ: ['ㅇ', 'ㅈ'], - ᅉ: ['ㅇ', 'ㅊ'], - ᅊ: ['ㅇ', 'ㅌ'], - ᅋ: ['ㅇ', 'ㅍ'], - ᅌ: 'ㆁ', - ᅍ: ['ㅈ', 'ㅇ'], - ᅎ: null, - ᅏ: null, - ᅐ: null, - ᅑ: null, - ᅒ: ['ㅊ', 'ㅋ'], - ᅓ: ['ㅊ', 'ㅎ'], - ᅔ: null, - ᅕ: null, - ᅖ: ['ㅍ', 'ㅂ'], - ᅗ: 'ㆄ', - ᅘ: ['ㅎ', 'ㅎ'], - ᅙ: 'ㆆ', - ᅚ: ['ㄱ', 'ㄷ'], - ᅛ: ['ㄱ', 'ㅅ'], - ᅜ: ['ㄱ', 'ㅈ'], - ᅝ: ['ㄱ', 'ㅎ'], - ᅞ: ['ㄷ', 'ㄹ'], - ᅡ: 'ㅏ', - ᅢ: 'ㅐ', - ᅣ: 'ㅑ', - ᅤ: 'ㅒ', - ᅥ: 'ㅓ', - ᅦ: 'ㅔ', - ᅧ: 'ㅕ', - ᅨ: 'ㅖ', - ᅩ: 'ㅗ', - ᅪ: ['ㅗ', 'ㅏ'], - ᅫ: ['ㅗ', 'ㅐ'], - ᅬ: ['ㅗ', 'ㅣ'], - ᅭ: 'ㅛ', - ᅮ: 'ㅜ', - ᅯ: ['ㅜ', 'ㅓ'], - ᅰ: ['ㅜ', 'ㅔ'], - ᅱ: ['ㅜ', 'ㅣ'], - ᅲ: 'ㅠ', - ᅳ: 'ㅡ', - ᅴ: ['ㅡ', 'ㅣ'], - ᅵ: 'ㅣ', - ᅶ: ['ㅏ', 'ㅗ'], - ᅷ: ['ㅏ', 'ㅜ'], - ᅸ: ['ㅑ', 'ㅗ'], - ᅹ: ['ㅑ', 'ㅛ'], - ᅺ: ['ㅓ', 'ㅗ'], - ᅻ: ['ㅓ', 'ㅜ'], - ᅼ: ['ㅓ', 'ㅡ'], - ᅽ: ['ㅕ', 'ㅗ'], - ᅾ: ['ㅕ', 'ㅜ'], - ᅿ: ['ㅗ', 'ㅓ'], - ᆀ: ['ㅔ', 'ㅗ'], - ᆁ: ['ㅖ', 'ㅗ'], - ᆂ: ['ㅗ', 'ㅗ'], - ᆃ: ['ㅗ', 'ㅜ'], - ᆄ: ['ㅛ', 'ㅑ'], - ᆅ: ['ㅛ', 'ㅒ'], - ᆆ: ['ㅛ', 'ㅕ'], - ᆇ: ['ㅛ', 'ㅗ'], - ᆈ: ['ㅛ', 'ㅣ'], - ᆉ: ['ㅜ', 'ㅏ'], - ᆊ: ['ㅜ', 'ㅐ'], - ᆋ: ['ㅜ', 'ㅓ', 'ㅡ'], - ᆌ: ['ㅜ', 'ㅖ'], - ᆍ: ['ㅜ', 'ㅜ'], - ᆎ: ['ㅠ', 'ㅏ'], - ᆏ: ['ㅠ', 'ㅓ'], - ᆐ: ['ㅠ', 'ㅔ'], - ᆑ: ['ㅠ', 'ㅕ'], - ᆒ: ['ㅠ', 'ㅔ'], - ᆓ: ['ㅠ', 'ㅜ'], - ᆔ: ['ㅠ', 'ㅣ'], - ᆕ: ['ㅡ', 'ㅜ'], - ᆖ: ['ㅡ', 'ㅡ'], - ᆗ: ['ㅡ', 'ㅣ', 'ㅜ'], - ᆘ: ['ㅣ', 'ㅏ'], - ᆙ: ['ㅣ', 'ㅑ'], - ᆚ: ['ㅣ', 'ㅗ'], - ᆛ: ['ㅣ', 'ㅜ'], - ᆜ: ['ㅣ', 'ㅡ'], - ᆝ: null, - ᆞ: 'ㆍ', - ᆟ: ['ㆍ', 'ㅓ'], - ᆠ: ['ㆍ', 'ㅜ'], - ᆡ: ['ㆍ', 'ㅣ'], - ᆢ: ['ㆍ', 'ㆍ'], - ᆣ: ['ㅏ', 'ㅡ'], - ᆤ: ['ㅑ', 'ㅜ'], - ᆥ: ['ㅕ', 'ㅑ'], - ᆦ: ['ㅗ', 'ㅑ'], - ᆧ: ['ㅗ', 'ㅒ'], - ᆨ: 'ㄱ', - ᆩ: ['ㄱ', 'ㄱ'], - ᆪ: ['ㄱ', 'ㅅ'], - ᆫ: 'ㄴ', - ᆬ: ['ㄴ', 'ㅈ'], - ᆭ: ['ㄴ', 'ㅎ'], - ᆮ: 'ㄷ', - ᆯ: 'ㄹ', - ᆰ: ['ㄹ', 'ㄱ'], - ᆱ: ['ㄹ', 'ㅁ'], - ᆲ: ['ㄹ', 'ㅂ'], - ᆳ: ['ㄹ', 'ㅅ'], - ᆴ: ['ㄹ', 'ㅌ'], - ᆵ: ['ㄹ', 'ㅍ'], - ᆶ: ['ㄹ', 'ㅎ'], - ᆷ: 'ㅁ', - ᆸ: 'ㅂ', - ᆹ: ['ㅂ', 'ㅅ'], - ᆺ: 'ㅅ', - ᆻ: ['ㅅ', 'ㅅ'], - ᆼ: 'ㅇ', - ᆽ: 'ㅈ', - ᆾ: 'ㅊ', - ᆿ: 'ㅋ', - ᇀ: 'ㅌ', - ᇁ: 'ㅍ', - ᇂ: 'ㅎ', - ᇃ: ['ㄱ', 'ㄹ'], - ᇄ: ['ㄱ', 'ㅅ', 'ㄱ'], - ᇅ: ['ㄴ', 'ㄱ'], - ᇆ: ['ㄴ', 'ㄷ'], - ᇇ: ['ㄴ', 'ㅅ'], - ᇈ: ['ㄴ', 'ㅿ'], - ᇉ: ['ㄴ', 'ㅌ'], - ᇊ: ['ㄷ', 'ㄱ'], - ᇋ: ['ㄷ', 'ㄹ'], - ᇌ: ['ㄹ', 'ㄱ', 'ㅅ'], - ᇍ: ['ㄹ', 'ㄴ'], - ᇎ: ['ㄹ', 'ㄷ'], - ᇏ: ['ㄹ', 'ㄷ', 'ㅎ'], - ᇐ: ['ㄹ', 'ㄹ'], - ᇑ: ['ㄹ', 'ㅁ', 'ㄱ'], - ᇒ: ['ㄹ', 'ㅁ', 'ㅅ'], - ᇓ: ['ㄹ', 'ㅂ', 'ㅅ'], - ᇔ: ['ㄹ', 'ㅂ', 'ㅎ'], - ᇕ: ['ㄹ', 'ㅸ'], - ᇖ: ['ㄹ', 'ㅅ', 'ㅅ'], - ᇗ: ['ㄹ', 'ㅿ'], - ᇘ: ['ㄹ', 'ㅋ'], - ᇙ: ['ㄹ', 'ㆆ'], - ᇚ: ['ㅁ', 'ㄱ'], - ᇛ: ['ㅁ', 'ㄹ'], - ᇜ: ['ㅁ', 'ㅂ'], - ᇝ: ['ㅁ', 'ㅅ'], - ᇞ: ['ㅁ', 'ㅅ', 'ㅅ'], - ᇟ: ['ㅁ', 'ㅿ'], - ᇠ: ['ㅁ', 'ㅊ'], - ᇡ: ['ㅁ', 'ㅎ'], - ᇢ: 'ㅱ', - ᇣ: ['ㅂ', 'ㄹ'], - ᇤ: ['ㅂ', 'ㅍ'], - ᇥ: ['ㅂ', 'ㅎ'], - ᇦ: ['ㅂ', 'ㅇ'], - ᇧ: ['ㅅ', 'ㄱ'], - ᇨ: ['ㅅ', 'ㄷ'], - ᇩ: ['ㅅ', 'ㄹ'], - ᇪ: ['ㅅ', 'ㅂ'], - ᇫ: 'ㅿ', - ᇬ: ['ㆁ', 'ㄱ'], - ᇭ: ['ㆁ', 'ㄱ', 'ㄱ'], - ᇮ: ['ㆁ', 'ㆁ'], - ᇯ: ['ㆁ', 'ㅋ'], - ᇰ: 'ㆁ', - ᇱ: ['ㆁ', 'ㅅ'], - ᇲ: ['ㆁ', 'ㅿ'], - ᇳ: ['ㅍ', 'ㅂ'], - ᇴ: 'ㆄ', - ᇵ: ['ㅎ', 'ㄴ'], - ᇶ: ['ㅎ', 'ㄹ'], - ᇷ: ['ㅎ', 'ㅁ'], - ᇸ: ['ㅎ', 'ㅂ'], - ᇹ: 'ㆆ', - ᇺ: ['ㄱ', 'ㄴ'], - ᇻ: ['ㄱ', 'ㅂ'], - ᇼ: ['ㄱ', 'ㅊ'], - ᇽ: ['ㄱ', 'ㅋ'], - ᇾ: ['ㄱ', 'ㅎ'], - ᇿ: ['ㄴ', 'ㄴ'], - }; - const jamoExtendedA$1 = { - ꥠ: ['ㄷ', 'ㅁ'], - ꥡ: ['ㄷ', 'ㅂ'], - ꥢ: ['ㄷ', 'ㅅ'], - ꥣ: ['ㄷ', 'ㅈ'], - ꥤ: ['ㄹ', 'ㄱ'], - ꥥ: ['ㄹ', 'ㄱ', 'ㄱ'], - ꥦ: ['ㄹ', 'ㄷ'], - ꥧ: ['ㄹ', 'ㄷ', 'ㄷ'], - ꥨ: ['ㄹ', 'ㅁ'], - ꥩ: ['ㄹ', 'ㅂ'], - ꥪ: ['ㄹ', 'ㅂ', 'ㅂ'], - ꥫ: ['ㄹ', 'ㅸ'], - ꥬ: ['ㄹ', 'ㅅ'], - ꥭ: ['ㄹ', 'ㅈ'], - ꥮ: ['ㄹ', 'ㅋ'], - ꥯ: ['ㅁ', 'ㄱ'], - ꥰ: ['ㅁ', 'ㄷ'], - ꥱ: ['ㅁ', 'ㅅ'], - ꥲ: ['ㅂ', 'ㅅ', 'ㅌ'], - ꥳ: ['ㅂ', 'ㅋ'], - ꥴ: ['ㅂ', 'ㅎ'], - ꥵ: ['ㅅ', 'ㅅ', 'ㅂ'], - ꥶ: ['ㅇ', 'ㄹ'], - ꥷ: ['ㅇ', 'ㅎ'], - ꥸ: ['ㅈ', 'ㅈ', 'ㅎ'], - ꥹ: ['ㅌ', 'ㅌ'], - ꥺ: ['ㅍ', 'ㅎ'], - ꥻ: ['ㅎ', 'ㅅ'], - ꥼ: ['ㆆ', 'ㆆ'], - }; - const jamoExtendedB$1 = { - ힰ: ['ㅗ', 'ㅕ'], - ힱ: ['ㅗ', 'ㅗ', 'ㅣ'], - ힲ: ['ㅛ', 'ㅏ'], - ힳ: ['ㅛ', 'ㅐ'], - ힴ: ['ㅛ', 'ㅓ'], - ힵ: ['ㅜ', 'ㅕ'], - ힶ: ['ㅜ', 'ㅣ', 'ㅣ'], - ힷ: ['ㅠ', 'ㅐ'], - ힸ: ['ㅠ', 'ㅗ'], - ힹ: ['ㅡ', 'ㅏ'], - ힺ: ['ㅡ', 'ㅓ'], - ힻ: ['ㅡ', 'ㅔ'], - ힼ: ['ㅡ', 'ㅗ'], - ힽ: ['ㅣ', 'ㅏ', 'ㅗ'], - ힾ: ['ㅣ', 'ㅒ'], - ힿ: ['ㅣ', 'ㅕ'], - ퟀ: ['ㅣ', 'ㅖ'], - ퟁ: ['ㅣ', 'ㅗ', 'ㅣ'], - ퟂ: ['ㅣ', 'ㅛ'], - ퟃ: ['ㅣ', 'ㅠ'], - ퟄ: ['ㅣ', 'ㅣ'], - ퟅ: ['ㆍ', 'ㅏ'], - ퟆ: ['ㆍ', 'ㅔ'], - ퟋ: ['ㄴ', 'ㄹ'], - ퟌ: ['ㄴ', 'ㅈ'], - ퟍ: ['ㄷ', 'ㄷ'], - ퟎ: ['ㄷ', 'ㄷ', 'ㅂ'], - ퟏ: ['ㄷ', 'ㅂ'], - ퟐ: ['ㄷ', 'ㅅ'], - ퟑ: ['ㄷ', 'ㅅ', 'ㄱ'], - ퟒ: ['ㄷ', 'ㅈ'], - ퟓ: ['ㄷ', 'ㅊ'], - ퟔ: ['ㄷ', 'ㅌ'], - ퟕ: ['ㄹ', 'ㄱ', 'ㄱ'], - ퟖ: ['ㄹ', 'ㄱ', 'ㅎ'], - ퟗ: ['ㄹ', 'ㄹ', 'ㅋ'], - ퟘ: ['ㄹ', 'ㅁ', 'ㅎ'], - ퟙ: ['ㄹ', 'ㅂ', 'ㄷ'], - ퟚ: ['ㄹ', 'ㅂ', 'ㅍ'], - ퟛ: ['ㄹ', 'ㆁ'], - ퟜ: ['ㄹ', 'ㆆ', 'ㅎ'], - ퟝ: null, - ퟞ: ['ㅁ', 'ㄴ'], - ퟟ: ['ㅁ', 'ㄴ', 'ㄴ'], - ퟠ: ['ㅁ', 'ㅁ'], - ퟡ: ['ㅁ', 'ㅂ', 'ㅅ'], - ퟢ: ['ㅁ', 'ㅈ'], - ퟣ: ['ㅂ', 'ㄷ'], - ퟤ: ['ㅂ', 'ㄹ', 'ㅍ'], - ퟥ: ['ㅂ', 'ㅁ'], - ퟦ: ['ㅂ', 'ㅂ'], - ퟧ: ['ㅂ', 'ㅅ', 'ㄷ'], - ퟨ: ['ㅂ', 'ㅈ'], - ퟩ: ['ㅂ', 'ㅊ'], - ퟪ: ['ㅅ', 'ㅁ'], - ퟫ: ['ㅅ', 'ㅸ'], - ퟬ: ['ㅅ', 'ㅅ', 'ㄱ'], - ퟭ: ['ㅅ', 'ㅅ', 'ㄷ'], - ퟮ: ['ㅅ', 'ㅿ'], - ퟯ: ['ㅅ', 'ㅈ'], - ퟰ: ['ㅅ', 'ㅊ'], - ퟱ: ['ㅅ', 'ㅌ'], - ퟲ: ['ㅅ', 'ㅎ'], - ퟳ: ['ㅿ', 'ㅂ'], - ퟴ: ['ㅿ', 'ㅸ'], - ퟵ: ['ㆁ', 'ㅁ'], - ퟶ: ['ㆁ', 'ㅎ'], - ퟷ: ['ㅈ', 'ㅂ'], - ퟸ: ['ㅈ', 'ㅂ', 'ㅂ'], - ퟹ: ['ㅈ', 'ㅈ'], - ퟺ: ['ㅍ', 'ㅅ'], - ퟻ: ['ㅍ', 'ㅌ'], - }; - const halfwidth$1 = { - ᄀ: 'ㄱ', - ᄁ: ['ㄱ', 'ㄱ'], - ᆪ: ['ㄱ', 'ㅅ'], - ᄂ: 'ㄴ', - ᆬ: ['ㄴ', 'ㅈ'], - ᆭ: ['ㄴ', 'ㅎ'], - ᄃ: 'ㄷ', - ᄄ: ['ㄷ', 'ㄷ'], - ᄅ: 'ㄹ', - ᆰ: ['ㄹ', 'ㄱ'], - ᆱ: ['ㄹ', 'ㅁ'], - ᆲ: ['ㄹ', 'ㅂ'], - ᆳ: ['ㄹ', 'ㅅ'], - ᆴ: ['ㄹ', 'ㅌ'], - ᆵ: ['ㄹ', 'ㅍ'], - ᄚ: ['ㄹ', 'ㅎ'], - ᄆ: 'ㅁ', - ᄇ: 'ㅂ', - ᄈ: ['ㅂ', 'ㅂ'], - ᄡ: ['ㅂ', 'ㅅ'], - ᄉ: 'ㅅ', - ᄊ: ['ㅅ', 'ㅅ'], - ᄋ: 'ㅇ', - ᄌ: 'ㅈ', - ᄍ: ['ㅈ', 'ㅈ'], - ᄎ: 'ㅊ', - ᄏ: 'ㅋ', - ᄐ: 'ㅌ', - ᄑ: 'ㅍ', - ᄒ: 'ㅎ', - ᅡ: 'ㅏ', - ᅢ: 'ㅐ', - ᅣ: 'ㅑ', - ᅤ: 'ㅒ', - ᅥ: 'ㅓ', - ᅦ: 'ㅔ', - ᅧ: 'ㅕ', - ᅨ: 'ㅖ', - ᅩ: 'ㅗ', - ᅪ: ['ㅗ', 'ㅏ'], - ᅫ: ['ㅗ', 'ㅐ'], - ᅬ: ['ㅗ', 'ㅣ'], - ᅭ: 'ㅛ', - ᅮ: 'ㅜ', - ᅯ: ['ㅜ', 'ㅓ'], - ᅰ: ['ㅜ', 'ㅔ'], - ᅱ: ['ㅜ', 'ㅣ'], - ᅲ: 'ㅠ', - ᅳ: 'ㅡ', - ᅴ: ['ㅡ', 'ㅣ'], - ᅵ: 'ㅣ', - }; - const all = Object.assign({}, jamo$1, jamoExtendedA$1, jamoExtendedB$1, halfwidth$1); - - // tries to transform everything into disassembled standard hangul - - const transformChar = char => (!standardHangul.contains(char) && all[char]) || char; - const transformDatum = datum => transformChar(Character(datum)); - const transformEveryChar = char => ( - (standardHangul.contains(char) ? pairs : all)[char] - || char - ); - const transformEveryDatum = datum => transformEveryChar(Character(datum)); - // transform everything just means that it also transforms - // standard hangul characters instead of ignoring them - - // this way, we can trust the inputs to composeAnything - const assembleFactory = transformer => (data, mode) => deepFlatResMap(transformer(data), composeAnything(mode)); - // the transformer should verify that each datum is a Character! - const assembleTransformer = data => deepMap(data, transformEveryDatum); - // this takes a CharacterGroup and transforms characters and - // complex characters, effectively leaving behind only the - // base Characters - // it doesn't decomposeSyllables though - var assemble = (assembleFactory(assembleTransformer)); - - const composeComplexCho = composeComplex(noUseJungJong); - const transformExceptCho = (char) => { - const res = transformEveryChar(char); - if (Array.isArray(res)) { - const comp = composeComplexCho(res); - // the default composeComplex only composes cho - // HACK: this bug might be an issue with composeComplex - if (Array.isArray(comp) && comp.length === 1) { - // if the composition actually ends up composing - // something and it's only one Character, just - // return the Character instead of an Array - return Character(comp); - } - return comp; - } - return res; - }; - // this function is needed by disassemble so it's trusting - var decomposeComplex = ((datum, decomposeDoubles) => toArray((decomposeDoubles ? transformEveryChar : transformExceptCho)(Character(datum)))); - - const trustMe = (char) => { - const code = char.codePointAt(0) - syllables.start; - const jongNum$$1 = code % 28; - const q = (code - jongNum$$1) / 28; - const jungNum$$1 = q % 21; - const choNum$$1 = 0 | q / 21; // basically Math.floor(q / 21) - return [cho$1[choNum$$1], jung$1[jungNum$$1], jong$1[jongNum$$1]].filter(v => v); - // the .filter(v => v) removes blank space in the array - }; - var decomposeSyllable = ((datum, hardFail) => { - const char = Character(datum); - if (!syllables.contains(char)) { - if (hardFail) { - throw Error('Decomposing a syllable requires a syllable to decompose!'); - } - return [datum]; - // if there's no hardFail, the function must - // still return the same type as it would have - // if it didn't fail - } - return trustMe(char); - }); - - const disassembleFactory = transformer => (datum) => { - const char = Character(datum); - if (syllables.contains(char)) { - return trustMe(char).map(transformer); - // that .map(transformEverything) catches the complex - // characters that decomposeSyllable returns - } - // otherwise try breaking complex characters apart - return transformer(char); - }; - const disassembleAll = disassembleFactory(transformEveryChar); - const disassemble = disassembleFactory(transformExceptCho); - // not to be confused with Hangul.disassemble - // this disassemble takes Characters as inputs, not CharacterGroups - const disassembleChar = (datum, grouped, decomposeDoubles) => { - const res = (decomposeDoubles ? disassembleAll : disassemble)(datum); - if (!grouped) { - return flatten(res); - } - return res; - }; - var disassemble$1 = ((data, grouped, decomposeDoubles) => (grouped ? deepMap : deepFlatMap)(data, decomposeDoubles ? disassembleAll : disassemble, true)); - // I know this looks really bad since it's all on - // one line but ESlint was being really finicky - - var name = ((obj) => { - Object.keys(obj).forEach((key) => { - obj[key].displayName = key; - }); - }); - - // This file is only used in ../publicCompose - // all is the only one of these that's actually used - // I can't Object.assign them all together unfortunately - const all$1 = { - ㄱ: { - ㄱ: 'ㄲ', - ㅅ: 'ㄳ', - }, - ㄷ: { - ㄷ: 'ㄸ', - }, - ㅅ: { - ㅅ: 'ㅆ', - ㄱ: 'ㅺ', - ㄴ: 'ㅻ', - ㄷ: 'ㅼ', - ㅂ: 'ㅽ', - ㅈ: 'ㅾ', - }, - ㅈ: { - ㅈ: 'ㅉ', - }, - ㅂ: { - ㅂ: 'ㅃ', - ㅅ: { - $: 'ㅄ', - ㄱ: 'ㅴ', - ㄷ: 'ㅵ', - }, - ㄱ: 'ㅲ', - ㄷ: 'ㅳ', - ㅈ: 'ㅶ', - ㅌ: 'ㅷ', - }, - ㅗ: { - ㅏ: 'ㅘ', - ㅐ: 'ㅙ', - ㅣ: 'ㅚ', - }, - ㅜ: { - ㅓ: 'ㅝ', - ㅔ: 'ㅞ', - ㅣ: 'ㅟ', - }, - ㅡ: { - ㅣ: 'ㅢ', - }, - ㄴ: { - ㅈ: 'ㄵ', - ㅎ: 'ㄶ', - ㄴ: 'ㅥ', - ㄷ: 'ㅦ', - ㅅ: 'ㅧ', - ㅿ: 'ㅨ', - }, - ㄹ: { - ㄱ: { - $: 'ㄺ', - ㅅ: 'ㅩ', - }, - ㅁ: 'ㄻ', - ㅂ: { - $: 'ㄼ', - ㅅ: 'ㅫ', - }, - ㅅ: 'ㄽ', - ㅌ: 'ㄾ', - ㅍ: 'ㄿ', - ㅎ: 'ㅀ', - ㄷ: 'ㅪ', - ㅿ: 'ㅬ', - ㆆ: 'ㅭ', - }, - ㅁ: { - ㅂ: 'ㅮ', - ㅅ: 'ㅯ', - ㅿ: 'ㅰ', - }, - ㅇ: { - ㅇ: 'ㆀ', - }, - ㆁ: { - ㅅ: 'ㆁ', - ㅿ: 'ㅿ', - }, - ㅎ: { - ㅎ: 'ㆅ', - }, - ㅛ: { - ㅑ: 'ㆇ', - ㅒ: 'ㆈ', - ㅣ: 'ㆉ', - }, - ㅠ: { - ㅕ: 'ㆊ', - ㅖ: 'ㆋ', - ㅣ: 'ㆌ', - }, - ㆍ: { - ㅣ: 'ㆎ', - }, - }; - - const standardizeCharacterBase = (mode) => { - const cc = composeComplex(mode); - return (datum) => { - const res = transformDatum(datum); - if (Array.isArray(res)) { - // atempt compose only if the value is an array - // it's unfortunate, but any compFn is untrusting - // since it's basically accessed publicly - // we know that v will always have good types - // but compFn will still check for Characters - return cc(res); - // returns an Array - } - return res; - }; - }; - const standardizeFactory = ((mode) => { - const currentStandardize = standardizeCharacterBase(mode); - return (data, grouped) => (grouped ? deepMap : deepFlatMap)(data, currentStandardize); - }); - var standardize = ((data, grouped, mode) => standardizeFactory(mode)(data, grouped)); - - // since these functions are exposed, the characters must be - // standardized so that the libaray can function properly - const standardizeCharacter = standardizeCharacterBase(useComp3 | useArchaic); - const complex$1 = (first, second, third = '', hardFail) => { - if (first === undefined || second === undefined) { - throw Error('Cannot compose a complex with less than two values!'); - } - const d1 = all$1[standardizeCharacter(first)]; - // depth 1 - if (!d1) { - if (hardFail) { - throw Error(`There's no complex character that starts with ${first}`); - } - return `${first}${second}${third}`; - } - const d2 = d1[standardizeCharacter(second)]; - // depth 2 - if (!d2) { - if (hardFail) { - throw Error(`Cannot combine ${first} and ${second}`); - } - return `${first}${second}${third}`; - } - const d2val = d2.$ || d2; - if (third) { - // if there's a third character (optional) - const d3 = d2[standardizeCharacter(third)]; - // depth 3 - if (!d3) { - // if depth 3 doesn't exist - if (hardFail) { - throw Error(`Found ${d2val} but cannot combine ${first}, ${second}, and ${third}`); - // the reason for this ^^^ is because sometimes - // d2 is a string rather than an object - } - return `${d2val}${third}`; - // at depth three, there should be a complex formed from - // the first and second characters so return that instead - // of the inputs concatenated - } - return d3; // this should always be a string - } - // the third character was falsy so just return the composition - return d2val; - }; - // this function will always return a String or it'll error (hardFail) - // there's probably a better way to structure these if-statements - // so if anyone comes up with one, I'll take it - - const syllable = (choChar, jungChar = '', jongChar = '', hardFail) => { - const cho = choNum[standardizeCharacter(choChar)]; - const jung = jungNum[standardizeCharacter(jungChar)]; - let jong; - if (jongChar) { - jong = jongNum[standardizeCharacter(jongChar)]; - } if (!Number.isInteger(cho)) { - if (hardFail) { - throw Error(`"${choChar}" is not a valid cho Character`); - } - return `${choChar}${jungChar}${jongChar}`; - } if (!Number.isInteger(jung)) { - if (hardFail) { - throw Error(`"${jungChar}" is not a valid jung Character`); - } - return `${choChar}${jungChar}${jongChar}`; - } if (jongChar && !Number.isInteger(jong)) { - // check if it exists because !Number.isInteger(undefined) - // is true and we don't want that happening since jongChar - // is optional - if (hardFail) { - throw Error(`"${jongChar}" is not a valid jong character`); - } - // getting here means that the cho and jung - // characters were valid, so call composeSyllable - return `${composeSyllableFn(cho, jung)}${jongChar}`; - } - return composeSyllableFn(cho, jung, jong); - }; - // by nesting all if-statements under if (hardFail) - // there might be a little better performance but I'm - // sure that it's pretty trivial. - - const standardizeComp3Archaic = standardizeFactory(useComp3 | useArchaic); - // support all types of complex - var stronger$1 = (data => standardizeComp3Archaic(data).map(char => stronger[char] || char)); - - // hangul to keystrokes - const hangulToKeyFn = char => hangulToKey[char] || char; - const transformToKeys = (hangulChar) => { - const res = transformExceptCho(hangulChar); - return isCharacterGroup(res) ? res.split('').map(hangulToKeyFn) : hangulToKeyFn(res); - }; - const disassembleToKeys = disassembleFactory(transformToKeys); - const hangulToKeys = (data, grouped) => (grouped ? deepMap : deepFlatMap)(data, disassembleToKeys); - - // keystrokes to hangul - const keyToHangulFn = char => keyToHangul[char]; - const transformCharToHangul = (latinDatum) => { - const latinChar = Character(latinDatum); - const res = keyToHangulFn(latinChar); - if (!res) { - // couldn't find a key for that characters - const lowerCaseRes = keyToHangulFn(latinChar.toLowerCase()); - if (!lowerCaseRes) { - return latinChar; - } - return lowerCaseRes; - } - return res; - }; - const transformToHangul = data => deepMap(data, transformCharToHangul); - const assembleFromKeys = assembleFactory(transformToHangul); - const keysToHangul = data => assembleFromKeys(data, noCompDouble); - // it's okay that we're not standarizing because the data - // in hangulToKey is already standard :) - - var testMulti = (aryFnName => isFn => data => deepFlatMap(data, transformEveryDatum)[aryFnName](isFn)); - - var contains = (testMulti('some')); - - var is = (isFn => (datum) => { - const res = transformEveryDatum(datum); - // it's okay that we don't check if data is - // a Character since transformEveryCharacter does. - return Array.isArray(res) ? res.every(isFn) : isFn(res); - }); - - var isAll = (testMulti('every')); - - const consonant = char => consonants[char]; - const isConsonant = is(consonant); - const isConsonantAll = isAll(consonant); - const containsConsonant = contains(consonant); - name({ - isConsonant, - isConsonantAll, - containsConsonant, - }); - - const isAll$1 = testFn => (data) => { - const len = data.length; - if (Array.isArray(data)) { - for (let i = 0; i < len; i++) { - const val = data[i]; - if (isCharacterGroup(val) ? isAll$1(testFn)(val) : testFn(val)) { - continue; - } - // the loop will get here if it doesn't satisfy the testing function - return false; - } - return true; - } if (typeof data === 'string') { - for (let i = 0; i < len; i++) { - const val = data[i]; - if (testFn(val)) { - continue; - } - return false; - } - return true; - } - throw TypeError('The data must be an Array or a String!'); - }; - const contains$1 = testFn => (data) => { - const len = data.length; - if (Array.isArray(data)) { - for (let i = 0; i < len; i++) { - const val = data[i]; - if (isCharacterGroup(val) ? isAll$1(testFn)(val) : testFn(val)) { - return true; - // this allows the function to short circut - } - } - return false; - } if (typeof data === 'string') { - for (let i = 0; i < len; i++) { - const val = data[i]; - if (testFn(val)) { - return true; - } - } - return false; - } - throw TypeError('The data must be an Array or a String!'); - }; - - const isJamo = datum => jamo.contains(Character(datum)); - const isCompatibilityJamo = datum => compatibilityJamo.contains(Character(datum)); - const isJamoExtendedA = datum => jamoExtendedA.char(Character(datum)); - const isSyllable = datum => syllables.contains(Character(datum)); - const isJamoExtendedB = datum => jamoExtendedB.contains(Character(datum)); - const isHalfwidth = datum => halfwidth.contains(Character(datum)); - const isReserved = datum => reserved.contains(Character(datum)); - const isStandardHangul = datum => standardHangul.contains(Character(datum)); - const isHangul = datum => hangul.contains(Character(datum)); - - const isAllJamo = isAll$1(isJamo); - const containsJamo = contains$1(isJamo); - - const isAllCompatibilityJamo = isAll$1(isCompatibilityJamo); - const containsCompatibilityJamo = contains$1(isCompatibilityJamo); - - const isAllJamoExtendedA = isAll$1(isJamoExtendedA); - const containsJamoExtendedA = contains$1(isJamoExtendedA); - - const isAllSyllable = isAll$1(isSyllable); - const containsSyllable = contains$1(isSyllable); - - const isAllJamoExtendedB = isAll$1(isJamoExtendedB); - const containsJamoExtendedB = contains$1(isJamoExtendedB); - - const isAllHalfwidth = isAll$1(isHalfwidth); - const containsHalfwidth = contains$1(isHalfwidth); - - const isAllReserved = isAll$1(isReserved); - const containsReserved = contains$1(isReserved); - - const isAllStandardHangul = isAll$1(isStandardHangul); - const containsStandardHangul = contains$1(isStandardHangul); - - const isAllHangul = isAll$1(isHangul); - const containsHangul = contains$1(isHangul); - name({ - isJamo, - isAllJamo, - containsJamo, - - isCompatibilityJamo, - isAllCompatibilityJamo, - containsCompatibilityJamo, - - isJamoExtendedA, - isAllJamoExtendedA, - containsJamoExtendedA, - - isSyllable, - isAllSyllable, - containsSyllable, - - isJamoExtendedB, - isAllJamoExtendedB, - containsJamoExtendedB, - - isHalfwidth, - isAllHalfwidth, - containsHalfwidth, - - isReserved, - isAllReserved, - containsReserved, - - isStandardHangul, - isAllStandardHangul, - containsStandardHangul, - - isHangul, - isAllHangul, - containsHangul, - }); - - const vowel = char => vowels[char]; - const isVowel$1 = is(vowel); - const isVowelAll = isAll(vowel); - const containsVowel = contains(vowel); - name({ - isVowel: isVowel$1, - isVowelAll, - containsVowel, - }); - - name({ - assemble, - - disassemble: disassemble$1, - disassembleCharacter: disassembleChar, - - composeComplex: complex$1, - composeSyllable: syllable, - - stronger: stronger$1, - }); - - exports.assemble = assemble; - exports.a = assemble; - exports.disassemble = disassemble$1; - exports.d = disassemble$1; - exports.disassembleCharacter = disassembleChar; - exports.composeComplex = complex$1; - exports.composeSyllable = syllable; - exports.stronger = stronger$1; - exports.useComp3 = useComp3; - exports.useArchaic = useArchaic; - exports.noUseJungJong = noUseJungJong; - exports.noCompDouble = noCompDouble; - exports.decomposeComplex = decomposeComplex; - exports.decomposeSyllable = decomposeSyllable; - exports.standardize = standardize; - exports.flatten = flatten; - exports.deepMap = deepMap; - exports.hangulToKeys = hangulToKeys; - exports.keysToHangul = keysToHangul; - exports.isConsonant = isConsonant; - exports.isConsonantAll = isConsonantAll; - exports.containsConsonant = containsConsonant; - exports.isJamo = isJamo; - exports.isCompatibilityJamo = isCompatibilityJamo; - exports.isJamoExtendedA = isJamoExtendedA; - exports.isSyllable = isSyllable; - exports.isJamoExtendedB = isJamoExtendedB; - exports.isHalfwidth = isHalfwidth; - exports.isReserved = isReserved; - exports.isStandardHangul = isStandardHangul; - exports.isHangul = isHangul; - exports.isAllJamo = isAllJamo; - exports.containsJamo = containsJamo; - exports.isAllCompatibilityJamo = isAllCompatibilityJamo; - exports.containsCompatibilityJamo = containsCompatibilityJamo; - exports.isAllJamoExtendedA = isAllJamoExtendedA; - exports.containsJamoExtendedA = containsJamoExtendedA; - exports.isAllSyllable = isAllSyllable; - exports.containsSyllable = containsSyllable; - exports.isAllJamoExtendedB = isAllJamoExtendedB; - exports.containsJamoExtendedB = containsJamoExtendedB; - exports.isAllHalfwidth = isAllHalfwidth; - exports.containsHalfwidth = containsHalfwidth; - exports.isAllReserved = isAllReserved; - exports.containsReserved = containsReserved; - exports.isAllStandardHangul = isAllStandardHangul; - exports.containsStandardHangul = containsStandardHangul; - exports.isAllHangul = isAllHangul; - exports.containsHangul = containsHangul; - exports.isVowel = isVowel$1; - exports.isVowelAll = isVowelAll; - exports.containsVowel = containsVowel; - - return exports; - -}({})); -//# sourceMappingURL=bundle.js.map diff --git a/dev/index.html b/dev/index.html deleted file mode 100644 index 31e759d..0000000 --- a/dev/index.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - Just a testing area - - - - - - diff --git a/dist/cjs/Hangul.js b/dist/cjs/Hangul.js deleted file mode 100644 index a5a7e6f..0000000 --- a/dist/cjs/Hangul.js +++ /dev/null @@ -1,1702 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { value: true }); - -const consonants = { - ㄱ: 1, - ㄴ: 1, - ㄷ: 1, - ㄹ: 1, - ㅁ: 1, - ㅂ: 1, - ㅅ: 1, - ㅇ: 1, - ㅈ: 1, - ㅊ: 1, - ㅋ: 1, - ㅌ: 1, - ㅍ: 1, - ㅎ: 1, - ㆁ: 1, // apparently this is now "ㅇ" - ㆄ: 1, - ㅱ: 1, - ㅿ: 1, -}; -const vowels = { - ㅏ: 1, - ㅐ: 1, - ㅑ: 1, - ㅓ: 1, - ㅔ: 1, - ㅕ: 1, - ㅖ: 1, - ㅗ: 1, - ㅛ: 1, - ㅜ: 1, - ㅠ: 1, - ㅡ: 1, - ㅣ: 1, - ㆍ: 1, -}; -const hangulToKey = { - ㅂ: 'q', - ㅃ: 'Q', - ㅈ: 'w', - ㅉ: 'W', - ㄷ: 'e', - ㄸ: 'E', - ㄱ: 'r', - ㄲ: 'R', - ㅅ: 't', - ㅆ: 'T', - ㅛ: 'y', - ㅕ: 'u', - ㅑ: 'i', - ㅐ: 'o', - ㅒ: 'O', - ㅔ: 'p', - ㅖ: 'P', - ㅁ: 'a', - ㄴ: 's', - ㅇ: 'd', - ㄹ: 'f', - ㅎ: 'g', - ㅗ: 'h', - ㅓ: 'j', - ㅏ: 'k', - ㅣ: 'l', - ㅋ: 'z', - ㅌ: 'x', - ㅊ: 'c', - ㅍ: 'v', - ㅠ: 'b', - ㅜ: 'n', - ㅡ: 'm', -}; -const keyToHangul = { - q: 'ㅂ', - Q: 'ㅃ', - w: 'ㅈ', - W: 'ㅉ', - e: 'ㄷ', - E: 'ㄸ', - r: 'ㄱ', - R: 'ㄲ', - t: 'ㅅ', - T: 'ㅆ', - y: 'ㅛ', - u: 'ㅕ', - i: 'ㅑ', - o: 'ㅐ', - O: 'ㅒ', - p: 'ㅔ', - P: 'ㅖ', - a: 'ㅁ', - s: 'ㄴ', - d: 'ㅇ', - f: 'ㄹ', - g: 'ㅎ', - h: 'ㅗ', - j: 'ㅓ', - k: 'ㅏ', - l: 'ㅣ', - z: 'ㅋ', - x: 'ㅌ', - c: 'ㅊ', - v: 'ㅍ', - b: 'ㅠ', - n: 'ㅜ', - m: 'ㅡ', -}; -// the reason the data is stored like this is because iterating -// through an array is slower than just getting a key from an object -// In this case though, it might be faster since arrays are allocated -// on the heap instead of the stack? - -// I realize that I can programmatically reverse the key-value pairs during -// runtime but since I can just do it now, it's just a little faster. - -const cho = { - ㄱㄱ: 'ㄲ', - ㄷㄷ: 'ㄸ', - ㅅㅅ: 'ㅆ', - ㅈㅈ: 'ㅉ', - ㅂㅂ: 'ㅃ', -}; -const jung = { - ㅗㅏ: 'ㅘ', - ㅗㅐ: 'ㅙ', - ㅗㅣ: 'ㅚ', - ㅜㅓ: 'ㅝ', - ㅜㅔ: 'ㅞ', - ㅜㅣ: 'ㅟ', - ㅡㅣ: 'ㅢ', -}; -const jong = { - ㄱㄱ: 'ㄲ', - ㄱㅅ: 'ㄳ', - ㄴㅈ: 'ㄵ', - ㄴㅎ: 'ㄶ', - ㄹㄱ: 'ㄺ', - ㄹㅁ: 'ㄻ', - ㄹㅂ: 'ㄼ', - ㄹㅅ: 'ㄽ', - ㄹㅌ: 'ㄾ', - ㄹㅍ: 'ㄿ', - ㄹㅎ: 'ㅀ', - ㅂㅅ: 'ㅄ', - ㅅㅅ: 'ㅆ', -}; -const archaic = { - ㄴㄴ: 'ㅥ', - ㄴㄷ: 'ㅦ', - ㄴㅅ: 'ㅧ', - ㄴㅿ: 'ㅨ', - ㄹㄱㅅ: 'ㅩ', - ㄹㄷ: 'ㅪ', - ㄹㅂㅅ: 'ㅫ', - ㄹㅿ: 'ㅬ', - ㄹㆆ: 'ㅭ', - ㅁㅂ: 'ㅮ', - ㅁㅅ: 'ㅯ', - ㅁㅿ: 'ㅰ', - ㅂㄱ: 'ㅲ', - ㅂㄷ: 'ㅳ', - ㅂㅅㄱ: 'ㅴ', - ㅂㅅㄷ: 'ㅵ', - ㅂㅈ: 'ㅶ', - ㅂㅌ: 'ㅷ', - ㅅㄱ: 'ㅺ', - ㅅㄴ: 'ㅻ', - ㅅㄷ: 'ㅼ', - ㅅㅂ: 'ㅽ', - ㅅㅈ: 'ㅾ', - ㅇㅇ: 'ㆀ', - ㆁㅅ: 'ㆁ', - ㆁㅿ: 'ㅿ', - ㅎㅎ: 'ㆅ', - ㅛㅑ: 'ㆇ', - ㅛㅒ: 'ㆈ', - ㅛㅣ: 'ㆉ', - ㅠㅕ: 'ㆊ', - ㅠㅖ: 'ㆋ', - ㅠㅣ: 'ㆌ', - ㆍㅣ: 'ㆎ', -}; -const pairs = { - ㄲ: ['ㄱ', 'ㄱ'], - ㄳ: ['ㄱ', 'ㅅ'], - ㄵ: ['ㄴ', 'ㅈ'], - ㄶ: ['ㄴ', 'ㅎ'], - ㄸ: ['ㄷ', 'ㄷ'], - ㄻ: ['ㄹ', 'ㅁ'], - ㄺ: ['ㄹ', 'ㄱ'], - ㄼ: ['ㄹ', 'ㅂ'], - ㄽ: ['ㄹ', 'ㅅ'], - ㄾ: ['ㄹ', 'ㅌ'], - ㄿ: ['ㄹ', 'ㅍ'], - ㅀ: ['ㄹ', 'ㅎ'], - ㅃ: ['ㅂ', 'ㅂ'], - ㅄ: ['ㅂ', 'ㅅ'], - ㅆ: ['ㅅ', 'ㅅ'], - ㅉ: ['ㅈ', 'ㅈ'], - ㅘ: ['ㅗ', 'ㅏ'], - ㅙ: ['ㅗ', 'ㅐ'], - ㅚ: ['ㅗ', 'ㅣ'], - ㅝ: ['ㅜ', 'ㅓ'], - ㅞ: ['ㅜ', 'ㅔ'], - ㅟ: ['ㅜ', 'ㅣ'], - ㅢ: ['ㅡ', 'ㅣ'], - ㅥ: ['ㄴ', 'ㄴ'], - ㅦ: ['ㄴ', 'ㄷ'], - ㅧ: ['ㄴ', 'ㅅ'], - ㅨ: ['ㄴ', 'ㅿ'], - ㅩ: ['ㄹ', 'ㄱ', 'ㅅ'], - ㅪ: ['ㄹ', 'ㄷ'], - ㅫ: ['ㄹ', 'ㅂ', 'ㅅ'], - ㅬ: ['ㄹ', 'ㅿ'], - ㅭ: ['ㄹ', 'ㆆ'], - ㅮ: ['ㅁ', 'ㅂ'], - ㅯ: ['ㅁ', 'ㅅ'], - ㅰ: ['ㅁ', 'ㅿ'], - ㅲ: ['ㅂ', 'ㄱ'], - ㅳ: ['ㅂ', 'ㄷ'], - ㅴ: ['ㅂ', 'ㅅ', 'ㄱ'], - ㅵ: ['ㅂ', 'ㅅ', 'ㄷ'], - ㅶ: ['ㅂ', 'ㅈ'], - ㅷ: ['ㅂ', 'ㅌ'], - ㅺ: ['ㅅ', 'ㄱ'], - ㅻ: ['ㅅ', 'ㄴ'], - ㅼ: ['ㅅ', 'ㄷ'], - ㅽ: ['ㅅ', 'ㅂ'], - ㅾ: ['ㅅ', 'ㅈ'], - ㆀ: ['ㅇ', 'ㅇ'], - ㆂ: ['ㆁ', 'ㅅ'], - ㆃ: ['ㆁ', 'ㅿ'], - ㆅ: ['ㅎ', 'ㅎ'], - ㆇ: ['ㅛ', 'ㅑ'], - ㆈ: ['ㅛ', 'ㅒ'], - ㆉ: ['ㅛ', 'ㅣ'], - ㆊ: ['ㅠ', 'ㅕ'], - ㆋ: ['ㅠ', 'ㅖ'], - ㆌ: ['ㅠ', 'ㅣ'], - ㆎ: ['ㆍ', 'ㅣ'], -}; -const complex = { - ㄲ: 1, - ㄳ: 1, - ㄵ: 1, - ㄶ: 1, - ㄸ: 1, - ㄺ: 1, - ㄻ: 1, - ㄼ: 1, - ㄽ: 1, - ㄾ: 1, - ㄿ: 1, - ㅀ: 1, - ㅃ: 1, - ㅄ: 1, - ㅆ: 1, - ㅉ: 1, - ㅘ: 1, - ㅙ: 1, - ㅚ: 1, - ㅝ: 1, - ㅞ: 1, - ㅟ: 1, - ㅢ: 1, -}; -const irregularComplex = { - ㅥ: 1, - ㅦ: 1, - ㅧ: 1, - ㅨ: 1, - ㅩ: 1, - ㅪ: 1, - ㅫ: 1, - ㅬ: 1, - ㅭ: 1, - ㅮ: 1, - ㅯ: 1, - ㅰ: 1, - ㅱ: 1, - ㅲ: 1, - ㅳ: 1, - ㅴ: 1, - ㅵ: 1, - ㅶ: 1, - ㅷ: 1, -}; -const complexList = Object.assign({}, complex, irregularComplex); -// yes, I know that this is not a list. -const stronger = { - ㄱ: 'ㄲ', - ㅋ: 'ㄲ', - ㄷ: 'ㄸ', - ㅌ: 'ㄸ', - ㅂ: 'ㅃ', - ㅍ: 'ㅃ', - ㅅ: 'ㅆ', - ㅈ: 'ㅉ', - ㅊ: 'ㅉ', -}; -// I would add a weaker export -// except that I can't reverse the outputs - -const cho$1 = [ - 'ㄱ', 'ㄲ', 'ㄴ', 'ㄷ', 'ㄸ', 'ㄹ', 'ㅁ', - 'ㅂ', 'ㅃ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅉ', - 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ', -]; -const jung$1 = [ - 'ㅏ', 'ㅐ', 'ㅑ', 'ㅒ', 'ㅓ', 'ㅔ', 'ㅕ', - 'ㅖ', 'ㅗ', 'ㅘ', 'ㅙ', 'ㅚ', 'ㅛ', 'ㅜ', - 'ㅝ', 'ㅞ', 'ㅟ', 'ㅠ', 'ㅡ', 'ㅢ', 'ㅣ', -]; -const jong$1 = [ - null, 'ㄱ', 'ㄲ', 'ㄳ', 'ㄴ', 'ㄵ', 'ㄶ', - 'ㄷ', 'ㄹ', 'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', - 'ㄿ', 'ㅀ', 'ㅁ', 'ㅂ', 'ㅄ', 'ㅅ', 'ㅆ', - 'ㅇ', 'ㅈ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ', -]; -const choNum = { - ㄱ: 0, - ㄲ: 1, - ㄴ: 2, - ㄷ: 3, - ㄸ: 4, - ㄹ: 5, - ㅁ: 6, - ㅂ: 7, - ㅃ: 8, - ㅅ: 9, - ㅆ: 10, - ㅇ: 11, - ㅈ: 12, - ㅉ: 13, - ㅊ: 14, - ㅋ: 15, - ㅌ: 16, - ㅍ: 17, - ㅎ: 18, -}; -const jungNum = { - ㅏ: 0, - ㅐ: 1, - ㅑ: 2, - ㅒ: 3, - ㅓ: 4, - ㅔ: 5, - ㅕ: 6, - ㅖ: 7, - ㅗ: 8, - ㅘ: 9, - ㅙ: 10, - ㅚ: 11, - ㅛ: 12, - ㅜ: 13, - ㅝ: 14, - ㅞ: 15, - ㅟ: 16, - ㅠ: 17, - ㅡ: 18, - ㅢ: 19, - ㅣ: 20, -}; -const jongNum = { - ㄱ: 1, - ㄲ: 2, - ㄳ: 3, - ㄴ: 4, - ㄵ: 5, - ㄶ: 6, - ㄷ: 7, - ㄹ: 8, - ㄺ: 9, - ㄻ: 10, - ㄼ: 11, - ㄽ: 12, - ㄾ: 13, - ㄿ: 14, - ㅀ: 15, - ㅁ: 16, - ㅂ: 17, - ㅄ: 18, - ㅅ: 19, - ㅆ: 20, - ㅇ: 21, - ㅈ: 22, - ㅊ: 23, - ㅋ: 24, - ㅌ: 25, - ㅍ: 26, - ㅎ: 27, -}; - -class UnicodeRange { - constructor(start, end) { - this.start = start; - this.end = end; - } - - containsCodePoint(num) { - return num >= this.start && num <= this.end; - } - - contains(char) { - return this.containsCodePoint(char.codePointAt(0)); - } -} -class CombinedRange { - constructor(ranges, codePoints = {}) { - this.ranges = ranges; - this.codePoints = codePoints; - } - - containsCodePoint(num) { - return ( - (this.codePoints && this.codePoints[num]) - || this.ranges.some(range => range.containsCodePoint(num)) - ); - } - - contains(char) { - const num = char.codePointAt(0); - return this.containsCodePoint(num); - } -} - -const jamo = new UnicodeRange(0x1100, 0x11FF); -const compatibilityJamo = new UnicodeRange(0x3130, 0x318F); -const jamoExtendedA = new UnicodeRange(0xA960, 0xA97F); -const syllables = new UnicodeRange(0xAC00, 0xD7AF); -const jamoExtendedB = new UnicodeRange(0xD7B0, 0xD7FF); -const halfwidth = new UnicodeRange(0xFFA0, 0xFFDF); -const reserved = new CombinedRange([ - new UnicodeRange(0xA97D, 0xA97F), // jamoExtendedA - new UnicodeRange(0xD7A4, 0xD7AF), // syllables - new UnicodeRange(0xD7C7, 0xD7CA), // jamoExtendedB - new UnicodeRange(0xD7FC, 0xD7FF), // jamoExtendedB -], { 0x3130: 1, 0x318F: 1 }); -const standardHangul = new CombinedRange([compatibilityJamo, syllables]); -const hangul = new CombinedRange([ - jamo, - compatibilityJamo, - jamoExtendedA, - syllables, - jamoExtendedB, - halfwidth, - reserved, -]); - -var composeSyllableFn = ((cho, jung, jong = 0) => ( - String.fromCodePoint(cho * 588 + jung * 28 + jong + syllables.start) - // this is the actual function that makes unicode syllable characters - // where the characters are mapped to numbers. Take a look at - // { choNum, jungNum, jongNum } from './unicode/syllable' -)); - -class Result { - constructor(result = '', remainder = []) { - this.result = result; - this.remainder = remainder; - } -} - -const Character = (val) => { - const str = `${val}`; - // not using .toString because Symbol.toPrimitive overrides when present - if (str.length !== 1) { - throw Error(`"${str}" is not a Character!`); - } - return str; -}; -// this function turns values into characters if it can -// otherwise it just fails -const ENOARYLIKE = () => { throw TypeError('The data must be an Array or a String!'); }; -const toArray = aryOrStr => (Array.isArray(aryOrStr) ? aryOrStr : aryOrStr.split('')); -// as a general note, calling .split like that instead of .split`` is faster -const isCharacterGroup = (val) => { - if (val.length < 1) { - return false; - } if (Array.isArray(val)) { - if (val.length > 1) { - return true; - } - return isCharacterGroup(val[0]); - } if (typeof val === 'string' && val.length > 1) { - return true; - } - return false; -}; -// while Characters can be a CharacterGroup, -// this function ignores characters -const identity = i => i; -const deepMap = (data, func, useToArray) => { - const modifier = useToArray ? toArray : identity; - if (Array.isArray(data)) { - return data.map(val => (isCharacterGroup(val) ? deepMap(val, func, useToArray) : modifier(func(val)))); - } if (typeof data === 'string') { - // since the data was a string, the array created from - // the string won't contain any character groups - return data.split('').map(char => modifier(func(char))); - } - ENOARYLIKE(); -}; -const deepFlatMap = (data, func) => { - let res = ''; - if (Array.isArray(data)) { - const len = data.length; - for (let i = 0; i < len; i++) { - // for is faster than forEach - // this function is used a lot so I'll - // take any optimization that I can get - const val = data[i]; - if (isCharacterGroup(val)) { - res += deepFlatMap(val, func); - } else { - const recurseRes = func(val); - if (isCharacterGroup(recurseRes)) { - res += deepFlatMap(recurseRes, identity); - } else { - res += recurseRes; - } - } - } - } else if (typeof data === 'string') { - const len = data.length; - for (let i = 0; i < len; i++) { - const recurseRes = func(data[i]); - if (isCharacterGroup(recurseRes)) { - res += deepFlatMap(recurseRes, identity); - } else { - res += recurseRes; - } - } - } else { - ENOARYLIKE(); - } - return res; -}; -const flatten = (data) => { - if (Array.isArray(data)) { - let res = ''; - const len = data.length; - for (let i = 0; i < len; i++) { - const val = data[i]; - if (isCharacterGroup(val)) { - res += flatten(val); - } else { - res += val; - } - } - return res; - } if (typeof data === 'string') { - return data; - } - ENOARYLIKE(); -}; -const deepFlatResMap = (data, func) => { - // this is different since it deals with functions that return Result objects. - // consumeLeftovers - let rem; - // remaining - let res = ''; - // result - if (Array.isArray(data)) { - rem = []; - const len = data.length; - for (let i = 0; i < len; i++) { - const val = data[i]; - if (isCharacterGroup(val)) { - rem.push(...deepFlatResMap(val, func)); - // deepFlatResMap always returns an array - // (or at least it should) - } else { - rem.push(val); - } - } - } else if (typeof data === 'string') { - rem = data.split(''); - // could have used toArray but since we already know - // the type of this, there's no need to - } else { - // it's not an Array or a String - ENOARYLIKE(); - } - while (rem.length) { - const comp = func(rem); - // func needs to return a Result like interface for this to work - // otherwise we'll get a really nasty to debug error - res += comp.result; - rem = comp.remainder; - } - return res; -}; - -// important note! -// these functions aren't going to really make any sense until -// you understand how they work in conjunction with the stuff -// that's in './types'. Read './Result' and './types' first. -// then read this. -const objCache = []; -const useComp3 = 0b001; -const useArchaic = 0b010; -const noUseJungJong = 0b100; -const noCompDouble = 0b1000; -const composeComplexBase = (mode) => { - // mode is being used as a bitfield - if (mode < 0 || mode > 8) { - throw Error('The mode cannot be less than zero or greater than eight!'); - } - const usingArchaic = mode & useArchaic; - const usingComp3 = usingArchaic && mode & useComp3; - const usingNoCompDouble = mode & noCompDouble; - let obj = objCache[mode]; - if (!obj) { - const objs = [cho]; - // there are no comp3 values in non archaic complex objects - if (!(mode & noUseJungJong)) { - // if you're usingJungJong - objs.push(jung, jong); - } if (usingArchaic) { - objs.push(archaic); - } - obj = Object.assign({}, ...objs); - objCache[mode] = obj; - // eslint got mad at me for chaining assignments - } - return (chars) => { - const len = chars.length; - if (len < 1) { - throw Error('Cannot compose array of zero characters!'); - } - const char1 = chars[0]; - if (len < 2) { - // if there aren't even two Characters to use - return new Result(char1); - } - const char2 = chars[1]; - if (usingNoCompDouble && char1 === char2) { - return new Result(char1, chars.slice(1)); - } - const comp2 = obj[char1 + char2]; - // comp2 = composition of 2 characters - if (comp2) { - if (usingComp3 && len > 2) { - // if there's more data, try to compose a tripple - const comp3 = obj[char1 + char2 + chars[2]]; - if (comp3) { - return new Result(comp3, chars.slice(3)); - } - } - // there's no more data or couldn't find a comp3 - return new Result(comp2, chars.slice(2)); - } - // couldn't find a comp2 - return new Result(char1, chars.slice(1)); - }; -}; -const composeComplex = (mode) => { - const cc = composeComplexBase(mode); - return ary => deepFlatResMap(ary, cc); -}; -const isVowel = char => char && char !== 'ㆍ' && vowels[char]; -var composeAnything = ((mode) => { - const cc = composeComplexBase(mode); - return (ary) => { - // while this function is named "composeSyllable", it actually - // can be used to compose anything, really. - if (ary.length < 2) { - return new Result(ary[0]); - // don't do extra computing for small operations - } - // the composeComplex function with the mode that is specified - const choRes = cc(ary); - // ^^ that's a Result object - const choChar = choRes.result; - // the result of the composition, should be a Character - const choRem = choRes.remainder; - // the remainder of the composition - const cho$$1 = choNum[choChar]; - // the number that the character is mapped to - if (choRem.length < 1 || !Number.isInteger(cho$$1)) { - // check if there's any more characters remaining - // also check if it's not an integer since 0 == false - // if it's not an integer, then return the potential - // complex or Character that was made from composeAnyComplex - return choRes; - // choRes is already a Result so no need to make another - } - const jungRes = cc(choRem); - - const jungChar = jungRes.result; - const jungRem = jungRes.remainder; - const jung$$1 = jungNum[jungChar]; - if (!Number.isInteger(jung$$1)) { - // there's no need to check to see if there's any more - // remaining since cho and jung are all that's needed - // to compose a syllable - return new Result(choChar, [jungChar, ...jungRem]); - // still only return choChar as a result since we want - // to try starting a syllable off with the jungChar next - // time this function is called - } if (jungRem.length) { - // there's no point in trying to add anything on to the complex - // if there aren't any characters left - if (!isVowel(jungRem[1])) { - // we need this part so that - // ㅁㅣㅇㅏ => 미아 - const jongRes = cc(jungRem); - - const jongChar = jongRes.result; - const jongRem = jongRes.remainder; - const jong$$1 = jongNum[jongChar]; - if (jong$$1) { - // if the character after the syllable is not a vowel - // and the jong character is valid - return new Result(composeSyllableFn(cho$$1, jung$$1, jong$$1), jongRem); - } - } - } - // there aren't any characters left - // or the character after the syllable is a vowel - // or the jong character isn't valid - return new Result(composeSyllableFn(cho$$1, jung$$1), jungRem); - // The last argument is optional for the Result constructor - }; -}); - -// if you're gonna copy this part, at least give me credit. -// I had to do all of this manually. -// also, I think turning all of these arrays into strings -// might speed up composition by a bit. -const jamo$1 = { - ᄀ: 'ㄱ', - ᄁ: ['ㄱ', 'ㄱ'], - ᄂ: 'ㄴ', - ᄃ: 'ㄷ', - ᄄ: ['ㄷ', 'ㄷ'], - ᄅ: 'ㄹ', - ᄆ: 'ㅁ', - ᄇ: 'ㅂ', - ᄈ: ['ㅂ', 'ㅂ'], - ᄉ: 'ㅅ', - ᄊ: ['ㅅ', 'ㅅ'], - ᄋ: 'ㅇ', - ᄌ: 'ㅈ', - ᄍ: ['ㅈ', 'ㅈ'], - ᄎ: 'ㅊ', - ᄏ: 'ㅋ', - ᄐ: 'ㅌ', - ᄑ: 'ㅍ', - ᄒ: 'ㅎ', - ᄓ: ['ㄴ', 'ㄱ'], - ᄔ: ['ㄴ', 'ㄴ'], - ᄕ: ['ㄴ', 'ㄷ'], - ᄖ: ['ㄴ', 'ㅂ'], - ᄗ: ['ㄷ', 'ㄱ'], - ᄘ: ['ㄹ', 'ㄴ'], - ᄙ: ['ㄹ', 'ㄹ'], - ᄚ: ['ㄹ', 'ㅎ'], - ᄛ: ['ㄹ', 'ㅇ'], - ᄜ: ['ㅁ', 'ㅂ'], - ᄝ: 'ㅱ', - ᄞ: ['ㅂ', 'ㄱ'], - ᄟ: ['ㅂ', 'ㄴ'], - ᄠ: ['ㅂ', 'ㄷ'], - ᄡ: ['ㅂ', 'ㅅ'], - ᄢ: ['ㅂ', 'ㅅ', 'ㄱ'], - ᄣ: ['ㅂ', 'ㅅ', 'ㄷ'], - ᄤ: ['ㅂ', 'ㅅ', 'ㅂ'], - ᄥ: ['ㅂ', 'ㅅ', 'ㅅ'], - ᄦ: ['ㅂ', 'ㅅ', 'ㅈ'], - ᄧ: ['ㅂ', 'ㅈ'], - ᄨ: ['ㅂ', 'ㅊ'], - ᄩ: ['ㅂ', 'ㅌ'], - ᄪ: ['ㅂ', 'ㅍ'], - ᄫ: ['ㅂ', 'ㅇ'], - ᄬ: [['ㅂ', 'ㅂ'], 'ㅇ'], - ᄭ: ['ㅅ', 'ㄱ'], - ᄮ: ['ㅅ', 'ㄴ'], - ᄯ: ['ㅅ', 'ㄷ'], - ᄰ: ['ㅅ', 'ㄹ'], - ᄱ: ['ㅅ', 'ㅁ'], - ᄲ: ['ㅅ', 'ㅂ'], - ᄳ: ['ㅅ', 'ㅂ', 'ㄱ'], - ᄴ: ['ㅅ', 'ㅅ', 'ㅅ'], - ᄵ: ['ㅅ', 'ㅇ'], - ᄶ: ['ㅅ', 'ㅈ'], - ᄷ: ['ㅅ', 'ㅊ'], - ᄸ: ['ㅅ', 'ㅋ'], - ᄹ: ['ㅅ', 'ㅌ'], - ᄺ: ['ㅅ', 'ㅍ'], - ᄻ: ['ㅅ', 'ㅎ'], - ᄼ: null, - ᄽ: null, - ᄾ: null, - ᄿ: null, - ᅀ: 'ㅿ', - ᅁ: ['ㅇ', 'ㄱ'], - ᅂ: ['ㅇ', 'ㄷ'], - ᅃ: ['ㅇ', 'ㅁ'], - ᅄ: ['ㅇ', 'ㅂ'], - ᅅ: ['ㅇ', 'ㅅ'], - ᅆ: ['ㅇ', 'ㅿ'], - ᅇ: ['ㅇ', 'ㅇ'], - ᅈ: ['ㅇ', 'ㅈ'], - ᅉ: ['ㅇ', 'ㅊ'], - ᅊ: ['ㅇ', 'ㅌ'], - ᅋ: ['ㅇ', 'ㅍ'], - ᅌ: 'ㆁ', - ᅍ: ['ㅈ', 'ㅇ'], - ᅎ: null, - ᅏ: null, - ᅐ: null, - ᅑ: null, - ᅒ: ['ㅊ', 'ㅋ'], - ᅓ: ['ㅊ', 'ㅎ'], - ᅔ: null, - ᅕ: null, - ᅖ: ['ㅍ', 'ㅂ'], - ᅗ: 'ㆄ', - ᅘ: ['ㅎ', 'ㅎ'], - ᅙ: 'ㆆ', - ᅚ: ['ㄱ', 'ㄷ'], - ᅛ: ['ㄱ', 'ㅅ'], - ᅜ: ['ㄱ', 'ㅈ'], - ᅝ: ['ㄱ', 'ㅎ'], - ᅞ: ['ㄷ', 'ㄹ'], - ᅡ: 'ㅏ', - ᅢ: 'ㅐ', - ᅣ: 'ㅑ', - ᅤ: 'ㅒ', - ᅥ: 'ㅓ', - ᅦ: 'ㅔ', - ᅧ: 'ㅕ', - ᅨ: 'ㅖ', - ᅩ: 'ㅗ', - ᅪ: ['ㅗ', 'ㅏ'], - ᅫ: ['ㅗ', 'ㅐ'], - ᅬ: ['ㅗ', 'ㅣ'], - ᅭ: 'ㅛ', - ᅮ: 'ㅜ', - ᅯ: ['ㅜ', 'ㅓ'], - ᅰ: ['ㅜ', 'ㅔ'], - ᅱ: ['ㅜ', 'ㅣ'], - ᅲ: 'ㅠ', - ᅳ: 'ㅡ', - ᅴ: ['ㅡ', 'ㅣ'], - ᅵ: 'ㅣ', - ᅶ: ['ㅏ', 'ㅗ'], - ᅷ: ['ㅏ', 'ㅜ'], - ᅸ: ['ㅑ', 'ㅗ'], - ᅹ: ['ㅑ', 'ㅛ'], - ᅺ: ['ㅓ', 'ㅗ'], - ᅻ: ['ㅓ', 'ㅜ'], - ᅼ: ['ㅓ', 'ㅡ'], - ᅽ: ['ㅕ', 'ㅗ'], - ᅾ: ['ㅕ', 'ㅜ'], - ᅿ: ['ㅗ', 'ㅓ'], - ᆀ: ['ㅔ', 'ㅗ'], - ᆁ: ['ㅖ', 'ㅗ'], - ᆂ: ['ㅗ', 'ㅗ'], - ᆃ: ['ㅗ', 'ㅜ'], - ᆄ: ['ㅛ', 'ㅑ'], - ᆅ: ['ㅛ', 'ㅒ'], - ᆆ: ['ㅛ', 'ㅕ'], - ᆇ: ['ㅛ', 'ㅗ'], - ᆈ: ['ㅛ', 'ㅣ'], - ᆉ: ['ㅜ', 'ㅏ'], - ᆊ: ['ㅜ', 'ㅐ'], - ᆋ: ['ㅜ', 'ㅓ', 'ㅡ'], - ᆌ: ['ㅜ', 'ㅖ'], - ᆍ: ['ㅜ', 'ㅜ'], - ᆎ: ['ㅠ', 'ㅏ'], - ᆏ: ['ㅠ', 'ㅓ'], - ᆐ: ['ㅠ', 'ㅔ'], - ᆑ: ['ㅠ', 'ㅕ'], - ᆒ: ['ㅠ', 'ㅔ'], - ᆓ: ['ㅠ', 'ㅜ'], - ᆔ: ['ㅠ', 'ㅣ'], - ᆕ: ['ㅡ', 'ㅜ'], - ᆖ: ['ㅡ', 'ㅡ'], - ᆗ: ['ㅡ', 'ㅣ', 'ㅜ'], - ᆘ: ['ㅣ', 'ㅏ'], - ᆙ: ['ㅣ', 'ㅑ'], - ᆚ: ['ㅣ', 'ㅗ'], - ᆛ: ['ㅣ', 'ㅜ'], - ᆜ: ['ㅣ', 'ㅡ'], - ᆝ: null, - ᆞ: 'ㆍ', - ᆟ: ['ㆍ', 'ㅓ'], - ᆠ: ['ㆍ', 'ㅜ'], - ᆡ: ['ㆍ', 'ㅣ'], - ᆢ: ['ㆍ', 'ㆍ'], - ᆣ: ['ㅏ', 'ㅡ'], - ᆤ: ['ㅑ', 'ㅜ'], - ᆥ: ['ㅕ', 'ㅑ'], - ᆦ: ['ㅗ', 'ㅑ'], - ᆧ: ['ㅗ', 'ㅒ'], - ᆨ: 'ㄱ', - ᆩ: ['ㄱ', 'ㄱ'], - ᆪ: ['ㄱ', 'ㅅ'], - ᆫ: 'ㄴ', - ᆬ: ['ㄴ', 'ㅈ'], - ᆭ: ['ㄴ', 'ㅎ'], - ᆮ: 'ㄷ', - ᆯ: 'ㄹ', - ᆰ: ['ㄹ', 'ㄱ'], - ᆱ: ['ㄹ', 'ㅁ'], - ᆲ: ['ㄹ', 'ㅂ'], - ᆳ: ['ㄹ', 'ㅅ'], - ᆴ: ['ㄹ', 'ㅌ'], - ᆵ: ['ㄹ', 'ㅍ'], - ᆶ: ['ㄹ', 'ㅎ'], - ᆷ: 'ㅁ', - ᆸ: 'ㅂ', - ᆹ: ['ㅂ', 'ㅅ'], - ᆺ: 'ㅅ', - ᆻ: ['ㅅ', 'ㅅ'], - ᆼ: 'ㅇ', - ᆽ: 'ㅈ', - ᆾ: 'ㅊ', - ᆿ: 'ㅋ', - ᇀ: 'ㅌ', - ᇁ: 'ㅍ', - ᇂ: 'ㅎ', - ᇃ: ['ㄱ', 'ㄹ'], - ᇄ: ['ㄱ', 'ㅅ', 'ㄱ'], - ᇅ: ['ㄴ', 'ㄱ'], - ᇆ: ['ㄴ', 'ㄷ'], - ᇇ: ['ㄴ', 'ㅅ'], - ᇈ: ['ㄴ', 'ㅿ'], - ᇉ: ['ㄴ', 'ㅌ'], - ᇊ: ['ㄷ', 'ㄱ'], - ᇋ: ['ㄷ', 'ㄹ'], - ᇌ: ['ㄹ', 'ㄱ', 'ㅅ'], - ᇍ: ['ㄹ', 'ㄴ'], - ᇎ: ['ㄹ', 'ㄷ'], - ᇏ: ['ㄹ', 'ㄷ', 'ㅎ'], - ᇐ: ['ㄹ', 'ㄹ'], - ᇑ: ['ㄹ', 'ㅁ', 'ㄱ'], - ᇒ: ['ㄹ', 'ㅁ', 'ㅅ'], - ᇓ: ['ㄹ', 'ㅂ', 'ㅅ'], - ᇔ: ['ㄹ', 'ㅂ', 'ㅎ'], - ᇕ: ['ㄹ', 'ㅸ'], - ᇖ: ['ㄹ', 'ㅅ', 'ㅅ'], - ᇗ: ['ㄹ', 'ㅿ'], - ᇘ: ['ㄹ', 'ㅋ'], - ᇙ: ['ㄹ', 'ㆆ'], - ᇚ: ['ㅁ', 'ㄱ'], - ᇛ: ['ㅁ', 'ㄹ'], - ᇜ: ['ㅁ', 'ㅂ'], - ᇝ: ['ㅁ', 'ㅅ'], - ᇞ: ['ㅁ', 'ㅅ', 'ㅅ'], - ᇟ: ['ㅁ', 'ㅿ'], - ᇠ: ['ㅁ', 'ㅊ'], - ᇡ: ['ㅁ', 'ㅎ'], - ᇢ: 'ㅱ', - ᇣ: ['ㅂ', 'ㄹ'], - ᇤ: ['ㅂ', 'ㅍ'], - ᇥ: ['ㅂ', 'ㅎ'], - ᇦ: ['ㅂ', 'ㅇ'], - ᇧ: ['ㅅ', 'ㄱ'], - ᇨ: ['ㅅ', 'ㄷ'], - ᇩ: ['ㅅ', 'ㄹ'], - ᇪ: ['ㅅ', 'ㅂ'], - ᇫ: 'ㅿ', - ᇬ: ['ㆁ', 'ㄱ'], - ᇭ: ['ㆁ', 'ㄱ', 'ㄱ'], - ᇮ: ['ㆁ', 'ㆁ'], - ᇯ: ['ㆁ', 'ㅋ'], - ᇰ: 'ㆁ', - ᇱ: ['ㆁ', 'ㅅ'], - ᇲ: ['ㆁ', 'ㅿ'], - ᇳ: ['ㅍ', 'ㅂ'], - ᇴ: 'ㆄ', - ᇵ: ['ㅎ', 'ㄴ'], - ᇶ: ['ㅎ', 'ㄹ'], - ᇷ: ['ㅎ', 'ㅁ'], - ᇸ: ['ㅎ', 'ㅂ'], - ᇹ: 'ㆆ', - ᇺ: ['ㄱ', 'ㄴ'], - ᇻ: ['ㄱ', 'ㅂ'], - ᇼ: ['ㄱ', 'ㅊ'], - ᇽ: ['ㄱ', 'ㅋ'], - ᇾ: ['ㄱ', 'ㅎ'], - ᇿ: ['ㄴ', 'ㄴ'], -}; -const jamoExtendedA$1 = { - ꥠ: ['ㄷ', 'ㅁ'], - ꥡ: ['ㄷ', 'ㅂ'], - ꥢ: ['ㄷ', 'ㅅ'], - ꥣ: ['ㄷ', 'ㅈ'], - ꥤ: ['ㄹ', 'ㄱ'], - ꥥ: ['ㄹ', 'ㄱ', 'ㄱ'], - ꥦ: ['ㄹ', 'ㄷ'], - ꥧ: ['ㄹ', 'ㄷ', 'ㄷ'], - ꥨ: ['ㄹ', 'ㅁ'], - ꥩ: ['ㄹ', 'ㅂ'], - ꥪ: ['ㄹ', 'ㅂ', 'ㅂ'], - ꥫ: ['ㄹ', 'ㅸ'], - ꥬ: ['ㄹ', 'ㅅ'], - ꥭ: ['ㄹ', 'ㅈ'], - ꥮ: ['ㄹ', 'ㅋ'], - ꥯ: ['ㅁ', 'ㄱ'], - ꥰ: ['ㅁ', 'ㄷ'], - ꥱ: ['ㅁ', 'ㅅ'], - ꥲ: ['ㅂ', 'ㅅ', 'ㅌ'], - ꥳ: ['ㅂ', 'ㅋ'], - ꥴ: ['ㅂ', 'ㅎ'], - ꥵ: ['ㅅ', 'ㅅ', 'ㅂ'], - ꥶ: ['ㅇ', 'ㄹ'], - ꥷ: ['ㅇ', 'ㅎ'], - ꥸ: ['ㅈ', 'ㅈ', 'ㅎ'], - ꥹ: ['ㅌ', 'ㅌ'], - ꥺ: ['ㅍ', 'ㅎ'], - ꥻ: ['ㅎ', 'ㅅ'], - ꥼ: ['ㆆ', 'ㆆ'], -}; -const jamoExtendedB$1 = { - ힰ: ['ㅗ', 'ㅕ'], - ힱ: ['ㅗ', 'ㅗ', 'ㅣ'], - ힲ: ['ㅛ', 'ㅏ'], - ힳ: ['ㅛ', 'ㅐ'], - ힴ: ['ㅛ', 'ㅓ'], - ힵ: ['ㅜ', 'ㅕ'], - ힶ: ['ㅜ', 'ㅣ', 'ㅣ'], - ힷ: ['ㅠ', 'ㅐ'], - ힸ: ['ㅠ', 'ㅗ'], - ힹ: ['ㅡ', 'ㅏ'], - ힺ: ['ㅡ', 'ㅓ'], - ힻ: ['ㅡ', 'ㅔ'], - ힼ: ['ㅡ', 'ㅗ'], - ힽ: ['ㅣ', 'ㅏ', 'ㅗ'], - ힾ: ['ㅣ', 'ㅒ'], - ힿ: ['ㅣ', 'ㅕ'], - ퟀ: ['ㅣ', 'ㅖ'], - ퟁ: ['ㅣ', 'ㅗ', 'ㅣ'], - ퟂ: ['ㅣ', 'ㅛ'], - ퟃ: ['ㅣ', 'ㅠ'], - ퟄ: ['ㅣ', 'ㅣ'], - ퟅ: ['ㆍ', 'ㅏ'], - ퟆ: ['ㆍ', 'ㅔ'], - ퟋ: ['ㄴ', 'ㄹ'], - ퟌ: ['ㄴ', 'ㅈ'], - ퟍ: ['ㄷ', 'ㄷ'], - ퟎ: ['ㄷ', 'ㄷ', 'ㅂ'], - ퟏ: ['ㄷ', 'ㅂ'], - ퟐ: ['ㄷ', 'ㅅ'], - ퟑ: ['ㄷ', 'ㅅ', 'ㄱ'], - ퟒ: ['ㄷ', 'ㅈ'], - ퟓ: ['ㄷ', 'ㅊ'], - ퟔ: ['ㄷ', 'ㅌ'], - ퟕ: ['ㄹ', 'ㄱ', 'ㄱ'], - ퟖ: ['ㄹ', 'ㄱ', 'ㅎ'], - ퟗ: ['ㄹ', 'ㄹ', 'ㅋ'], - ퟘ: ['ㄹ', 'ㅁ', 'ㅎ'], - ퟙ: ['ㄹ', 'ㅂ', 'ㄷ'], - ퟚ: ['ㄹ', 'ㅂ', 'ㅍ'], - ퟛ: ['ㄹ', 'ㆁ'], - ퟜ: ['ㄹ', 'ㆆ', 'ㅎ'], - ퟝ: null, - ퟞ: ['ㅁ', 'ㄴ'], - ퟟ: ['ㅁ', 'ㄴ', 'ㄴ'], - ퟠ: ['ㅁ', 'ㅁ'], - ퟡ: ['ㅁ', 'ㅂ', 'ㅅ'], - ퟢ: ['ㅁ', 'ㅈ'], - ퟣ: ['ㅂ', 'ㄷ'], - ퟤ: ['ㅂ', 'ㄹ', 'ㅍ'], - ퟥ: ['ㅂ', 'ㅁ'], - ퟦ: ['ㅂ', 'ㅂ'], - ퟧ: ['ㅂ', 'ㅅ', 'ㄷ'], - ퟨ: ['ㅂ', 'ㅈ'], - ퟩ: ['ㅂ', 'ㅊ'], - ퟪ: ['ㅅ', 'ㅁ'], - ퟫ: ['ㅅ', 'ㅸ'], - ퟬ: ['ㅅ', 'ㅅ', 'ㄱ'], - ퟭ: ['ㅅ', 'ㅅ', 'ㄷ'], - ퟮ: ['ㅅ', 'ㅿ'], - ퟯ: ['ㅅ', 'ㅈ'], - ퟰ: ['ㅅ', 'ㅊ'], - ퟱ: ['ㅅ', 'ㅌ'], - ퟲ: ['ㅅ', 'ㅎ'], - ퟳ: ['ㅿ', 'ㅂ'], - ퟴ: ['ㅿ', 'ㅸ'], - ퟵ: ['ㆁ', 'ㅁ'], - ퟶ: ['ㆁ', 'ㅎ'], - ퟷ: ['ㅈ', 'ㅂ'], - ퟸ: ['ㅈ', 'ㅂ', 'ㅂ'], - ퟹ: ['ㅈ', 'ㅈ'], - ퟺ: ['ㅍ', 'ㅅ'], - ퟻ: ['ㅍ', 'ㅌ'], -}; -const halfwidth$1 = { - ᄀ: 'ㄱ', - ᄁ: ['ㄱ', 'ㄱ'], - ᆪ: ['ㄱ', 'ㅅ'], - ᄂ: 'ㄴ', - ᆬ: ['ㄴ', 'ㅈ'], - ᆭ: ['ㄴ', 'ㅎ'], - ᄃ: 'ㄷ', - ᄄ: ['ㄷ', 'ㄷ'], - ᄅ: 'ㄹ', - ᆰ: ['ㄹ', 'ㄱ'], - ᆱ: ['ㄹ', 'ㅁ'], - ᆲ: ['ㄹ', 'ㅂ'], - ᆳ: ['ㄹ', 'ㅅ'], - ᆴ: ['ㄹ', 'ㅌ'], - ᆵ: ['ㄹ', 'ㅍ'], - ᄚ: ['ㄹ', 'ㅎ'], - ᄆ: 'ㅁ', - ᄇ: 'ㅂ', - ᄈ: ['ㅂ', 'ㅂ'], - ᄡ: ['ㅂ', 'ㅅ'], - ᄉ: 'ㅅ', - ᄊ: ['ㅅ', 'ㅅ'], - ᄋ: 'ㅇ', - ᄌ: 'ㅈ', - ᄍ: ['ㅈ', 'ㅈ'], - ᄎ: 'ㅊ', - ᄏ: 'ㅋ', - ᄐ: 'ㅌ', - ᄑ: 'ㅍ', - ᄒ: 'ㅎ', - ᅡ: 'ㅏ', - ᅢ: 'ㅐ', - ᅣ: 'ㅑ', - ᅤ: 'ㅒ', - ᅥ: 'ㅓ', - ᅦ: 'ㅔ', - ᅧ: 'ㅕ', - ᅨ: 'ㅖ', - ᅩ: 'ㅗ', - ᅪ: ['ㅗ', 'ㅏ'], - ᅫ: ['ㅗ', 'ㅐ'], - ᅬ: ['ㅗ', 'ㅣ'], - ᅭ: 'ㅛ', - ᅮ: 'ㅜ', - ᅯ: ['ㅜ', 'ㅓ'], - ᅰ: ['ㅜ', 'ㅔ'], - ᅱ: ['ㅜ', 'ㅣ'], - ᅲ: 'ㅠ', - ᅳ: 'ㅡ', - ᅴ: ['ㅡ', 'ㅣ'], - ᅵ: 'ㅣ', -}; -const all = Object.assign({}, jamo$1, jamoExtendedA$1, jamoExtendedB$1, halfwidth$1); - -// tries to transform everything into disassembled standard hangul - -const transformChar = char => (!standardHangul.contains(char) && all[char]) || char; -const transformDatum = datum => transformChar(Character(datum)); -const transformEveryChar = char => ( - (standardHangul.contains(char) ? pairs : all)[char] - || char -); -const transformEveryDatum = datum => transformEveryChar(Character(datum)); -// transform everything just means that it also transforms -// standard hangul characters instead of ignoring them - -// this way, we can trust the inputs to composeAnything -const assembleFactory = transformer => (data, mode) => deepFlatResMap(transformer(data), composeAnything(mode)); -// the transformer should verify that each datum is a Character! -const assembleTransformer = data => deepMap(data, transformEveryDatum); -// this takes a CharacterGroup and transforms characters and -// complex characters, effectively leaving behind only the -// base Characters -// it doesn't decomposeSyllables though -var assemble = (assembleFactory(assembleTransformer)); - -const composeComplexCho = composeComplex(noUseJungJong); -const transformExceptCho = (char) => { - const res = transformEveryChar(char); - if (Array.isArray(res)) { - const comp = composeComplexCho(res); - // the default composeComplex only composes cho - // HACK: this bug might be an issue with composeComplex - if (Array.isArray(comp) && comp.length === 1) { - // if the composition actually ends up composing - // something and it's only one Character, just - // return the Character instead of an Array - return Character(comp); - } - return comp; - } - return res; -}; -// this function is needed by disassemble so it's trusting -var decomposeComplex = ((datum, decomposeDoubles) => toArray((decomposeDoubles ? transformEveryChar : transformExceptCho)(Character(datum)))); - -const trustMe = (char) => { - const code = char.codePointAt(0) - syllables.start; - const jongNum$$1 = code % 28; - const q = (code - jongNum$$1) / 28; - const jungNum$$1 = q % 21; - const choNum$$1 = 0 | q / 21; // basically Math.floor(q / 21) - return [cho$1[choNum$$1], jung$1[jungNum$$1], jong$1[jongNum$$1]].filter(v => v); - // the .filter(v => v) removes blank space in the array -}; -var decomposeSyllable = ((datum, hardFail) => { - const char = Character(datum); - if (!syllables.contains(char)) { - if (hardFail) { - throw Error('Decomposing a syllable requires a syllable to decompose!'); - } - return [datum]; - // if there's no hardFail, the function must - // still return the same type as it would have - // if it didn't fail - } - return trustMe(char); -}); - -const disassembleFactory = transformer => (datum) => { - const char = Character(datum); - if (syllables.contains(char)) { - return trustMe(char).map(transformer); - // that .map(transformEverything) catches the complex - // characters that decomposeSyllable returns - } - // otherwise try breaking complex characters apart - return transformer(char); -}; -const disassembleAll = disassembleFactory(transformEveryChar); -const disassemble = disassembleFactory(transformExceptCho); -// not to be confused with Hangul.disassemble -// this disassemble takes Characters as inputs, not CharacterGroups -const disassembleChar = (datum, grouped, decomposeDoubles) => { - const res = (decomposeDoubles ? disassembleAll : disassemble)(datum); - if (!grouped) { - return flatten(res); - } - return res; -}; -var disassemble$1 = ((data, grouped, decomposeDoubles) => (grouped ? deepMap : deepFlatMap)(data, decomposeDoubles ? disassembleAll : disassemble, true)); -// I know this looks really bad since it's all on -// one line but ESlint was being really finicky - -var name = ((obj) => { - Object.keys(obj).forEach((key) => { - obj[key].displayName = key; - }); -}); - -// This file is only used in ../publicCompose -// all is the only one of these that's actually used -// I can't Object.assign them all together unfortunately -const all$1 = { - ㄱ: { - ㄱ: 'ㄲ', - ㅅ: 'ㄳ', - }, - ㄷ: { - ㄷ: 'ㄸ', - }, - ㅅ: { - ㅅ: 'ㅆ', - ㄱ: 'ㅺ', - ㄴ: 'ㅻ', - ㄷ: 'ㅼ', - ㅂ: 'ㅽ', - ㅈ: 'ㅾ', - }, - ㅈ: { - ㅈ: 'ㅉ', - }, - ㅂ: { - ㅂ: 'ㅃ', - ㅅ: { - $: 'ㅄ', - ㄱ: 'ㅴ', - ㄷ: 'ㅵ', - }, - ㄱ: 'ㅲ', - ㄷ: 'ㅳ', - ㅈ: 'ㅶ', - ㅌ: 'ㅷ', - }, - ㅗ: { - ㅏ: 'ㅘ', - ㅐ: 'ㅙ', - ㅣ: 'ㅚ', - }, - ㅜ: { - ㅓ: 'ㅝ', - ㅔ: 'ㅞ', - ㅣ: 'ㅟ', - }, - ㅡ: { - ㅣ: 'ㅢ', - }, - ㄴ: { - ㅈ: 'ㄵ', - ㅎ: 'ㄶ', - ㄴ: 'ㅥ', - ㄷ: 'ㅦ', - ㅅ: 'ㅧ', - ㅿ: 'ㅨ', - }, - ㄹ: { - ㄱ: { - $: 'ㄺ', - ㅅ: 'ㅩ', - }, - ㅁ: 'ㄻ', - ㅂ: { - $: 'ㄼ', - ㅅ: 'ㅫ', - }, - ㅅ: 'ㄽ', - ㅌ: 'ㄾ', - ㅍ: 'ㄿ', - ㅎ: 'ㅀ', - ㄷ: 'ㅪ', - ㅿ: 'ㅬ', - ㆆ: 'ㅭ', - }, - ㅁ: { - ㅂ: 'ㅮ', - ㅅ: 'ㅯ', - ㅿ: 'ㅰ', - }, - ㅇ: { - ㅇ: 'ㆀ', - }, - ㆁ: { - ㅅ: 'ㆁ', - ㅿ: 'ㅿ', - }, - ㅎ: { - ㅎ: 'ㆅ', - }, - ㅛ: { - ㅑ: 'ㆇ', - ㅒ: 'ㆈ', - ㅣ: 'ㆉ', - }, - ㅠ: { - ㅕ: 'ㆊ', - ㅖ: 'ㆋ', - ㅣ: 'ㆌ', - }, - ㆍ: { - ㅣ: 'ㆎ', - }, -}; - -const standardizeCharacterBase = (mode) => { - const cc = composeComplex(mode); - return (datum) => { - const res = transformDatum(datum); - if (Array.isArray(res)) { - // atempt compose only if the value is an array - // it's unfortunate, but any compFn is untrusting - // since it's basically accessed publicly - // we know that v will always have good types - // but compFn will still check for Characters - return cc(res); - // returns an Array - } - return res; - }; -}; -const standardizeFactory = ((mode) => { - const currentStandardize = standardizeCharacterBase(mode); - return (data, grouped) => (grouped ? deepMap : deepFlatMap)(data, currentStandardize); -}); -var standardize = ((data, grouped, mode) => standardizeFactory(mode)(data, grouped)); - -// since these functions are exposed, the characters must be -// standardized so that the libaray can function properly -const standardizeCharacter = standardizeCharacterBase(useComp3 | useArchaic); -const complex$1 = (first, second, third = '', hardFail) => { - if (first === undefined || second === undefined) { - throw Error('Cannot compose a complex with less than two values!'); - } - const d1 = all$1[standardizeCharacter(first)]; - // depth 1 - if (!d1) { - if (hardFail) { - throw Error(`There's no complex character that starts with ${first}`); - } - return `${first}${second}${third}`; - } - const d2 = d1[standardizeCharacter(second)]; - // depth 2 - if (!d2) { - if (hardFail) { - throw Error(`Cannot combine ${first} and ${second}`); - } - return `${first}${second}${third}`; - } - const d2val = d2.$ || d2; - if (third) { - // if there's a third character (optional) - const d3 = d2[standardizeCharacter(third)]; - // depth 3 - if (!d3) { - // if depth 3 doesn't exist - if (hardFail) { - throw Error(`Found ${d2val} but cannot combine ${first}, ${second}, and ${third}`); - // the reason for this ^^^ is because sometimes - // d2 is a string rather than an object - } - return `${d2val}${third}`; - // at depth three, there should be a complex formed from - // the first and second characters so return that instead - // of the inputs concatenated - } - return d3; // this should always be a string - } - // the third character was falsy so just return the composition - return d2val; -}; -// this function will always return a String or it'll error (hardFail) -// there's probably a better way to structure these if-statements -// so if anyone comes up with one, I'll take it - -const syllable = (choChar, jungChar = '', jongChar = '', hardFail) => { - const cho = choNum[standardizeCharacter(choChar)]; - const jung = jungNum[standardizeCharacter(jungChar)]; - let jong; - if (jongChar) { - jong = jongNum[standardizeCharacter(jongChar)]; - } if (!Number.isInteger(cho)) { - if (hardFail) { - throw Error(`"${choChar}" is not a valid cho Character`); - } - return `${choChar}${jungChar}${jongChar}`; - } if (!Number.isInteger(jung)) { - if (hardFail) { - throw Error(`"${jungChar}" is not a valid jung Character`); - } - return `${choChar}${jungChar}${jongChar}`; - } if (jongChar && !Number.isInteger(jong)) { - // check if it exists because !Number.isInteger(undefined) - // is true and we don't want that happening since jongChar - // is optional - if (hardFail) { - throw Error(`"${jongChar}" is not a valid jong character`); - } - // getting here means that the cho and jung - // characters were valid, so call composeSyllable - return `${composeSyllableFn(cho, jung)}${jongChar}`; - } - return composeSyllableFn(cho, jung, jong); -}; -// by nesting all if-statements under if (hardFail) -// there might be a little better performance but I'm -// sure that it's pretty trivial. - -const standardizeComp3Archaic = standardizeFactory(useComp3 | useArchaic); -// support all types of complex -var stronger$1 = (data => standardizeComp3Archaic(data).map(char => stronger[char] || char)); - -const hangulToKeyFn = char => hangulToKey[char] || char; -const keyToHangulFn = char => keyToHangul[char]; -const transformToKeys = (hangulChar) => { - const res = transformExceptCho(hangulChar); - return Array.isArray(res) ? res.map(hangulToKeyFn) : hangulToKeyFn(res); -}; -const disassembleToKeys = disassembleFactory(transformToKeys); -const toKeys = (data, grouped) => (grouped ? deepMap : deepFlatMap)(data, disassembleToKeys); -const transformCharToHangul = (latinDatum) => { - const latinChar = Character(latinDatum); - const res = keyToHangulFn(latinChar); - if (!res) { - // couldn't find a key for that characters - const lowerCaseRes = keyToHangulFn(latinChar.toLowerCase()); - if (!lowerCaseRes) { - return latinChar; - } - return lowerCaseRes; - } - return res; -}; -// it's okay that we're not standarizing because the data -// in hangulToKey is already standard :) -const transformToHangul = data => deepMap(data, transformCharToHangul); -const assembleFromKeys = assembleFactory(transformToHangul); -const fromKeys = data => assembleFromKeys(data, noCompDouble); - -var testMulti = (aryFnName => isFn => data => deepFlatMap(data, transformEveryDatum)[aryFnName](isFn)); - -var contains = (testMulti('some')); - -var is = (isFn => (datum) => { - const res = transformEveryDatum(datum); - // it's okay that we don't check if data is - // a Character since transformEveryCharacter does. - return Array.isArray(res) ? res.every(isFn) : isFn(res); -}); - -var isAll = (testMulti('every')); - -const consonant = char => consonants[char]; -const isConsonant = is(consonant); -const isConsonantAll = isAll(consonant); -const containsConsonant = contains(consonant); -name({ - isConsonant, - isConsonantAll, - containsConsonant, -}); - -const isAll$1 = testFn => (data) => { - const len = data.length; - if (Array.isArray(data)) { - for (let i = 0; i < len; i++) { - const val = data[i]; - if (isCharacterGroup(val) ? isAll$1(testFn)(val) : testFn(val)) { - continue; - } - // the loop will get here if it doesn't satisfy the testing function - return false; - } - return true; - } if (typeof data === 'string') { - for (let i = 0; i < len; i++) { - const val = data[i]; - if (testFn(val)) { - continue; - } - return false; - } - return true; - } - throw TypeError('The data must be an Array or a String!'); -}; -const contains$1 = testFn => (data) => { - const len = data.length; - if (Array.isArray(data)) { - for (let i = 0; i < len; i++) { - const val = data[i]; - if (isCharacterGroup(val) ? isAll$1(testFn)(val) : testFn(val)) { - return true; - // this allows the function to short circut - } - } - return false; - } if (typeof data === 'string') { - for (let i = 0; i < len; i++) { - const val = data[i]; - if (testFn(val)) { - return true; - } - } - return false; - } - throw TypeError('The data must be an Array or a String!'); -}; - -const isJamo = datum => jamo.contains(Character(datum)); -const isCompatibilityJamo = datum => compatibilityJamo.contains(Character(datum)); -const isJamoExtendedA = datum => jamoExtendedA.char(Character(datum)); -const isSyllable = datum => syllables.contains(Character(datum)); -const isJamoExtendedB = datum => jamoExtendedB.contains(Character(datum)); -const isHalfwidth = datum => halfwidth.contains(Character(datum)); -const isReserved = datum => reserved.contains(Character(datum)); -const isStandardHangul = datum => standardHangul.contains(Character(datum)); -const isHangul = datum => hangul.contains(Character(datum)); - -const isAllJamo = isAll$1(isJamo); -const containsJamo = contains$1(isJamo); - -const isAllCompatibilityJamo = isAll$1(isCompatibilityJamo); -const containsCompatibilityJamo = contains$1(isCompatibilityJamo); - -const isAllJamoExtendedA = isAll$1(isJamoExtendedA); -const containsJamoExtendedA = contains$1(isJamoExtendedA); - -const isAllSyllable = isAll$1(isSyllable); -const containsSyllable = contains$1(isSyllable); - -const isAllJamoExtendedB = isAll$1(isJamoExtendedB); -const containsJamoExtendedB = contains$1(isJamoExtendedB); - -const isAllHalfwidth = isAll$1(isHalfwidth); -const containsHalfwidth = contains$1(isHalfwidth); - -const isAllReserved = isAll$1(isReserved); -const containsReserved = contains$1(isReserved); - -const isAllStandardHangul = isAll$1(isStandardHangul); -const containsStandardHangul = contains$1(isStandardHangul); - -const isAllHangul = isAll$1(isHangul); -const containsHangul = contains$1(isHangul); -name({ - isJamo, - isAllJamo, - containsJamo, - - isCompatibilityJamo, - isAllCompatibilityJamo, - containsCompatibilityJamo, - - isJamoExtendedA, - isAllJamoExtendedA, - containsJamoExtendedA, - - isSyllable, - isAllSyllable, - containsSyllable, - - isJamoExtendedB, - isAllJamoExtendedB, - containsJamoExtendedB, - - isHalfwidth, - isAllHalfwidth, - containsHalfwidth, - - isReserved, - isAllReserved, - containsReserved, - - isStandardHangul, - isAllStandardHangul, - containsStandardHangul, - - isHangul, - isAllHangul, - containsHangul, -}); - -const vowel = char => vowels[char]; -const isVowel$1 = is(vowel); -const isVowelAll = isAll(vowel); -const containsVowel = contains(vowel); -name({ - isVowel: isVowel$1, - isVowelAll, - containsVowel, -}); - -name({ - assemble, - - disassemble: disassemble$1, - disassembleCharacter: disassembleChar, - - composeComplex: complex$1, - composeSyllable: syllable, - - stronger: stronger$1, -}); - -exports.assemble = assemble; -exports.a = assemble; -exports.disassemble = disassemble$1; -exports.d = disassemble$1; -exports.disassembleCharacter = disassembleChar; -exports.composeComplex = complex$1; -exports.composeSyllable = syllable; -exports.stronger = stronger$1; -exports.useComp3 = useComp3; -exports.useArchaic = useArchaic; -exports.noUseJungJong = noUseJungJong; -exports.noCompDouble = noCompDouble; -exports.decomposeComplex = decomposeComplex; -exports.decomposeSyllable = decomposeSyllable; -exports.standardize = standardize; -exports.flatten = flatten; -exports.deepMap = deepMap; -exports.toKeys = toKeys; -exports.fromKeys = fromKeys; -exports.isConsonant = isConsonant; -exports.isConsonantAll = isConsonantAll; -exports.containsConsonant = containsConsonant; -exports.isJamo = isJamo; -exports.isCompatibilityJamo = isCompatibilityJamo; -exports.isJamoExtendedA = isJamoExtendedA; -exports.isSyllable = isSyllable; -exports.isJamoExtendedB = isJamoExtendedB; -exports.isHalfwidth = isHalfwidth; -exports.isReserved = isReserved; -exports.isStandardHangul = isStandardHangul; -exports.isHangul = isHangul; -exports.isAllJamo = isAllJamo; -exports.containsJamo = containsJamo; -exports.isAllCompatibilityJamo = isAllCompatibilityJamo; -exports.containsCompatibilityJamo = containsCompatibilityJamo; -exports.isAllJamoExtendedA = isAllJamoExtendedA; -exports.containsJamoExtendedA = containsJamoExtendedA; -exports.isAllSyllable = isAllSyllable; -exports.containsSyllable = containsSyllable; -exports.isAllJamoExtendedB = isAllJamoExtendedB; -exports.containsJamoExtendedB = containsJamoExtendedB; -exports.isAllHalfwidth = isAllHalfwidth; -exports.containsHalfwidth = containsHalfwidth; -exports.isAllReserved = isAllReserved; -exports.containsReserved = containsReserved; -exports.isAllStandardHangul = isAllStandardHangul; -exports.containsStandardHangul = containsStandardHangul; -exports.isAllHangul = isAllHangul; -exports.containsHangul = containsHangul; -exports.isVowel = isVowel$1; -exports.isVowelAll = isVowelAll; -exports.containsVowel = containsVowel; diff --git a/dist/cjs/Hangul.min.js b/dist/cjs/Hangul.min.js deleted file mode 100644 index 02e7730..0000000 --- a/dist/cjs/Hangul.min.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const consonants={"ㄱ":1,"ㄴ":1,"ㄷ":1,"ㄹ":1,"ㅁ":1,"ㅂ":1,"ㅅ":1,"ㅇ":1,"ㅈ":1,"ㅊ":1,"ㅋ":1,"ㅌ":1,"ㅍ":1,"ㅎ":1,"ㆁ":1,"ㆄ":1,"ㅱ":1,"ㅿ":1},vowels={"ㅏ":1,"ㅐ":1,"ㅑ":1,"ㅓ":1,"ㅔ":1,"ㅕ":1,"ㅖ":1,"ㅗ":1,"ㅛ":1,"ㅜ":1,"ㅠ":1,"ㅡ":1,"ㅣ":1,"ㆍ":1},hangulToKey={"ㅂ":"q","ㅃ":"Q","ㅈ":"w","ㅉ":"W","ㄷ":"e","ㄸ":"E","ㄱ":"r","ㄲ":"R","ㅅ":"t","ㅆ":"T","ㅛ":"y","ㅕ":"u","ㅑ":"i","ㅐ":"o","ㅒ":"O","ㅔ":"p","ㅖ":"P","ㅁ":"a","ㄴ":"s","ㅇ":"d","ㄹ":"f","ㅎ":"g","ㅗ":"h","ㅓ":"j","ㅏ":"k","ㅣ":"l","ㅋ":"z","ㅌ":"x","ㅊ":"c","ㅍ":"v","ㅠ":"b","ㅜ":"n","ㅡ":"m"},keyToHangul={q:"ㅂ",Q:"ㅃ",w:"ㅈ",W:"ㅉ",e:"ㄷ",E:"ㄸ",r:"ㄱ",R:"ㄲ",t:"ㅅ",T:"ㅆ",y:"ㅛ",u:"ㅕ",i:"ㅑ",o:"ㅐ",O:"ㅒ",p:"ㅔ",P:"ㅖ",a:"ㅁ",s:"ㄴ",d:"ㅇ",f:"ㄹ",g:"ㅎ",h:"ㅗ",j:"ㅓ",k:"ㅏ",l:"ㅣ",z:"ㅋ",x:"ㅌ",c:"ㅊ",v:"ㅍ",b:"ㅠ",n:"ㅜ",m:"ㅡ"},cho={"ㄱㄱ":"ㄲ","ㄷㄷ":"ㄸ","ㅅㅅ":"ㅆ","ㅈㅈ":"ㅉ","ㅂㅂ":"ㅃ"},jung={"ㅗㅏ":"ㅘ","ㅗㅐ":"ㅙ","ㅗㅣ":"ㅚ","ㅜㅓ":"ㅝ","ㅜㅔ":"ㅞ","ㅜㅣ":"ㅟ","ㅡㅣ":"ㅢ"},jong={"ㄱㄱ":"ㄲ","ㄱㅅ":"ㄳ","ㄴㅈ":"ㄵ","ㄴㅎ":"ㄶ","ㄹㄱ":"ㄺ","ㄹㅁ":"ㄻ","ㄹㅂ":"ㄼ","ㄹㅅ":"ㄽ","ㄹㅌ":"ㄾ","ㄹㅍ":"ㄿ","ㄹㅎ":"ㅀ","ㅂㅅ":"ㅄ","ㅅㅅ":"ㅆ"},archaic={"ㄴㄴ":"ㅥ","ㄴㄷ":"ㅦ","ㄴㅅ":"ㅧ","ㄴㅿ":"ㅨ","ㄹㄱㅅ":"ㅩ","ㄹㄷ":"ㅪ","ㄹㅂㅅ":"ㅫ","ㄹㅿ":"ㅬ","ㄹㆆ":"ㅭ","ㅁㅂ":"ㅮ","ㅁㅅ":"ㅯ","ㅁㅿ":"ㅰ","ㅂㄱ":"ㅲ","ㅂㄷ":"ㅳ","ㅂㅅㄱ":"ㅴ","ㅂㅅㄷ":"ㅵ","ㅂㅈ":"ㅶ","ㅂㅌ":"ㅷ","ㅅㄱ":"ㅺ","ㅅㄴ":"ㅻ","ㅅㄷ":"ㅼ","ㅅㅂ":"ㅽ","ㅅㅈ":"ㅾ","ㅇㅇ":"ㆀ","ㆁㅅ":"ㆁ","ㆁㅿ":"ㅿ","ㅎㅎ":"ㆅ","ㅛㅑ":"ㆇ","ㅛㅒ":"ㆈ","ㅛㅣ":"ㆉ","ㅠㅕ":"ㆊ","ㅠㅖ":"ㆋ","ㅠㅣ":"ㆌ","ㆍㅣ":"ㆎ"},pairs={"ㄲ":["ㄱ","ㄱ"],"ㄳ":["ㄱ","ㅅ"],"ㄵ":["ㄴ","ㅈ"],"ㄶ":["ㄴ","ㅎ"],"ㄸ":["ㄷ","ㄷ"],"ㄻ":["ㄹ","ㅁ"],"ㄺ":["ㄹ","ㄱ"],"ㄼ":["ㄹ","ㅂ"],"ㄽ":["ㄹ","ㅅ"],"ㄾ":["ㄹ","ㅌ"],"ㄿ":["ㄹ","ㅍ"],"ㅀ":["ㄹ","ㅎ"],"ㅃ":["ㅂ","ㅂ"],"ㅄ":["ㅂ","ㅅ"],"ㅆ":["ㅅ","ㅅ"],"ㅉ":["ㅈ","ㅈ"],"ㅘ":["ㅗ","ㅏ"],"ㅙ":["ㅗ","ㅐ"],"ㅚ":["ㅗ","ㅣ"],"ㅝ":["ㅜ","ㅓ"],"ㅞ":["ㅜ","ㅔ"],"ㅟ":["ㅜ","ㅣ"],"ㅢ":["ㅡ","ㅣ"],"ㅥ":["ㄴ","ㄴ"],"ㅦ":["ㄴ","ㄷ"],"ㅧ":["ㄴ","ㅅ"],"ㅨ":["ㄴ","ㅿ"],"ㅩ":["ㄹ","ㄱ","ㅅ"],"ㅪ":["ㄹ","ㄷ"],"ㅫ":["ㄹ","ㅂ","ㅅ"],"ㅬ":["ㄹ","ㅿ"],"ㅭ":["ㄹ","ㆆ"],"ㅮ":["ㅁ","ㅂ"],"ㅯ":["ㅁ","ㅅ"],"ㅰ":["ㅁ","ㅿ"],"ㅲ":["ㅂ","ㄱ"],"ㅳ":["ㅂ","ㄷ"],"ㅴ":["ㅂ","ㅅ","ㄱ"],"ㅵ":["ㅂ","ㅅ","ㄷ"],"ㅶ":["ㅂ","ㅈ"],"ㅷ":["ㅂ","ㅌ"],"ㅺ":["ㅅ","ㄱ"],"ㅻ":["ㅅ","ㄴ"],"ㅼ":["ㅅ","ㄷ"],"ㅽ":["ㅅ","ㅂ"],"ㅾ":["ㅅ","ㅈ"],"ㆀ":["ㅇ","ㅇ"],"ㆂ":["ㆁ","ㅅ"],"ㆃ":["ㆁ","ㅿ"],"ㆅ":["ㅎ","ㅎ"],"ㆇ":["ㅛ","ㅑ"],"ㆈ":["ㅛ","ㅒ"],"ㆉ":["ㅛ","ㅣ"],"ㆊ":["ㅠ","ㅕ"],"ㆋ":["ㅠ","ㅖ"],"ㆌ":["ㅠ","ㅣ"],"ㆎ":["ㆍ","ㅣ"]},complex={"ㄲ":1,"ㄳ":1,"ㄵ":1,"ㄶ":1,"ㄸ":1,"ㄺ":1,"ㄻ":1,"ㄼ":1,"ㄽ":1,"ㄾ":1,"ㄿ":1,"ㅀ":1,"ㅃ":1,"ㅄ":1,"ㅆ":1,"ㅉ":1,"ㅘ":1,"ㅙ":1,"ㅚ":1,"ㅝ":1,"ㅞ":1,"ㅟ":1,"ㅢ":1},irregularComplex={"ㅥ":1,"ㅦ":1,"ㅧ":1,"ㅨ":1,"ㅩ":1,"ㅪ":1,"ㅫ":1,"ㅬ":1,"ㅭ":1,"ㅮ":1,"ㅯ":1,"ㅰ":1,"ㅱ":1,"ㅲ":1,"ㅳ":1,"ㅴ":1,"ㅵ":1,"ㅶ":1,"ㅷ":1},complexList=Object.assign({},complex,irregularComplex),stronger={"ㄱ":"ㄲ","ㅋ":"ㄲ","ㄷ":"ㄸ","ㅌ":"ㄸ","ㅂ":"ㅃ","ㅍ":"ㅃ","ㅅ":"ㅆ","ㅈ":"ㅉ","ㅊ":"ㅉ"},cho$1=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],jung$1=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],jong$1=[null,"ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],choNum={"ㄱ":0,"ㄲ":1,"ㄴ":2,"ㄷ":3,"ㄸ":4,"ㄹ":5,"ㅁ":6,"ㅂ":7,"ㅃ":8,"ㅅ":9,"ㅆ":10,"ㅇ":11,"ㅈ":12,"ㅉ":13,"ㅊ":14,"ㅋ":15,"ㅌ":16,"ㅍ":17,"ㅎ":18},jungNum={"ㅏ":0,"ㅐ":1,"ㅑ":2,"ㅒ":3,"ㅓ":4,"ㅔ":5,"ㅕ":6,"ㅖ":7,"ㅗ":8,"ㅘ":9,"ㅙ":10,"ㅚ":11,"ㅛ":12,"ㅜ":13,"ㅝ":14,"ㅞ":15,"ㅟ":16,"ㅠ":17,"ㅡ":18,"ㅢ":19,"ㅣ":20},jongNum={"ㄱ":1,"ㄲ":2,"ㄳ":3,"ㄴ":4,"ㄵ":5,"ㄶ":6,"ㄷ":7,"ㄹ":8,"ㄺ":9,"ㄻ":10,"ㄼ":11,"ㄽ":12,"ㄾ":13,"ㄿ":14,"ㅀ":15,"ㅁ":16,"ㅂ":17,"ㅄ":18,"ㅅ":19,"ㅆ":20,"ㅇ":21,"ㅈ":22,"ㅊ":23,"ㅋ":24,"ㅌ":25,"ㅍ":26,"ㅎ":27};class UnicodeRange{constructor(e,a){this.start=e,this.end=a}containsCodePoint(e){return e>=this.start&&e<=this.end}contains(e){return this.containsCodePoint(e.codePointAt(0))}}class CombinedRange{constructor(e,a={}){this.ranges=e,this.codePoints=a}containsCodePoint(e){return this.codePoints&&this.codePoints[e]||this.ranges.some(a=>a.containsCodePoint(e))}contains(e){const a=e.codePointAt(0);return this.containsCodePoint(a)}}const jamo=new UnicodeRange(4352,4607),compatibilityJamo=new UnicodeRange(12592,12687),jamoExtendedA=new UnicodeRange(43360,43391),syllables=new UnicodeRange(44032,55215),jamoExtendedB=new UnicodeRange(55216,55295),halfwidth=new UnicodeRange(65440,65503),reserved=new CombinedRange([new UnicodeRange(43389,43391),new UnicodeRange(55204,55215),new UnicodeRange(55239,55242),new UnicodeRange(55292,55295)],{12592:1,12687:1}),standardHangul=new CombinedRange([compatibilityJamo,syllables]),hangul=new CombinedRange([jamo,compatibilityJamo,jamoExtendedA,syllables,jamoExtendedB,halfwidth,reserved]);var composeSyllable=(e,a,s=0)=>String.fromCodePoint(588*e+28*a+s+syllables.start);class Result{constructor(e="",a=[]){this.result=e,this.remainder=a}}const Character=e=>{const a=`${e}`;if(1!==a.length)throw Error(`"${a}" is not a Character!`);return a},ENOARYLIKE=()=>{throw TypeError("The data must be an Array or a String!")},toArray=e=>Array.isArray(e)?e:e.split(""),isCharacterGroup=e=>!(e.length<1)&&(Array.isArray(e)?e.length>1||isCharacterGroup(e[0]):"string"==typeof e&&e.length>1),identity=e=>e,deepMap=(e,a,s)=>{const t=s?toArray:identity;return Array.isArray(e)?e.map(e=>isCharacterGroup(e)?deepMap(e,a,s):t(a(e))):"string"==typeof e?e.split("").map(e=>t(a(e))):void ENOARYLIKE()},deepFlatMap=(e,a)=>{let s="";if(Array.isArray(e)){const t=e.length;for(let n=0;n{if(Array.isArray(e)){let a="";const s=e.length;for(let t=0;t{let s,t="";if(Array.isArray(e)){s=[];const t=e.length;for(let n=0;n{if(e<0||e>8)throw Error("The mode cannot be less than zero or greater than eight!");const a=2&e,s=a&&1&e,t=8&e;let n=objCache[e];if(!n){const s=[cho];4&e||s.push(jung,jong),a&&s.push(archaic),n=Object.assign({},...s),objCache[e]=n}return e=>{const a=e.length;if(a<1)throw Error("Cannot compose array of zero characters!");const o=e[0];if(a<2)return new Result(o);const r=e[1];if(t&&o===r)return new Result(o,e.slice(1));const l=n[o+r];if(l){if(s&&a>2){const a=n[o+r+e[2]];if(a)return new Result(a,e.slice(3))}return new Result(l,e.slice(2))}return new Result(o,e.slice(1))}},composeComplex=e=>{const a=composeComplexBase(e);return e=>deepFlatResMap(e,a)},isVowel=e=>e&&"ㆍ"!==e&&vowels[e];var composeAnything=e=>{const a=composeComplexBase(e);return e=>{if(e.length<2)return new Result(e[0]);const s=a(e),t=s.result,n=s.remainder,o=choNum[t];if(n.length<1||!Number.isInteger(o))return s;const r=a(n),l=r.result,i=r.remainder,c=jungNum[l];if(!Number.isInteger(c))return new Result(t,[l,...i]);if(i.length&&!isVowel(i[1])){const e=a(i),s=e.result,t=e.remainder,n=jongNum[s];if(n)return new Result(composeSyllable(o,c,n),t)}return new Result(composeSyllable(o,c),i)}};const jamo$1={"ᄀ":"ㄱ","ᄁ":["ㄱ","ㄱ"],"ᄂ":"ㄴ","ᄃ":"ㄷ","ᄄ":["ㄷ","ㄷ"],"ᄅ":"ㄹ","ᄆ":"ㅁ","ᄇ":"ㅂ","ᄈ":["ㅂ","ㅂ"],"ᄉ":"ㅅ","ᄊ":["ㅅ","ㅅ"],"ᄋ":"ㅇ","ᄌ":"ㅈ","ᄍ":["ㅈ","ㅈ"],"ᄎ":"ㅊ","ᄏ":"ㅋ","ᄐ":"ㅌ","ᄑ":"ㅍ","ᄒ":"ㅎ","ᄓ":["ㄴ","ㄱ"],"ᄔ":["ㄴ","ㄴ"],"ᄕ":["ㄴ","ㄷ"],"ᄖ":["ㄴ","ㅂ"],"ᄗ":["ㄷ","ㄱ"],"ᄘ":["ㄹ","ㄴ"],"ᄙ":["ㄹ","ㄹ"],"ᄚ":["ㄹ","ㅎ"],"ᄛ":["ㄹ","ㅇ"],"ᄜ":["ㅁ","ㅂ"],"ᄝ":"ㅱ","ᄞ":["ㅂ","ㄱ"],"ᄟ":["ㅂ","ㄴ"],"ᄠ":["ㅂ","ㄷ"],"ᄡ":["ㅂ","ㅅ"],"ᄢ":["ㅂ","ㅅ","ㄱ"],"ᄣ":["ㅂ","ㅅ","ㄷ"],"ᄤ":["ㅂ","ㅅ","ㅂ"],"ᄥ":["ㅂ","ㅅ","ㅅ"],"ᄦ":["ㅂ","ㅅ","ㅈ"],"ᄧ":["ㅂ","ㅈ"],"ᄨ":["ㅂ","ㅊ"],"ᄩ":["ㅂ","ㅌ"],"ᄪ":["ㅂ","ㅍ"],"ᄫ":["ㅂ","ㅇ"],"ᄬ":[["ㅂ","ㅂ"],"ㅇ"],"ᄭ":["ㅅ","ㄱ"],"ᄮ":["ㅅ","ㄴ"],"ᄯ":["ㅅ","ㄷ"],"ᄰ":["ㅅ","ㄹ"],"ᄱ":["ㅅ","ㅁ"],"ᄲ":["ㅅ","ㅂ"],"ᄳ":["ㅅ","ㅂ","ㄱ"],"ᄴ":["ㅅ","ㅅ","ㅅ"],"ᄵ":["ㅅ","ㅇ"],"ᄶ":["ㅅ","ㅈ"],"ᄷ":["ㅅ","ㅊ"],"ᄸ":["ㅅ","ㅋ"],"ᄹ":["ㅅ","ㅌ"],"ᄺ":["ㅅ","ㅍ"],"ᄻ":["ㅅ","ㅎ"],"ᄼ":null,"ᄽ":null,"ᄾ":null,"ᄿ":null,"ᅀ":"ㅿ","ᅁ":["ㅇ","ㄱ"],"ᅂ":["ㅇ","ㄷ"],"ᅃ":["ㅇ","ㅁ"],"ᅄ":["ㅇ","ㅂ"],"ᅅ":["ㅇ","ㅅ"],"ᅆ":["ㅇ","ㅿ"],"ᅇ":["ㅇ","ㅇ"],"ᅈ":["ㅇ","ㅈ"],"ᅉ":["ㅇ","ㅊ"],"ᅊ":["ㅇ","ㅌ"],"ᅋ":["ㅇ","ㅍ"],"ᅌ":"ㆁ","ᅍ":["ㅈ","ㅇ"],"ᅎ":null,"ᅏ":null,"ᅐ":null,"ᅑ":null,"ᅒ":["ㅊ","ㅋ"],"ᅓ":["ㅊ","ㅎ"],"ᅔ":null,"ᅕ":null,"ᅖ":["ㅍ","ㅂ"],"ᅗ":"ㆄ","ᅘ":["ㅎ","ㅎ"],"ᅙ":"ㆆ","ᅚ":["ㄱ","ㄷ"],"ᅛ":["ㄱ","ㅅ"],"ᅜ":["ㄱ","ㅈ"],"ᅝ":["ㄱ","ㅎ"],"ᅞ":["ㄷ","ㄹ"],"ᅡ":"ㅏ","ᅢ":"ㅐ","ᅣ":"ㅑ","ᅤ":"ㅒ","ᅥ":"ㅓ","ᅦ":"ㅔ","ᅧ":"ㅕ","ᅨ":"ㅖ","ᅩ":"ㅗ","ᅪ":["ㅗ","ㅏ"],"ᅫ":["ㅗ","ㅐ"],"ᅬ":["ㅗ","ㅣ"],"ᅭ":"ㅛ","ᅮ":"ㅜ","ᅯ":["ㅜ","ㅓ"],"ᅰ":["ㅜ","ㅔ"],"ᅱ":["ㅜ","ㅣ"],"ᅲ":"ㅠ","ᅳ":"ㅡ","ᅴ":["ㅡ","ㅣ"],"ᅵ":"ㅣ","ᅶ":["ㅏ","ㅗ"],"ᅷ":["ㅏ","ㅜ"],"ᅸ":["ㅑ","ㅗ"],"ᅹ":["ㅑ","ㅛ"],"ᅺ":["ㅓ","ㅗ"],"ᅻ":["ㅓ","ㅜ"],"ᅼ":["ㅓ","ㅡ"],"ᅽ":["ㅕ","ㅗ"],"ᅾ":["ㅕ","ㅜ"],"ᅿ":["ㅗ","ㅓ"],"ᆀ":["ㅔ","ㅗ"],"ᆁ":["ㅖ","ㅗ"],"ᆂ":["ㅗ","ㅗ"],"ᆃ":["ㅗ","ㅜ"],"ᆄ":["ㅛ","ㅑ"],"ᆅ":["ㅛ","ㅒ"],"ᆆ":["ㅛ","ㅕ"],"ᆇ":["ㅛ","ㅗ"],"ᆈ":["ㅛ","ㅣ"],"ᆉ":["ㅜ","ㅏ"],"ᆊ":["ㅜ","ㅐ"],"ᆋ":["ㅜ","ㅓ","ㅡ"],"ᆌ":["ㅜ","ㅖ"],"ᆍ":["ㅜ","ㅜ"],"ᆎ":["ㅠ","ㅏ"],"ᆏ":["ㅠ","ㅓ"],"ᆐ":["ㅠ","ㅔ"],"ᆑ":["ㅠ","ㅕ"],"ᆒ":["ㅠ","ㅔ"],"ᆓ":["ㅠ","ㅜ"],"ᆔ":["ㅠ","ㅣ"],"ᆕ":["ㅡ","ㅜ"],"ᆖ":["ㅡ","ㅡ"],"ᆗ":["ㅡ","ㅣ","ㅜ"],"ᆘ":["ㅣ","ㅏ"],"ᆙ":["ㅣ","ㅑ"],"ᆚ":["ㅣ","ㅗ"],"ᆛ":["ㅣ","ㅜ"],"ᆜ":["ㅣ","ㅡ"],"ᆝ":null,"ᆞ":"ㆍ","ᆟ":["ㆍ","ㅓ"],"ᆠ":["ㆍ","ㅜ"],"ᆡ":["ㆍ","ㅣ"],"ᆢ":["ㆍ","ㆍ"],"ᆣ":["ㅏ","ㅡ"],"ᆤ":["ㅑ","ㅜ"],"ᆥ":["ㅕ","ㅑ"],"ᆦ":["ㅗ","ㅑ"],"ᆧ":["ㅗ","ㅒ"],"ᆨ":"ㄱ","ᆩ":["ㄱ","ㄱ"],"ᆪ":["ㄱ","ㅅ"],"ᆫ":"ㄴ","ᆬ":["ㄴ","ㅈ"],"ᆭ":["ㄴ","ㅎ"],"ᆮ":"ㄷ","ᆯ":"ㄹ","ᆰ":["ㄹ","ㄱ"],"ᆱ":["ㄹ","ㅁ"],"ᆲ":["ㄹ","ㅂ"],"ᆳ":["ㄹ","ㅅ"],"ᆴ":["ㄹ","ㅌ"],"ᆵ":["ㄹ","ㅍ"],"ᆶ":["ㄹ","ㅎ"],"ᆷ":"ㅁ","ᆸ":"ㅂ","ᆹ":["ㅂ","ㅅ"],"ᆺ":"ㅅ","ᆻ":["ㅅ","ㅅ"],"ᆼ":"ㅇ","ᆽ":"ㅈ","ᆾ":"ㅊ","ᆿ":"ㅋ","ᇀ":"ㅌ","ᇁ":"ㅍ","ᇂ":"ㅎ","ᇃ":["ㄱ","ㄹ"],"ᇄ":["ㄱ","ㅅ","ㄱ"],"ᇅ":["ㄴ","ㄱ"],"ᇆ":["ㄴ","ㄷ"],"ᇇ":["ㄴ","ㅅ"],"ᇈ":["ㄴ","ㅿ"],"ᇉ":["ㄴ","ㅌ"],"ᇊ":["ㄷ","ㄱ"],"ᇋ":["ㄷ","ㄹ"],"ᇌ":["ㄹ","ㄱ","ㅅ"],"ᇍ":["ㄹ","ㄴ"],"ᇎ":["ㄹ","ㄷ"],"ᇏ":["ㄹ","ㄷ","ㅎ"],"ᇐ":["ㄹ","ㄹ"],"ᇑ":["ㄹ","ㅁ","ㄱ"],"ᇒ":["ㄹ","ㅁ","ㅅ"],"ᇓ":["ㄹ","ㅂ","ㅅ"],"ᇔ":["ㄹ","ㅂ","ㅎ"],"ᇕ":["ㄹ","ㅸ"],"ᇖ":["ㄹ","ㅅ","ㅅ"],"ᇗ":["ㄹ","ㅿ"],"ᇘ":["ㄹ","ㅋ"],"ᇙ":["ㄹ","ㆆ"],"ᇚ":["ㅁ","ㄱ"],"ᇛ":["ㅁ","ㄹ"],"ᇜ":["ㅁ","ㅂ"],"ᇝ":["ㅁ","ㅅ"],"ᇞ":["ㅁ","ㅅ","ㅅ"],"ᇟ":["ㅁ","ㅿ"],"ᇠ":["ㅁ","ㅊ"],"ᇡ":["ㅁ","ㅎ"],"ᇢ":"ㅱ","ᇣ":["ㅂ","ㄹ"],"ᇤ":["ㅂ","ㅍ"],"ᇥ":["ㅂ","ㅎ"],"ᇦ":["ㅂ","ㅇ"],"ᇧ":["ㅅ","ㄱ"],"ᇨ":["ㅅ","ㄷ"],"ᇩ":["ㅅ","ㄹ"],"ᇪ":["ㅅ","ㅂ"],"ᇫ":"ㅿ","ᇬ":["ㆁ","ㄱ"],"ᇭ":["ㆁ","ㄱ","ㄱ"],"ᇮ":["ㆁ","ㆁ"],"ᇯ":["ㆁ","ㅋ"],"ᇰ":"ㆁ","ᇱ":["ㆁ","ㅅ"],"ᇲ":["ㆁ","ㅿ"],"ᇳ":["ㅍ","ㅂ"],"ᇴ":"ㆄ","ᇵ":["ㅎ","ㄴ"],"ᇶ":["ㅎ","ㄹ"],"ᇷ":["ㅎ","ㅁ"],"ᇸ":["ㅎ","ㅂ"],"ᇹ":"ㆆ","ᇺ":["ㄱ","ㄴ"],"ᇻ":["ㄱ","ㅂ"],"ᇼ":["ㄱ","ㅊ"],"ᇽ":["ㄱ","ㅋ"],"ᇾ":["ㄱ","ㅎ"],"ᇿ":["ㄴ","ㄴ"]},jamoExtendedA$1={"ꥠ":["ㄷ","ㅁ"],"ꥡ":["ㄷ","ㅂ"],"ꥢ":["ㄷ","ㅅ"],"ꥣ":["ㄷ","ㅈ"],"ꥤ":["ㄹ","ㄱ"],"ꥥ":["ㄹ","ㄱ","ㄱ"],"ꥦ":["ㄹ","ㄷ"],"ꥧ":["ㄹ","ㄷ","ㄷ"],"ꥨ":["ㄹ","ㅁ"],"ꥩ":["ㄹ","ㅂ"],"ꥪ":["ㄹ","ㅂ","ㅂ"],"ꥫ":["ㄹ","ㅸ"],"ꥬ":["ㄹ","ㅅ"],"ꥭ":["ㄹ","ㅈ"],"ꥮ":["ㄹ","ㅋ"],"ꥯ":["ㅁ","ㄱ"],"ꥰ":["ㅁ","ㄷ"],"ꥱ":["ㅁ","ㅅ"],"ꥲ":["ㅂ","ㅅ","ㅌ"],"ꥳ":["ㅂ","ㅋ"],"ꥴ":["ㅂ","ㅎ"],"ꥵ":["ㅅ","ㅅ","ㅂ"],"ꥶ":["ㅇ","ㄹ"],"ꥷ":["ㅇ","ㅎ"],"ꥸ":["ㅈ","ㅈ","ㅎ"],"ꥹ":["ㅌ","ㅌ"],"ꥺ":["ㅍ","ㅎ"],"ꥻ":["ㅎ","ㅅ"],"ꥼ":["ㆆ","ㆆ"]},jamoExtendedB$1={"ힰ":["ㅗ","ㅕ"],"ힱ":["ㅗ","ㅗ","ㅣ"],"ힲ":["ㅛ","ㅏ"],"ힳ":["ㅛ","ㅐ"],"ힴ":["ㅛ","ㅓ"],"ힵ":["ㅜ","ㅕ"],"ힶ":["ㅜ","ㅣ","ㅣ"],"ힷ":["ㅠ","ㅐ"],"ힸ":["ㅠ","ㅗ"],"ힹ":["ㅡ","ㅏ"],"ힺ":["ㅡ","ㅓ"],"ힻ":["ㅡ","ㅔ"],"ힼ":["ㅡ","ㅗ"],"ힽ":["ㅣ","ㅏ","ㅗ"],"ힾ":["ㅣ","ㅒ"],"ힿ":["ㅣ","ㅕ"],"ퟀ":["ㅣ","ㅖ"],"ퟁ":["ㅣ","ㅗ","ㅣ"],"ퟂ":["ㅣ","ㅛ"],"ퟃ":["ㅣ","ㅠ"],"ퟄ":["ㅣ","ㅣ"],"ퟅ":["ㆍ","ㅏ"],"ퟆ":["ㆍ","ㅔ"],"ퟋ":["ㄴ","ㄹ"],"ퟌ":["ㄴ","ㅈ"],"ퟍ":["ㄷ","ㄷ"],"ퟎ":["ㄷ","ㄷ","ㅂ"],"ퟏ":["ㄷ","ㅂ"],"ퟐ":["ㄷ","ㅅ"],"ퟑ":["ㄷ","ㅅ","ㄱ"],"ퟒ":["ㄷ","ㅈ"],"ퟓ":["ㄷ","ㅊ"],"ퟔ":["ㄷ","ㅌ"],"ퟕ":["ㄹ","ㄱ","ㄱ"],"ퟖ":["ㄹ","ㄱ","ㅎ"],"ퟗ":["ㄹ","ㄹ","ㅋ"],"ퟘ":["ㄹ","ㅁ","ㅎ"],"ퟙ":["ㄹ","ㅂ","ㄷ"],"ퟚ":["ㄹ","ㅂ","ㅍ"],"ퟛ":["ㄹ","ㆁ"],"ퟜ":["ㄹ","ㆆ","ㅎ"],"ퟝ":null,"ퟞ":["ㅁ","ㄴ"],"ퟟ":["ㅁ","ㄴ","ㄴ"],"ퟠ":["ㅁ","ㅁ"],"ퟡ":["ㅁ","ㅂ","ㅅ"],"ퟢ":["ㅁ","ㅈ"],"ퟣ":["ㅂ","ㄷ"],"ퟤ":["ㅂ","ㄹ","ㅍ"],"ퟥ":["ㅂ","ㅁ"],"ퟦ":["ㅂ","ㅂ"],"ퟧ":["ㅂ","ㅅ","ㄷ"],"ퟨ":["ㅂ","ㅈ"],"ퟩ":["ㅂ","ㅊ"],"ퟪ":["ㅅ","ㅁ"],"ퟫ":["ㅅ","ㅸ"],"ퟬ":["ㅅ","ㅅ","ㄱ"],"ퟭ":["ㅅ","ㅅ","ㄷ"],"ퟮ":["ㅅ","ㅿ"],"ퟯ":["ㅅ","ㅈ"],"ퟰ":["ㅅ","ㅊ"],"ퟱ":["ㅅ","ㅌ"],"ퟲ":["ㅅ","ㅎ"],"ퟳ":["ㅿ","ㅂ"],"ퟴ":["ㅿ","ㅸ"],"ퟵ":["ㆁ","ㅁ"],"ퟶ":["ㆁ","ㅎ"],"ퟷ":["ㅈ","ㅂ"],"ퟸ":["ㅈ","ㅂ","ㅂ"],"ퟹ":["ㅈ","ㅈ"],"ퟺ":["ㅍ","ㅅ"],"ퟻ":["ㅍ","ㅌ"]},halfwidth$1={"ᄀ":"ㄱ","ᄁ":["ㄱ","ㄱ"],"ᆪ":["ㄱ","ㅅ"],"ᄂ":"ㄴ","ᆬ":["ㄴ","ㅈ"],"ᆭ":["ㄴ","ㅎ"],"ᄃ":"ㄷ","ᄄ":["ㄷ","ㄷ"],"ᄅ":"ㄹ","ᆰ":["ㄹ","ㄱ"],"ᆱ":["ㄹ","ㅁ"],"ᆲ":["ㄹ","ㅂ"],"ᆳ":["ㄹ","ㅅ"],"ᆴ":["ㄹ","ㅌ"],"ᆵ":["ㄹ","ㅍ"],"ᄚ":["ㄹ","ㅎ"],"ᄆ":"ㅁ","ᄇ":"ㅂ","ᄈ":["ㅂ","ㅂ"],"ᄡ":["ㅂ","ㅅ"],"ᄉ":"ㅅ","ᄊ":["ㅅ","ㅅ"],"ᄋ":"ㅇ","ᄌ":"ㅈ","ᄍ":["ㅈ","ㅈ"],"ᄎ":"ㅊ","ᄏ":"ㅋ","ᄐ":"ㅌ","ᄑ":"ㅍ","ᄒ":"ㅎ","ᅡ":"ㅏ","ᅢ":"ㅐ","ᅣ":"ㅑ","ᅤ":"ㅒ","ᅥ":"ㅓ","ᅦ":"ㅔ","ᅧ":"ㅕ","ᅨ":"ㅖ","ᅩ":"ㅗ","ᅪ":["ㅗ","ㅏ"],"ᅫ":["ㅗ","ㅐ"],"ᅬ":["ㅗ","ㅣ"],"ᅭ":"ㅛ","ᅮ":"ㅜ","ᅯ":["ㅜ","ㅓ"],"ᅰ":["ㅜ","ㅔ"],"ᅱ":["ㅜ","ㅣ"],"ᅲ":"ㅠ","ᅳ":"ㅡ","ᅴ":["ㅡ","ㅣ"],"ᅵ":"ㅣ"},all=Object.assign({},jamo$1,jamoExtendedA$1,jamoExtendedB$1,halfwidth$1),transformChar=e=>!standardHangul.contains(e)&&all[e]||e,transformDatum=e=>transformChar(Character(e)),transformEveryChar=e=>(standardHangul.contains(e)?pairs:all)[e]||e,transformEveryDatum=e=>transformEveryChar(Character(e)),assembleFactory=e=>(a,s)=>deepFlatResMap(e(a),composeAnything(s)),assembleTransformer=e=>deepMap(e,transformEveryDatum);var assemble=assembleFactory(assembleTransformer);const composeComplexCho=composeComplex(4),transformExceptCho=e=>{const a=transformEveryChar(e);if(Array.isArray(a)){const e=composeComplexCho(a);return Array.isArray(e)&&1===e.length?Character(e):e}return a};var decomposeComplex=(e,a)=>toArray((a?transformEveryChar:transformExceptCho)(Character(e)));const trustMe=e=>{const a=e.codePointAt(0)-syllables.start,s=a%28,t=(a-s)/28,n=t%21;return[cho$1[0|t/21],jung$1[n],jong$1[s]].filter(e=>e)};var decomposeSyllable=(e,a)=>{const s=Character(e);if(!syllables.contains(s)){if(a)throw Error("Decomposing a syllable requires a syllable to decompose!");return[e]}return trustMe(s)};const disassembleFactory=e=>a=>{const s=Character(a);return syllables.contains(s)?trustMe(s).map(e):e(s)},disassembleAll=disassembleFactory(transformEveryChar),disassemble=disassembleFactory(transformExceptCho),disassembleChar=(e,a,s)=>{const t=(s?disassembleAll:disassemble)(e);return a?t:flatten(t)};var disassemble$1=(e,a,s)=>(a?deepMap:deepFlatMap)(e,s?disassembleAll:disassemble,!0),name=e=>{Object.keys(e).forEach(a=>{e[a].displayName=a})};const all$1={"ㄱ":{"ㄱ":"ㄲ","ㅅ":"ㄳ"},"ㄷ":{"ㄷ":"ㄸ"},"ㅅ":{"ㅅ":"ㅆ","ㄱ":"ㅺ","ㄴ":"ㅻ","ㄷ":"ㅼ","ㅂ":"ㅽ","ㅈ":"ㅾ"},"ㅈ":{"ㅈ":"ㅉ"},"ㅂ":{"ㅂ":"ㅃ","ㅅ":{$:"ㅄ","ㄱ":"ㅴ","ㄷ":"ㅵ"},"ㄱ":"ㅲ","ㄷ":"ㅳ","ㅈ":"ㅶ","ㅌ":"ㅷ"},"ㅗ":{"ㅏ":"ㅘ","ㅐ":"ㅙ","ㅣ":"ㅚ"},"ㅜ":{"ㅓ":"ㅝ","ㅔ":"ㅞ","ㅣ":"ㅟ"},"ㅡ":{"ㅣ":"ㅢ"},"ㄴ":{"ㅈ":"ㄵ","ㅎ":"ㄶ","ㄴ":"ㅥ","ㄷ":"ㅦ","ㅅ":"ㅧ","ㅿ":"ㅨ"},"ㄹ":{"ㄱ":{$:"ㄺ","ㅅ":"ㅩ"},"ㅁ":"ㄻ","ㅂ":{$:"ㄼ","ㅅ":"ㅫ"},"ㅅ":"ㄽ","ㅌ":"ㄾ","ㅍ":"ㄿ","ㅎ":"ㅀ","ㄷ":"ㅪ","ㅿ":"ㅬ","ㆆ":"ㅭ"},"ㅁ":{"ㅂ":"ㅮ","ㅅ":"ㅯ","ㅿ":"ㅰ"},"ㅇ":{"ㅇ":"ㆀ"},"ㆁ":{"ㅅ":"ㆁ","ㅿ":"ㅿ"},"ㅎ":{"ㅎ":"ㆅ"},"ㅛ":{"ㅑ":"ㆇ","ㅒ":"ㆈ","ㅣ":"ㆉ"},"ㅠ":{"ㅕ":"ㆊ","ㅖ":"ㆋ","ㅣ":"ㆌ"},"ㆍ":{"ㅣ":"ㆎ"}},standardizeCharacterBase=e=>{const a=composeComplex(e);return e=>{const s=transformDatum(e);return Array.isArray(s)?a(s):s}},standardizeFactory=e=>{const a=standardizeCharacterBase(e);return(e,s)=>(s?deepMap:deepFlatMap)(e,a)};var standardize=(e,a,s)=>standardizeFactory(s)(e,a);const standardizeCharacter=standardizeCharacterBase(3),complex$1=(e,a,s="",t)=>{if(void 0===e||void 0===a)throw Error("Cannot compose a complex with less than two values!");const n=all$1[standardizeCharacter(e)];if(!n){if(t)throw Error(`There's no complex character that starts with ${e}`);return`${e}${a}${s}`}const o=n[standardizeCharacter(a)];if(!o){if(t)throw Error(`Cannot combine ${e} and ${a}`);return`${e}${a}${s}`}const r=o.$||o;if(s){const n=o[standardizeCharacter(s)];if(!n){if(t)throw Error(`Found ${r} but cannot combine ${e}, ${a}, and ${s}`);return`${r}${s}`}return n}return r},syllable=(e,a="",s="",t)=>{const n=choNum[standardizeCharacter(e)],o=jungNum[standardizeCharacter(a)];let r;if(s&&(r=jongNum[standardizeCharacter(s)]),!Number.isInteger(n)){if(t)throw Error(`"${e}" is not a valid cho Character`);return`${e}${a}${s}`}if(!Number.isInteger(o)){if(t)throw Error(`"${a}" is not a valid jung Character`);return`${e}${a}${s}`}if(s&&!Number.isInteger(r)){if(t)throw Error(`"${s}" is not a valid jong character`);return`${composeSyllable(n,o)}${s}`}return composeSyllable(n,o,r)},standardizeComp3Archaic=standardizeFactory(3);var stronger$1=e=>standardizeComp3Archaic(e).map(e=>stronger[e]||e);const hangulToKeyFn=e=>hangulToKey[e]||e,keyToHangulFn=e=>keyToHangul[e],transformToKeys=e=>{const a=transformExceptCho(e);return Array.isArray(a)?a.map(hangulToKeyFn):hangulToKeyFn(a)},disassembleToKeys=disassembleFactory(transformToKeys),toKeys=(e,a)=>(a?deepMap:deepFlatMap)(e,disassembleToKeys),transformCharToHangul=e=>{const a=Character(e),s=keyToHangulFn(a);if(!s){const e=keyToHangulFn(a.toLowerCase());return e||a}return s},transformToHangul=e=>deepMap(e,transformCharToHangul),assembleFromKeys=assembleFactory(transformToHangul),fromKeys=e=>assembleFromKeys(e,8);var testMulti=e=>a=>s=>deepFlatMap(s,transformEveryDatum)[e](a),contains=testMulti("some"),is=e=>a=>{const s=transformEveryDatum(a);return Array.isArray(s)?s.every(e):e(s)},isAll=testMulti("every");const consonant=e=>consonants[e],isConsonant=is(consonant),isConsonantAll=isAll(consonant),containsConsonant=contains(consonant);name({isConsonant:isConsonant,isConsonantAll:isConsonantAll,containsConsonant:containsConsonant});const isAll$1=e=>a=>{const s=a.length;if(Array.isArray(a)){for(let t=0;ta=>{const s=a.length;if(Array.isArray(a)){for(let t=0;tjamo.contains(Character(e)),isCompatibilityJamo=e=>compatibilityJamo.contains(Character(e)),isJamoExtendedA=e=>jamoExtendedA.char(Character(e)),isSyllable=e=>syllables.contains(Character(e)),isJamoExtendedB=e=>jamoExtendedB.contains(Character(e)),isHalfwidth=e=>halfwidth.contains(Character(e)),isReserved=e=>reserved.contains(Character(e)),isStandardHangul=e=>standardHangul.contains(Character(e)),isHangul=e=>hangul.contains(Character(e)),isAllJamo=isAll$1(isJamo),containsJamo=contains$1(isJamo),isAllCompatibilityJamo=isAll$1(isCompatibilityJamo),containsCompatibilityJamo=contains$1(isCompatibilityJamo),isAllJamoExtendedA=isAll$1(isJamoExtendedA),containsJamoExtendedA=contains$1(isJamoExtendedA),isAllSyllable=isAll$1(isSyllable),containsSyllable=contains$1(isSyllable),isAllJamoExtendedB=isAll$1(isJamoExtendedB),containsJamoExtendedB=contains$1(isJamoExtendedB),isAllHalfwidth=isAll$1(isHalfwidth),containsHalfwidth=contains$1(isHalfwidth),isAllReserved=isAll$1(isReserved),containsReserved=contains$1(isReserved),isAllStandardHangul=isAll$1(isStandardHangul),containsStandardHangul=contains$1(isStandardHangul),isAllHangul=isAll$1(isHangul),containsHangul=contains$1(isHangul);name({isJamo:isJamo,isAllJamo:isAllJamo,containsJamo:containsJamo,isCompatibilityJamo:isCompatibilityJamo,isAllCompatibilityJamo:isAllCompatibilityJamo,containsCompatibilityJamo:containsCompatibilityJamo,isJamoExtendedA:isJamoExtendedA,isAllJamoExtendedA:isAllJamoExtendedA,containsJamoExtendedA:containsJamoExtendedA,isSyllable:isSyllable,isAllSyllable:isAllSyllable,containsSyllable:containsSyllable,isJamoExtendedB:isJamoExtendedB,isAllJamoExtendedB:isAllJamoExtendedB,containsJamoExtendedB:containsJamoExtendedB,isHalfwidth:isHalfwidth,isAllHalfwidth:isAllHalfwidth,containsHalfwidth:containsHalfwidth,isReserved:isReserved,isAllReserved:isAllReserved,containsReserved:containsReserved,isStandardHangul:isStandardHangul,isAllStandardHangul:isAllStandardHangul,containsStandardHangul:containsStandardHangul,isHangul:isHangul,isAllHangul:isAllHangul,containsHangul:containsHangul});const vowel=e=>vowels[e],isVowel$1=is(vowel),isVowelAll=isAll(vowel),containsVowel=contains(vowel);name({isVowel:isVowel$1,isVowelAll:isVowelAll,containsVowel:containsVowel}),name({assemble:assemble,disassemble:disassemble$1,disassembleCharacter:disassembleChar,composeComplex:complex$1,composeSyllable:syllable,stronger:stronger$1}),exports.assemble=assemble,exports.a=assemble,exports.disassemble=disassemble$1,exports.d=disassemble$1,exports.disassembleCharacter=disassembleChar,exports.composeComplex=complex$1,exports.composeSyllable=syllable,exports.stronger=stronger$1,exports.useComp3=1,exports.useArchaic=2,exports.noUseJungJong=4,exports.noCompDouble=8,exports.decomposeComplex=decomposeComplex,exports.decomposeSyllable=decomposeSyllable,exports.standardize=standardize,exports.flatten=flatten,exports.deepMap=deepMap,exports.toKeys=toKeys,exports.fromKeys=fromKeys,exports.isConsonant=isConsonant,exports.isConsonantAll=isConsonantAll,exports.containsConsonant=containsConsonant,exports.isJamo=isJamo,exports.isCompatibilityJamo=isCompatibilityJamo,exports.isJamoExtendedA=isJamoExtendedA,exports.isSyllable=isSyllable,exports.isJamoExtendedB=isJamoExtendedB,exports.isHalfwidth=isHalfwidth,exports.isReserved=isReserved,exports.isStandardHangul=isStandardHangul,exports.isHangul=isHangul,exports.isAllJamo=isAllJamo,exports.containsJamo=containsJamo,exports.isAllCompatibilityJamo=isAllCompatibilityJamo,exports.containsCompatibilityJamo=containsCompatibilityJamo,exports.isAllJamoExtendedA=isAllJamoExtendedA,exports.containsJamoExtendedA=containsJamoExtendedA,exports.isAllSyllable=isAllSyllable,exports.containsSyllable=containsSyllable,exports.isAllJamoExtendedB=isAllJamoExtendedB,exports.containsJamoExtendedB=containsJamoExtendedB,exports.isAllHalfwidth=isAllHalfwidth,exports.containsHalfwidth=containsHalfwidth,exports.isAllReserved=isAllReserved,exports.containsReserved=containsReserved,exports.isAllStandardHangul=isAllStandardHangul,exports.containsStandardHangul=containsStandardHangul,exports.isAllHangul=isAllHangul,exports.containsHangul=containsHangul,exports.isVowel=isVowel$1,exports.isVowelAll=isVowelAll,exports.containsVowel=containsVowel; diff --git a/dist/iife/Hangul.js b/dist/iife/Hangul.js deleted file mode 100644 index 5e1903c..0000000 --- a/dist/iife/Hangul.js +++ /dev/null @@ -1,1705 +0,0 @@ -var Hangul = (function (exports) { - 'use strict'; - - const consonants = { - ㄱ: 1, - ㄴ: 1, - ㄷ: 1, - ㄹ: 1, - ㅁ: 1, - ㅂ: 1, - ㅅ: 1, - ㅇ: 1, - ㅈ: 1, - ㅊ: 1, - ㅋ: 1, - ㅌ: 1, - ㅍ: 1, - ㅎ: 1, - ㆁ: 1, // apparently this is now "ㅇ" - ㆄ: 1, - ㅱ: 1, - ㅿ: 1, - }; - const vowels = { - ㅏ: 1, - ㅐ: 1, - ㅑ: 1, - ㅓ: 1, - ㅔ: 1, - ㅕ: 1, - ㅖ: 1, - ㅗ: 1, - ㅛ: 1, - ㅜ: 1, - ㅠ: 1, - ㅡ: 1, - ㅣ: 1, - ㆍ: 1, - }; - const hangulToKey = { - ㅂ: 'q', - ㅃ: 'Q', - ㅈ: 'w', - ㅉ: 'W', - ㄷ: 'e', - ㄸ: 'E', - ㄱ: 'r', - ㄲ: 'R', - ㅅ: 't', - ㅆ: 'T', - ㅛ: 'y', - ㅕ: 'u', - ㅑ: 'i', - ㅐ: 'o', - ㅒ: 'O', - ㅔ: 'p', - ㅖ: 'P', - ㅁ: 'a', - ㄴ: 's', - ㅇ: 'd', - ㄹ: 'f', - ㅎ: 'g', - ㅗ: 'h', - ㅓ: 'j', - ㅏ: 'k', - ㅣ: 'l', - ㅋ: 'z', - ㅌ: 'x', - ㅊ: 'c', - ㅍ: 'v', - ㅠ: 'b', - ㅜ: 'n', - ㅡ: 'm', - }; - const keyToHangul = { - q: 'ㅂ', - Q: 'ㅃ', - w: 'ㅈ', - W: 'ㅉ', - e: 'ㄷ', - E: 'ㄸ', - r: 'ㄱ', - R: 'ㄲ', - t: 'ㅅ', - T: 'ㅆ', - y: 'ㅛ', - u: 'ㅕ', - i: 'ㅑ', - o: 'ㅐ', - O: 'ㅒ', - p: 'ㅔ', - P: 'ㅖ', - a: 'ㅁ', - s: 'ㄴ', - d: 'ㅇ', - f: 'ㄹ', - g: 'ㅎ', - h: 'ㅗ', - j: 'ㅓ', - k: 'ㅏ', - l: 'ㅣ', - z: 'ㅋ', - x: 'ㅌ', - c: 'ㅊ', - v: 'ㅍ', - b: 'ㅠ', - n: 'ㅜ', - m: 'ㅡ', - }; - // the reason the data is stored like this is because iterating - // through an array is slower than just getting a key from an object - // In this case though, it might be faster since arrays are allocated - // on the heap instead of the stack? - - // I realize that I can programmatically reverse the key-value pairs during - // runtime but since I can just do it now, it's just a little faster. - - const cho = { - ㄱㄱ: 'ㄲ', - ㄷㄷ: 'ㄸ', - ㅅㅅ: 'ㅆ', - ㅈㅈ: 'ㅉ', - ㅂㅂ: 'ㅃ', - }; - const jung = { - ㅗㅏ: 'ㅘ', - ㅗㅐ: 'ㅙ', - ㅗㅣ: 'ㅚ', - ㅜㅓ: 'ㅝ', - ㅜㅔ: 'ㅞ', - ㅜㅣ: 'ㅟ', - ㅡㅣ: 'ㅢ', - }; - const jong = { - ㄱㄱ: 'ㄲ', - ㄱㅅ: 'ㄳ', - ㄴㅈ: 'ㄵ', - ㄴㅎ: 'ㄶ', - ㄹㄱ: 'ㄺ', - ㄹㅁ: 'ㄻ', - ㄹㅂ: 'ㄼ', - ㄹㅅ: 'ㄽ', - ㄹㅌ: 'ㄾ', - ㄹㅍ: 'ㄿ', - ㄹㅎ: 'ㅀ', - ㅂㅅ: 'ㅄ', - ㅅㅅ: 'ㅆ', - }; - const archaic = { - ㄴㄴ: 'ㅥ', - ㄴㄷ: 'ㅦ', - ㄴㅅ: 'ㅧ', - ㄴㅿ: 'ㅨ', - ㄹㄱㅅ: 'ㅩ', - ㄹㄷ: 'ㅪ', - ㄹㅂㅅ: 'ㅫ', - ㄹㅿ: 'ㅬ', - ㄹㆆ: 'ㅭ', - ㅁㅂ: 'ㅮ', - ㅁㅅ: 'ㅯ', - ㅁㅿ: 'ㅰ', - ㅂㄱ: 'ㅲ', - ㅂㄷ: 'ㅳ', - ㅂㅅㄱ: 'ㅴ', - ㅂㅅㄷ: 'ㅵ', - ㅂㅈ: 'ㅶ', - ㅂㅌ: 'ㅷ', - ㅅㄱ: 'ㅺ', - ㅅㄴ: 'ㅻ', - ㅅㄷ: 'ㅼ', - ㅅㅂ: 'ㅽ', - ㅅㅈ: 'ㅾ', - ㅇㅇ: 'ㆀ', - ㆁㅅ: 'ㆁ', - ㆁㅿ: 'ㅿ', - ㅎㅎ: 'ㆅ', - ㅛㅑ: 'ㆇ', - ㅛㅒ: 'ㆈ', - ㅛㅣ: 'ㆉ', - ㅠㅕ: 'ㆊ', - ㅠㅖ: 'ㆋ', - ㅠㅣ: 'ㆌ', - ㆍㅣ: 'ㆎ', - }; - const pairs = { - ㄲ: ['ㄱ', 'ㄱ'], - ㄳ: ['ㄱ', 'ㅅ'], - ㄵ: ['ㄴ', 'ㅈ'], - ㄶ: ['ㄴ', 'ㅎ'], - ㄸ: ['ㄷ', 'ㄷ'], - ㄻ: ['ㄹ', 'ㅁ'], - ㄺ: ['ㄹ', 'ㄱ'], - ㄼ: ['ㄹ', 'ㅂ'], - ㄽ: ['ㄹ', 'ㅅ'], - ㄾ: ['ㄹ', 'ㅌ'], - ㄿ: ['ㄹ', 'ㅍ'], - ㅀ: ['ㄹ', 'ㅎ'], - ㅃ: ['ㅂ', 'ㅂ'], - ㅄ: ['ㅂ', 'ㅅ'], - ㅆ: ['ㅅ', 'ㅅ'], - ㅉ: ['ㅈ', 'ㅈ'], - ㅘ: ['ㅗ', 'ㅏ'], - ㅙ: ['ㅗ', 'ㅐ'], - ㅚ: ['ㅗ', 'ㅣ'], - ㅝ: ['ㅜ', 'ㅓ'], - ㅞ: ['ㅜ', 'ㅔ'], - ㅟ: ['ㅜ', 'ㅣ'], - ㅢ: ['ㅡ', 'ㅣ'], - ㅥ: ['ㄴ', 'ㄴ'], - ㅦ: ['ㄴ', 'ㄷ'], - ㅧ: ['ㄴ', 'ㅅ'], - ㅨ: ['ㄴ', 'ㅿ'], - ㅩ: ['ㄹ', 'ㄱ', 'ㅅ'], - ㅪ: ['ㄹ', 'ㄷ'], - ㅫ: ['ㄹ', 'ㅂ', 'ㅅ'], - ㅬ: ['ㄹ', 'ㅿ'], - ㅭ: ['ㄹ', 'ㆆ'], - ㅮ: ['ㅁ', 'ㅂ'], - ㅯ: ['ㅁ', 'ㅅ'], - ㅰ: ['ㅁ', 'ㅿ'], - ㅲ: ['ㅂ', 'ㄱ'], - ㅳ: ['ㅂ', 'ㄷ'], - ㅴ: ['ㅂ', 'ㅅ', 'ㄱ'], - ㅵ: ['ㅂ', 'ㅅ', 'ㄷ'], - ㅶ: ['ㅂ', 'ㅈ'], - ㅷ: ['ㅂ', 'ㅌ'], - ㅺ: ['ㅅ', 'ㄱ'], - ㅻ: ['ㅅ', 'ㄴ'], - ㅼ: ['ㅅ', 'ㄷ'], - ㅽ: ['ㅅ', 'ㅂ'], - ㅾ: ['ㅅ', 'ㅈ'], - ㆀ: ['ㅇ', 'ㅇ'], - ㆂ: ['ㆁ', 'ㅅ'], - ㆃ: ['ㆁ', 'ㅿ'], - ㆅ: ['ㅎ', 'ㅎ'], - ㆇ: ['ㅛ', 'ㅑ'], - ㆈ: ['ㅛ', 'ㅒ'], - ㆉ: ['ㅛ', 'ㅣ'], - ㆊ: ['ㅠ', 'ㅕ'], - ㆋ: ['ㅠ', 'ㅖ'], - ㆌ: ['ㅠ', 'ㅣ'], - ㆎ: ['ㆍ', 'ㅣ'], - }; - const complex = { - ㄲ: 1, - ㄳ: 1, - ㄵ: 1, - ㄶ: 1, - ㄸ: 1, - ㄺ: 1, - ㄻ: 1, - ㄼ: 1, - ㄽ: 1, - ㄾ: 1, - ㄿ: 1, - ㅀ: 1, - ㅃ: 1, - ㅄ: 1, - ㅆ: 1, - ㅉ: 1, - ㅘ: 1, - ㅙ: 1, - ㅚ: 1, - ㅝ: 1, - ㅞ: 1, - ㅟ: 1, - ㅢ: 1, - }; - const irregularComplex = { - ㅥ: 1, - ㅦ: 1, - ㅧ: 1, - ㅨ: 1, - ㅩ: 1, - ㅪ: 1, - ㅫ: 1, - ㅬ: 1, - ㅭ: 1, - ㅮ: 1, - ㅯ: 1, - ㅰ: 1, - ㅱ: 1, - ㅲ: 1, - ㅳ: 1, - ㅴ: 1, - ㅵ: 1, - ㅶ: 1, - ㅷ: 1, - }; - const complexList = Object.assign({}, complex, irregularComplex); - // yes, I know that this is not a list. - const stronger = { - ㄱ: 'ㄲ', - ㅋ: 'ㄲ', - ㄷ: 'ㄸ', - ㅌ: 'ㄸ', - ㅂ: 'ㅃ', - ㅍ: 'ㅃ', - ㅅ: 'ㅆ', - ㅈ: 'ㅉ', - ㅊ: 'ㅉ', - }; - // I would add a weaker export - // except that I can't reverse the outputs - - const cho$1 = [ - 'ㄱ', 'ㄲ', 'ㄴ', 'ㄷ', 'ㄸ', 'ㄹ', 'ㅁ', - 'ㅂ', 'ㅃ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅉ', - 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ', - ]; - const jung$1 = [ - 'ㅏ', 'ㅐ', 'ㅑ', 'ㅒ', 'ㅓ', 'ㅔ', 'ㅕ', - 'ㅖ', 'ㅗ', 'ㅘ', 'ㅙ', 'ㅚ', 'ㅛ', 'ㅜ', - 'ㅝ', 'ㅞ', 'ㅟ', 'ㅠ', 'ㅡ', 'ㅢ', 'ㅣ', - ]; - const jong$1 = [ - null, 'ㄱ', 'ㄲ', 'ㄳ', 'ㄴ', 'ㄵ', 'ㄶ', - 'ㄷ', 'ㄹ', 'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', - 'ㄿ', 'ㅀ', 'ㅁ', 'ㅂ', 'ㅄ', 'ㅅ', 'ㅆ', - 'ㅇ', 'ㅈ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ', - ]; - const choNum = { - ㄱ: 0, - ㄲ: 1, - ㄴ: 2, - ㄷ: 3, - ㄸ: 4, - ㄹ: 5, - ㅁ: 6, - ㅂ: 7, - ㅃ: 8, - ㅅ: 9, - ㅆ: 10, - ㅇ: 11, - ㅈ: 12, - ㅉ: 13, - ㅊ: 14, - ㅋ: 15, - ㅌ: 16, - ㅍ: 17, - ㅎ: 18, - }; - const jungNum = { - ㅏ: 0, - ㅐ: 1, - ㅑ: 2, - ㅒ: 3, - ㅓ: 4, - ㅔ: 5, - ㅕ: 6, - ㅖ: 7, - ㅗ: 8, - ㅘ: 9, - ㅙ: 10, - ㅚ: 11, - ㅛ: 12, - ㅜ: 13, - ㅝ: 14, - ㅞ: 15, - ㅟ: 16, - ㅠ: 17, - ㅡ: 18, - ㅢ: 19, - ㅣ: 20, - }; - const jongNum = { - ㄱ: 1, - ㄲ: 2, - ㄳ: 3, - ㄴ: 4, - ㄵ: 5, - ㄶ: 6, - ㄷ: 7, - ㄹ: 8, - ㄺ: 9, - ㄻ: 10, - ㄼ: 11, - ㄽ: 12, - ㄾ: 13, - ㄿ: 14, - ㅀ: 15, - ㅁ: 16, - ㅂ: 17, - ㅄ: 18, - ㅅ: 19, - ㅆ: 20, - ㅇ: 21, - ㅈ: 22, - ㅊ: 23, - ㅋ: 24, - ㅌ: 25, - ㅍ: 26, - ㅎ: 27, - }; - - class UnicodeRange { - constructor(start, end) { - this.start = start; - this.end = end; - } - - containsCodePoint(num) { - return num >= this.start && num <= this.end; - } - - contains(char) { - return this.containsCodePoint(char.codePointAt(0)); - } - } - class CombinedRange { - constructor(ranges, codePoints = {}) { - this.ranges = ranges; - this.codePoints = codePoints; - } - - containsCodePoint(num) { - return ( - (this.codePoints && this.codePoints[num]) - || this.ranges.some(range => range.containsCodePoint(num)) - ); - } - - contains(char) { - const num = char.codePointAt(0); - return this.containsCodePoint(num); - } - } - - const jamo = new UnicodeRange(0x1100, 0x11FF); - const compatibilityJamo = new UnicodeRange(0x3130, 0x318F); - const jamoExtendedA = new UnicodeRange(0xA960, 0xA97F); - const syllables = new UnicodeRange(0xAC00, 0xD7AF); - const jamoExtendedB = new UnicodeRange(0xD7B0, 0xD7FF); - const halfwidth = new UnicodeRange(0xFFA0, 0xFFDF); - const reserved = new CombinedRange([ - new UnicodeRange(0xA97D, 0xA97F), // jamoExtendedA - new UnicodeRange(0xD7A4, 0xD7AF), // syllables - new UnicodeRange(0xD7C7, 0xD7CA), // jamoExtendedB - new UnicodeRange(0xD7FC, 0xD7FF), // jamoExtendedB - ], { 0x3130: 1, 0x318F: 1 }); - const standardHangul = new CombinedRange([compatibilityJamo, syllables]); - const hangul = new CombinedRange([ - jamo, - compatibilityJamo, - jamoExtendedA, - syllables, - jamoExtendedB, - halfwidth, - reserved, - ]); - - var composeSyllable = ((cho, jung, jong = 0) => ( - String.fromCodePoint(cho * 588 + jung * 28 + jong + syllables.start) - // this is the actual function that makes unicode syllable characters - // where the characters are mapped to numbers. Take a look at - // { choNum, jungNum, jongNum } from './unicode/syllable' - )); - - class Result { - constructor(result = '', remainder = []) { - this.result = result; - this.remainder = remainder; - } - } - - const Character = (val) => { - const str = `${val}`; - // not using .toString because Symbol.toPrimitive overrides when present - if (str.length !== 1) { - throw Error(`"${str}" is not a Character!`); - } - return str; - }; - // this function turns values into characters if it can - // otherwise it just fails - const ENOARYLIKE = () => { throw TypeError('The data must be an Array or a String!'); }; - const toArray = aryOrStr => (Array.isArray(aryOrStr) ? aryOrStr : aryOrStr.split('')); - // as a general note, calling .split like that instead of .split`` is faster - const isCharacterGroup = (val) => { - if (val.length < 1) { - return false; - } if (Array.isArray(val)) { - if (val.length > 1) { - return true; - } - return isCharacterGroup(val[0]); - } if (typeof val === 'string' && val.length > 1) { - return true; - } - return false; - }; - // while Characters can be a CharacterGroup, - // this function ignores characters - const identity = i => i; - const deepMap = (data, func, useToArray) => { - const modifier = useToArray ? toArray : identity; - if (Array.isArray(data)) { - return data.map(val => (isCharacterGroup(val) ? deepMap(val, func, useToArray) : modifier(func(val)))); - } if (typeof data === 'string') { - // since the data was a string, the array created from - // the string won't contain any character groups - return data.split('').map(char => modifier(func(char))); - } - ENOARYLIKE(); - }; - const deepFlatMap = (data, func) => { - let res = ''; - if (Array.isArray(data)) { - const len = data.length; - for (let i = 0; i < len; i++) { - // for is faster than forEach - // this function is used a lot so I'll - // take any optimization that I can get - const val = data[i]; - if (isCharacterGroup(val)) { - res += deepFlatMap(val, func); - } else { - const recurseRes = func(val); - if (isCharacterGroup(recurseRes)) { - res += deepFlatMap(recurseRes, identity); - } else { - res += recurseRes; - } - } - } - } else if (typeof data === 'string') { - const len = data.length; - for (let i = 0; i < len; i++) { - const recurseRes = func(data[i]); - if (isCharacterGroup(recurseRes)) { - res += deepFlatMap(recurseRes, identity); - } else { - res += recurseRes; - } - } - } else { - ENOARYLIKE(); - } - return res; - }; - const flatten = (data) => { - if (Array.isArray(data)) { - let res = ''; - const len = data.length; - for (let i = 0; i < len; i++) { - const val = data[i]; - if (isCharacterGroup(val)) { - res += flatten(val); - } else { - res += val; - } - } - return res; - } if (typeof data === 'string') { - return data; - } - ENOARYLIKE(); - }; - const deepFlatResMap = (data, func) => { - // this is different since it deals with functions that return Result objects. - // consumeLeftovers - let rem; - // remaining - let res = ''; - // result - if (Array.isArray(data)) { - rem = []; - const len = data.length; - for (let i = 0; i < len; i++) { - const val = data[i]; - if (isCharacterGroup(val)) { - rem.push(...deepFlatResMap(val, func)); - // deepFlatResMap always returns an array - // (or at least it should) - } else { - rem.push(val); - } - } - } else if (typeof data === 'string') { - rem = data.split(''); - // could have used toArray but since we already know - // the type of this, there's no need to - } else { - // it's not an Array or a String - ENOARYLIKE(); - } - while (rem.length) { - const comp = func(rem); - // func needs to return a Result like interface for this to work - // otherwise we'll get a really nasty to debug error - res += comp.result; - rem = comp.remainder; - } - return res; - }; - - // important note! - // these functions aren't going to really make any sense until - // you understand how they work in conjunction with the stuff - // that's in './types'. Read './Result' and './types' first. - // then read this. - const objCache = []; - const useComp3 = 0b001; - const useArchaic = 0b010; - const noUseJungJong = 0b100; - const noCompDouble = 0b1000; - const composeComplexBase = (mode) => { - // mode is being used as a bitfield - if (mode < 0 || mode > 8) { - throw Error('The mode cannot be less than zero or greater than eight!'); - } - const usingArchaic = mode & useArchaic; - const usingComp3 = usingArchaic && mode & useComp3; - const usingNoCompDouble = mode & noCompDouble; - let obj = objCache[mode]; - if (!obj) { - const objs = [cho]; - // there are no comp3 values in non archaic complex objects - if (!(mode & noUseJungJong)) { - // if you're usingJungJong - objs.push(jung, jong); - } if (usingArchaic) { - objs.push(archaic); - } - obj = Object.assign({}, ...objs); - objCache[mode] = obj; - // eslint got mad at me for chaining assignments - } - return (chars) => { - const len = chars.length; - if (len < 1) { - throw Error('Cannot compose array of zero characters!'); - } - const char1 = chars[0]; - if (len < 2) { - // if there aren't even two Characters to use - return new Result(char1); - } - const char2 = chars[1]; - if (usingNoCompDouble && char1 === char2) { - return new Result(char1, chars.slice(1)); - } - const comp2 = obj[char1 + char2]; - // comp2 = composition of 2 characters - if (comp2) { - if (usingComp3 && len > 2) { - // if there's more data, try to compose a tripple - const comp3 = obj[char1 + char2 + chars[2]]; - if (comp3) { - return new Result(comp3, chars.slice(3)); - } - } - // there's no more data or couldn't find a comp3 - return new Result(comp2, chars.slice(2)); - } - // couldn't find a comp2 - return new Result(char1, chars.slice(1)); - }; - }; - const composeComplex = (mode) => { - const cc = composeComplexBase(mode); - return ary => deepFlatResMap(ary, cc); - }; - const isVowel = char => char && char !== 'ㆍ' && vowels[char]; - var composeAnything = ((mode) => { - const cc = composeComplexBase(mode); - return (ary) => { - // while this function is named "composeSyllable", it actually - // can be used to compose anything, really. - if (ary.length < 2) { - return new Result(ary[0]); - // don't do extra computing for small operations - } - // the composeComplex function with the mode that is specified - const choRes = cc(ary); - // ^^ that's a Result object - const choChar = choRes.result; - // the result of the composition, should be a Character - const choRem = choRes.remainder; - // the remainder of the composition - const cho$$1 = choNum[choChar]; - // the number that the character is mapped to - if (choRem.length < 1 || !Number.isInteger(cho$$1)) { - // check if there's any more characters remaining - // also check if it's not an integer since 0 == false - // if it's not an integer, then return the potential - // complex or Character that was made from composeAnyComplex - return choRes; - // choRes is already a Result so no need to make another - } - const jungRes = cc(choRem); - - const jungChar = jungRes.result; - const jungRem = jungRes.remainder; - const jung$$1 = jungNum[jungChar]; - if (!Number.isInteger(jung$$1)) { - // there's no need to check to see if there's any more - // remaining since cho and jung are all that's needed - // to compose a syllable - return new Result(choChar, [jungChar, ...jungRem]); - // still only return choChar as a result since we want - // to try starting a syllable off with the jungChar next - // time this function is called - } if (jungRem.length) { - // there's no point in trying to add anything on to the complex - // if there aren't any characters left - if (!isVowel(jungRem[1])) { - // we need this part so that - // ㅁㅣㅇㅏ => 미아 - const jongRes = cc(jungRem); - - const jongChar = jongRes.result; - const jongRem = jongRes.remainder; - const jong$$1 = jongNum[jongChar]; - if (jong$$1) { - // if the character after the syllable is not a vowel - // and the jong character is valid - return new Result(composeSyllable(cho$$1, jung$$1, jong$$1), jongRem); - } - } - } - // there aren't any characters left - // or the character after the syllable is a vowel - // or the jong character isn't valid - return new Result(composeSyllable(cho$$1, jung$$1), jungRem); - // The last argument is optional for the Result constructor - }; - }); - - // if you're gonna copy this part, at least give me credit. - // I had to do all of this manually. - // also, I think turning all of these arrays into strings - // might speed up composition by a bit. - const jamo$1 = { - ᄀ: 'ㄱ', - ᄁ: ['ㄱ', 'ㄱ'], - ᄂ: 'ㄴ', - ᄃ: 'ㄷ', - ᄄ: ['ㄷ', 'ㄷ'], - ᄅ: 'ㄹ', - ᄆ: 'ㅁ', - ᄇ: 'ㅂ', - ᄈ: ['ㅂ', 'ㅂ'], - ᄉ: 'ㅅ', - ᄊ: ['ㅅ', 'ㅅ'], - ᄋ: 'ㅇ', - ᄌ: 'ㅈ', - ᄍ: ['ㅈ', 'ㅈ'], - ᄎ: 'ㅊ', - ᄏ: 'ㅋ', - ᄐ: 'ㅌ', - ᄑ: 'ㅍ', - ᄒ: 'ㅎ', - ᄓ: ['ㄴ', 'ㄱ'], - ᄔ: ['ㄴ', 'ㄴ'], - ᄕ: ['ㄴ', 'ㄷ'], - ᄖ: ['ㄴ', 'ㅂ'], - ᄗ: ['ㄷ', 'ㄱ'], - ᄘ: ['ㄹ', 'ㄴ'], - ᄙ: ['ㄹ', 'ㄹ'], - ᄚ: ['ㄹ', 'ㅎ'], - ᄛ: ['ㄹ', 'ㅇ'], - ᄜ: ['ㅁ', 'ㅂ'], - ᄝ: 'ㅱ', - ᄞ: ['ㅂ', 'ㄱ'], - ᄟ: ['ㅂ', 'ㄴ'], - ᄠ: ['ㅂ', 'ㄷ'], - ᄡ: ['ㅂ', 'ㅅ'], - ᄢ: ['ㅂ', 'ㅅ', 'ㄱ'], - ᄣ: ['ㅂ', 'ㅅ', 'ㄷ'], - ᄤ: ['ㅂ', 'ㅅ', 'ㅂ'], - ᄥ: ['ㅂ', 'ㅅ', 'ㅅ'], - ᄦ: ['ㅂ', 'ㅅ', 'ㅈ'], - ᄧ: ['ㅂ', 'ㅈ'], - ᄨ: ['ㅂ', 'ㅊ'], - ᄩ: ['ㅂ', 'ㅌ'], - ᄪ: ['ㅂ', 'ㅍ'], - ᄫ: ['ㅂ', 'ㅇ'], - ᄬ: [['ㅂ', 'ㅂ'], 'ㅇ'], - ᄭ: ['ㅅ', 'ㄱ'], - ᄮ: ['ㅅ', 'ㄴ'], - ᄯ: ['ㅅ', 'ㄷ'], - ᄰ: ['ㅅ', 'ㄹ'], - ᄱ: ['ㅅ', 'ㅁ'], - ᄲ: ['ㅅ', 'ㅂ'], - ᄳ: ['ㅅ', 'ㅂ', 'ㄱ'], - ᄴ: ['ㅅ', 'ㅅ', 'ㅅ'], - ᄵ: ['ㅅ', 'ㅇ'], - ᄶ: ['ㅅ', 'ㅈ'], - ᄷ: ['ㅅ', 'ㅊ'], - ᄸ: ['ㅅ', 'ㅋ'], - ᄹ: ['ㅅ', 'ㅌ'], - ᄺ: ['ㅅ', 'ㅍ'], - ᄻ: ['ㅅ', 'ㅎ'], - ᄼ: null, - ᄽ: null, - ᄾ: null, - ᄿ: null, - ᅀ: 'ㅿ', - ᅁ: ['ㅇ', 'ㄱ'], - ᅂ: ['ㅇ', 'ㄷ'], - ᅃ: ['ㅇ', 'ㅁ'], - ᅄ: ['ㅇ', 'ㅂ'], - ᅅ: ['ㅇ', 'ㅅ'], - ᅆ: ['ㅇ', 'ㅿ'], - ᅇ: ['ㅇ', 'ㅇ'], - ᅈ: ['ㅇ', 'ㅈ'], - ᅉ: ['ㅇ', 'ㅊ'], - ᅊ: ['ㅇ', 'ㅌ'], - ᅋ: ['ㅇ', 'ㅍ'], - ᅌ: 'ㆁ', - ᅍ: ['ㅈ', 'ㅇ'], - ᅎ: null, - ᅏ: null, - ᅐ: null, - ᅑ: null, - ᅒ: ['ㅊ', 'ㅋ'], - ᅓ: ['ㅊ', 'ㅎ'], - ᅔ: null, - ᅕ: null, - ᅖ: ['ㅍ', 'ㅂ'], - ᅗ: 'ㆄ', - ᅘ: ['ㅎ', 'ㅎ'], - ᅙ: 'ㆆ', - ᅚ: ['ㄱ', 'ㄷ'], - ᅛ: ['ㄱ', 'ㅅ'], - ᅜ: ['ㄱ', 'ㅈ'], - ᅝ: ['ㄱ', 'ㅎ'], - ᅞ: ['ㄷ', 'ㄹ'], - ᅡ: 'ㅏ', - ᅢ: 'ㅐ', - ᅣ: 'ㅑ', - ᅤ: 'ㅒ', - ᅥ: 'ㅓ', - ᅦ: 'ㅔ', - ᅧ: 'ㅕ', - ᅨ: 'ㅖ', - ᅩ: 'ㅗ', - ᅪ: ['ㅗ', 'ㅏ'], - ᅫ: ['ㅗ', 'ㅐ'], - ᅬ: ['ㅗ', 'ㅣ'], - ᅭ: 'ㅛ', - ᅮ: 'ㅜ', - ᅯ: ['ㅜ', 'ㅓ'], - ᅰ: ['ㅜ', 'ㅔ'], - ᅱ: ['ㅜ', 'ㅣ'], - ᅲ: 'ㅠ', - ᅳ: 'ㅡ', - ᅴ: ['ㅡ', 'ㅣ'], - ᅵ: 'ㅣ', - ᅶ: ['ㅏ', 'ㅗ'], - ᅷ: ['ㅏ', 'ㅜ'], - ᅸ: ['ㅑ', 'ㅗ'], - ᅹ: ['ㅑ', 'ㅛ'], - ᅺ: ['ㅓ', 'ㅗ'], - ᅻ: ['ㅓ', 'ㅜ'], - ᅼ: ['ㅓ', 'ㅡ'], - ᅽ: ['ㅕ', 'ㅗ'], - ᅾ: ['ㅕ', 'ㅜ'], - ᅿ: ['ㅗ', 'ㅓ'], - ᆀ: ['ㅔ', 'ㅗ'], - ᆁ: ['ㅖ', 'ㅗ'], - ᆂ: ['ㅗ', 'ㅗ'], - ᆃ: ['ㅗ', 'ㅜ'], - ᆄ: ['ㅛ', 'ㅑ'], - ᆅ: ['ㅛ', 'ㅒ'], - ᆆ: ['ㅛ', 'ㅕ'], - ᆇ: ['ㅛ', 'ㅗ'], - ᆈ: ['ㅛ', 'ㅣ'], - ᆉ: ['ㅜ', 'ㅏ'], - ᆊ: ['ㅜ', 'ㅐ'], - ᆋ: ['ㅜ', 'ㅓ', 'ㅡ'], - ᆌ: ['ㅜ', 'ㅖ'], - ᆍ: ['ㅜ', 'ㅜ'], - ᆎ: ['ㅠ', 'ㅏ'], - ᆏ: ['ㅠ', 'ㅓ'], - ᆐ: ['ㅠ', 'ㅔ'], - ᆑ: ['ㅠ', 'ㅕ'], - ᆒ: ['ㅠ', 'ㅔ'], - ᆓ: ['ㅠ', 'ㅜ'], - ᆔ: ['ㅠ', 'ㅣ'], - ᆕ: ['ㅡ', 'ㅜ'], - ᆖ: ['ㅡ', 'ㅡ'], - ᆗ: ['ㅡ', 'ㅣ', 'ㅜ'], - ᆘ: ['ㅣ', 'ㅏ'], - ᆙ: ['ㅣ', 'ㅑ'], - ᆚ: ['ㅣ', 'ㅗ'], - ᆛ: ['ㅣ', 'ㅜ'], - ᆜ: ['ㅣ', 'ㅡ'], - ᆝ: null, - ᆞ: 'ㆍ', - ᆟ: ['ㆍ', 'ㅓ'], - ᆠ: ['ㆍ', 'ㅜ'], - ᆡ: ['ㆍ', 'ㅣ'], - ᆢ: ['ㆍ', 'ㆍ'], - ᆣ: ['ㅏ', 'ㅡ'], - ᆤ: ['ㅑ', 'ㅜ'], - ᆥ: ['ㅕ', 'ㅑ'], - ᆦ: ['ㅗ', 'ㅑ'], - ᆧ: ['ㅗ', 'ㅒ'], - ᆨ: 'ㄱ', - ᆩ: ['ㄱ', 'ㄱ'], - ᆪ: ['ㄱ', 'ㅅ'], - ᆫ: 'ㄴ', - ᆬ: ['ㄴ', 'ㅈ'], - ᆭ: ['ㄴ', 'ㅎ'], - ᆮ: 'ㄷ', - ᆯ: 'ㄹ', - ᆰ: ['ㄹ', 'ㄱ'], - ᆱ: ['ㄹ', 'ㅁ'], - ᆲ: ['ㄹ', 'ㅂ'], - ᆳ: ['ㄹ', 'ㅅ'], - ᆴ: ['ㄹ', 'ㅌ'], - ᆵ: ['ㄹ', 'ㅍ'], - ᆶ: ['ㄹ', 'ㅎ'], - ᆷ: 'ㅁ', - ᆸ: 'ㅂ', - ᆹ: ['ㅂ', 'ㅅ'], - ᆺ: 'ㅅ', - ᆻ: ['ㅅ', 'ㅅ'], - ᆼ: 'ㅇ', - ᆽ: 'ㅈ', - ᆾ: 'ㅊ', - ᆿ: 'ㅋ', - ᇀ: 'ㅌ', - ᇁ: 'ㅍ', - ᇂ: 'ㅎ', - ᇃ: ['ㄱ', 'ㄹ'], - ᇄ: ['ㄱ', 'ㅅ', 'ㄱ'], - ᇅ: ['ㄴ', 'ㄱ'], - ᇆ: ['ㄴ', 'ㄷ'], - ᇇ: ['ㄴ', 'ㅅ'], - ᇈ: ['ㄴ', 'ㅿ'], - ᇉ: ['ㄴ', 'ㅌ'], - ᇊ: ['ㄷ', 'ㄱ'], - ᇋ: ['ㄷ', 'ㄹ'], - ᇌ: ['ㄹ', 'ㄱ', 'ㅅ'], - ᇍ: ['ㄹ', 'ㄴ'], - ᇎ: ['ㄹ', 'ㄷ'], - ᇏ: ['ㄹ', 'ㄷ', 'ㅎ'], - ᇐ: ['ㄹ', 'ㄹ'], - ᇑ: ['ㄹ', 'ㅁ', 'ㄱ'], - ᇒ: ['ㄹ', 'ㅁ', 'ㅅ'], - ᇓ: ['ㄹ', 'ㅂ', 'ㅅ'], - ᇔ: ['ㄹ', 'ㅂ', 'ㅎ'], - ᇕ: ['ㄹ', 'ㅸ'], - ᇖ: ['ㄹ', 'ㅅ', 'ㅅ'], - ᇗ: ['ㄹ', 'ㅿ'], - ᇘ: ['ㄹ', 'ㅋ'], - ᇙ: ['ㄹ', 'ㆆ'], - ᇚ: ['ㅁ', 'ㄱ'], - ᇛ: ['ㅁ', 'ㄹ'], - ᇜ: ['ㅁ', 'ㅂ'], - ᇝ: ['ㅁ', 'ㅅ'], - ᇞ: ['ㅁ', 'ㅅ', 'ㅅ'], - ᇟ: ['ㅁ', 'ㅿ'], - ᇠ: ['ㅁ', 'ㅊ'], - ᇡ: ['ㅁ', 'ㅎ'], - ᇢ: 'ㅱ', - ᇣ: ['ㅂ', 'ㄹ'], - ᇤ: ['ㅂ', 'ㅍ'], - ᇥ: ['ㅂ', 'ㅎ'], - ᇦ: ['ㅂ', 'ㅇ'], - ᇧ: ['ㅅ', 'ㄱ'], - ᇨ: ['ㅅ', 'ㄷ'], - ᇩ: ['ㅅ', 'ㄹ'], - ᇪ: ['ㅅ', 'ㅂ'], - ᇫ: 'ㅿ', - ᇬ: ['ㆁ', 'ㄱ'], - ᇭ: ['ㆁ', 'ㄱ', 'ㄱ'], - ᇮ: ['ㆁ', 'ㆁ'], - ᇯ: ['ㆁ', 'ㅋ'], - ᇰ: 'ㆁ', - ᇱ: ['ㆁ', 'ㅅ'], - ᇲ: ['ㆁ', 'ㅿ'], - ᇳ: ['ㅍ', 'ㅂ'], - ᇴ: 'ㆄ', - ᇵ: ['ㅎ', 'ㄴ'], - ᇶ: ['ㅎ', 'ㄹ'], - ᇷ: ['ㅎ', 'ㅁ'], - ᇸ: ['ㅎ', 'ㅂ'], - ᇹ: 'ㆆ', - ᇺ: ['ㄱ', 'ㄴ'], - ᇻ: ['ㄱ', 'ㅂ'], - ᇼ: ['ㄱ', 'ㅊ'], - ᇽ: ['ㄱ', 'ㅋ'], - ᇾ: ['ㄱ', 'ㅎ'], - ᇿ: ['ㄴ', 'ㄴ'], - }; - const jamoExtendedA$1 = { - ꥠ: ['ㄷ', 'ㅁ'], - ꥡ: ['ㄷ', 'ㅂ'], - ꥢ: ['ㄷ', 'ㅅ'], - ꥣ: ['ㄷ', 'ㅈ'], - ꥤ: ['ㄹ', 'ㄱ'], - ꥥ: ['ㄹ', 'ㄱ', 'ㄱ'], - ꥦ: ['ㄹ', 'ㄷ'], - ꥧ: ['ㄹ', 'ㄷ', 'ㄷ'], - ꥨ: ['ㄹ', 'ㅁ'], - ꥩ: ['ㄹ', 'ㅂ'], - ꥪ: ['ㄹ', 'ㅂ', 'ㅂ'], - ꥫ: ['ㄹ', 'ㅸ'], - ꥬ: ['ㄹ', 'ㅅ'], - ꥭ: ['ㄹ', 'ㅈ'], - ꥮ: ['ㄹ', 'ㅋ'], - ꥯ: ['ㅁ', 'ㄱ'], - ꥰ: ['ㅁ', 'ㄷ'], - ꥱ: ['ㅁ', 'ㅅ'], - ꥲ: ['ㅂ', 'ㅅ', 'ㅌ'], - ꥳ: ['ㅂ', 'ㅋ'], - ꥴ: ['ㅂ', 'ㅎ'], - ꥵ: ['ㅅ', 'ㅅ', 'ㅂ'], - ꥶ: ['ㅇ', 'ㄹ'], - ꥷ: ['ㅇ', 'ㅎ'], - ꥸ: ['ㅈ', 'ㅈ', 'ㅎ'], - ꥹ: ['ㅌ', 'ㅌ'], - ꥺ: ['ㅍ', 'ㅎ'], - ꥻ: ['ㅎ', 'ㅅ'], - ꥼ: ['ㆆ', 'ㆆ'], - }; - const jamoExtendedB$1 = { - ힰ: ['ㅗ', 'ㅕ'], - ힱ: ['ㅗ', 'ㅗ', 'ㅣ'], - ힲ: ['ㅛ', 'ㅏ'], - ힳ: ['ㅛ', 'ㅐ'], - ힴ: ['ㅛ', 'ㅓ'], - ힵ: ['ㅜ', 'ㅕ'], - ힶ: ['ㅜ', 'ㅣ', 'ㅣ'], - ힷ: ['ㅠ', 'ㅐ'], - ힸ: ['ㅠ', 'ㅗ'], - ힹ: ['ㅡ', 'ㅏ'], - ힺ: ['ㅡ', 'ㅓ'], - ힻ: ['ㅡ', 'ㅔ'], - ힼ: ['ㅡ', 'ㅗ'], - ힽ: ['ㅣ', 'ㅏ', 'ㅗ'], - ힾ: ['ㅣ', 'ㅒ'], - ힿ: ['ㅣ', 'ㅕ'], - ퟀ: ['ㅣ', 'ㅖ'], - ퟁ: ['ㅣ', 'ㅗ', 'ㅣ'], - ퟂ: ['ㅣ', 'ㅛ'], - ퟃ: ['ㅣ', 'ㅠ'], - ퟄ: ['ㅣ', 'ㅣ'], - ퟅ: ['ㆍ', 'ㅏ'], - ퟆ: ['ㆍ', 'ㅔ'], - ퟋ: ['ㄴ', 'ㄹ'], - ퟌ: ['ㄴ', 'ㅈ'], - ퟍ: ['ㄷ', 'ㄷ'], - ퟎ: ['ㄷ', 'ㄷ', 'ㅂ'], - ퟏ: ['ㄷ', 'ㅂ'], - ퟐ: ['ㄷ', 'ㅅ'], - ퟑ: ['ㄷ', 'ㅅ', 'ㄱ'], - ퟒ: ['ㄷ', 'ㅈ'], - ퟓ: ['ㄷ', 'ㅊ'], - ퟔ: ['ㄷ', 'ㅌ'], - ퟕ: ['ㄹ', 'ㄱ', 'ㄱ'], - ퟖ: ['ㄹ', 'ㄱ', 'ㅎ'], - ퟗ: ['ㄹ', 'ㄹ', 'ㅋ'], - ퟘ: ['ㄹ', 'ㅁ', 'ㅎ'], - ퟙ: ['ㄹ', 'ㅂ', 'ㄷ'], - ퟚ: ['ㄹ', 'ㅂ', 'ㅍ'], - ퟛ: ['ㄹ', 'ㆁ'], - ퟜ: ['ㄹ', 'ㆆ', 'ㅎ'], - ퟝ: null, - ퟞ: ['ㅁ', 'ㄴ'], - ퟟ: ['ㅁ', 'ㄴ', 'ㄴ'], - ퟠ: ['ㅁ', 'ㅁ'], - ퟡ: ['ㅁ', 'ㅂ', 'ㅅ'], - ퟢ: ['ㅁ', 'ㅈ'], - ퟣ: ['ㅂ', 'ㄷ'], - ퟤ: ['ㅂ', 'ㄹ', 'ㅍ'], - ퟥ: ['ㅂ', 'ㅁ'], - ퟦ: ['ㅂ', 'ㅂ'], - ퟧ: ['ㅂ', 'ㅅ', 'ㄷ'], - ퟨ: ['ㅂ', 'ㅈ'], - ퟩ: ['ㅂ', 'ㅊ'], - ퟪ: ['ㅅ', 'ㅁ'], - ퟫ: ['ㅅ', 'ㅸ'], - ퟬ: ['ㅅ', 'ㅅ', 'ㄱ'], - ퟭ: ['ㅅ', 'ㅅ', 'ㄷ'], - ퟮ: ['ㅅ', 'ㅿ'], - ퟯ: ['ㅅ', 'ㅈ'], - ퟰ: ['ㅅ', 'ㅊ'], - ퟱ: ['ㅅ', 'ㅌ'], - ퟲ: ['ㅅ', 'ㅎ'], - ퟳ: ['ㅿ', 'ㅂ'], - ퟴ: ['ㅿ', 'ㅸ'], - ퟵ: ['ㆁ', 'ㅁ'], - ퟶ: ['ㆁ', 'ㅎ'], - ퟷ: ['ㅈ', 'ㅂ'], - ퟸ: ['ㅈ', 'ㅂ', 'ㅂ'], - ퟹ: ['ㅈ', 'ㅈ'], - ퟺ: ['ㅍ', 'ㅅ'], - ퟻ: ['ㅍ', 'ㅌ'], - }; - const halfwidth$1 = { - ᄀ: 'ㄱ', - ᄁ: ['ㄱ', 'ㄱ'], - ᆪ: ['ㄱ', 'ㅅ'], - ᄂ: 'ㄴ', - ᆬ: ['ㄴ', 'ㅈ'], - ᆭ: ['ㄴ', 'ㅎ'], - ᄃ: 'ㄷ', - ᄄ: ['ㄷ', 'ㄷ'], - ᄅ: 'ㄹ', - ᆰ: ['ㄹ', 'ㄱ'], - ᆱ: ['ㄹ', 'ㅁ'], - ᆲ: ['ㄹ', 'ㅂ'], - ᆳ: ['ㄹ', 'ㅅ'], - ᆴ: ['ㄹ', 'ㅌ'], - ᆵ: ['ㄹ', 'ㅍ'], - ᄚ: ['ㄹ', 'ㅎ'], - ᄆ: 'ㅁ', - ᄇ: 'ㅂ', - ᄈ: ['ㅂ', 'ㅂ'], - ᄡ: ['ㅂ', 'ㅅ'], - ᄉ: 'ㅅ', - ᄊ: ['ㅅ', 'ㅅ'], - ᄋ: 'ㅇ', - ᄌ: 'ㅈ', - ᄍ: ['ㅈ', 'ㅈ'], - ᄎ: 'ㅊ', - ᄏ: 'ㅋ', - ᄐ: 'ㅌ', - ᄑ: 'ㅍ', - ᄒ: 'ㅎ', - ᅡ: 'ㅏ', - ᅢ: 'ㅐ', - ᅣ: 'ㅑ', - ᅤ: 'ㅒ', - ᅥ: 'ㅓ', - ᅦ: 'ㅔ', - ᅧ: 'ㅕ', - ᅨ: 'ㅖ', - ᅩ: 'ㅗ', - ᅪ: ['ㅗ', 'ㅏ'], - ᅫ: ['ㅗ', 'ㅐ'], - ᅬ: ['ㅗ', 'ㅣ'], - ᅭ: 'ㅛ', - ᅮ: 'ㅜ', - ᅯ: ['ㅜ', 'ㅓ'], - ᅰ: ['ㅜ', 'ㅔ'], - ᅱ: ['ㅜ', 'ㅣ'], - ᅲ: 'ㅠ', - ᅳ: 'ㅡ', - ᅴ: ['ㅡ', 'ㅣ'], - ᅵ: 'ㅣ', - }; - const all = Object.assign({}, jamo$1, jamoExtendedA$1, jamoExtendedB$1, halfwidth$1); - - // tries to transform everything into disassembled standard hangul - - const transformChar = char => (!standardHangul.contains(char) && all[char]) || char; - const transformDatum = datum => transformChar(Character(datum)); - const transformEveryChar = char => ( - (standardHangul.contains(char) ? pairs : all)[char] - || char - ); - const transformEveryDatum = datum => transformEveryChar(Character(datum)); - // transform everything just means that it also transforms - // standard hangul characters instead of ignoring them - - // this way, we can trust the inputs to composeAnything - const assembleFactory = transformer => (data, mode) => deepFlatResMap(transformer(data), composeAnything(mode)); - // the transformer should verify that each datum is a Character! - const assembleTransformer = data => deepMap(data, transformEveryDatum); - // this takes a CharacterGroup and transforms characters and - // complex characters, effectively leaving behind only the - // base Characters - // it doesn't decomposeSyllables though - var assemble = (assembleFactory(assembleTransformer)); - - const composeComplexCho = composeComplex(noUseJungJong); - const transformExceptCho = (char) => { - const res = transformEveryChar(char); - if (Array.isArray(res)) { - const comp = composeComplexCho(res); - // the default composeComplex only composes cho - // HACK: this bug might be an issue with composeComplex - if (Array.isArray(comp) && comp.length === 1) { - // if the composition actually ends up composing - // something and it's only one Character, just - // return the Character instead of an Array - return Character(comp); - } - return comp; - } - return res; - }; - // this function is needed by disassemble so it's trusting - var decomposeComplex = ((datum, decomposeDoubles) => toArray((decomposeDoubles ? transformEveryChar : transformExceptCho)(Character(datum)))); - - const trustMe = (char) => { - const code = char.codePointAt(0) - syllables.start; - const jongNum$$1 = code % 28; - const q = (code - jongNum$$1) / 28; - const jungNum$$1 = q % 21; - const choNum$$1 = 0 | q / 21; // basically Math.floor(q / 21) - return [cho$1[choNum$$1], jung$1[jungNum$$1], jong$1[jongNum$$1]].filter(v => v); - // the .filter(v => v) removes blank space in the array - }; - var decomposeSyllable = ((datum, hardFail) => { - const char = Character(datum); - if (!syllables.contains(char)) { - if (hardFail) { - throw Error('Decomposing a syllable requires a syllable to decompose!'); - } - return [datum]; - // if there's no hardFail, the function must - // still return the same type as it would have - // if it didn't fail - } - return trustMe(char); - }); - - const disassembleFactory = transformer => (datum) => { - const char = Character(datum); - if (syllables.contains(char)) { - return trustMe(char).map(transformer); - // that .map(transformEverything) catches the complex - // characters that decomposeSyllable returns - } - // otherwise try breaking complex characters apart - return transformer(char); - }; - const disassembleAll = disassembleFactory(transformEveryChar); - const disassemble = disassembleFactory(transformExceptCho); - // not to be confused with Hangul.disassemble - // this disassemble takes Characters as inputs, not CharacterGroups - const disassembleChar = (datum, grouped, decomposeDoubles) => { - const res = (decomposeDoubles ? disassembleAll : disassemble)(datum); - if (!grouped) { - return flatten(res); - } - return res; - }; - var disassemble$1 = ((data, grouped, decomposeDoubles) => (grouped ? deepMap : deepFlatMap)(data, decomposeDoubles ? disassembleAll : disassemble, true)); - // I know this looks really bad since it's all on - // one line but ESlint was being really finicky - - var name = ((obj) => { - Object.keys(obj).forEach((key) => { - obj[key].displayName = key; - }); - }); - - // This file is only used in ../publicCompose - // all is the only one of these that's actually used - // I can't Object.assign them all together unfortunately - const all$1 = { - ㄱ: { - ㄱ: 'ㄲ', - ㅅ: 'ㄳ', - }, - ㄷ: { - ㄷ: 'ㄸ', - }, - ㅅ: { - ㅅ: 'ㅆ', - ㄱ: 'ㅺ', - ㄴ: 'ㅻ', - ㄷ: 'ㅼ', - ㅂ: 'ㅽ', - ㅈ: 'ㅾ', - }, - ㅈ: { - ㅈ: 'ㅉ', - }, - ㅂ: { - ㅂ: 'ㅃ', - ㅅ: { - $: 'ㅄ', - ㄱ: 'ㅴ', - ㄷ: 'ㅵ', - }, - ㄱ: 'ㅲ', - ㄷ: 'ㅳ', - ㅈ: 'ㅶ', - ㅌ: 'ㅷ', - }, - ㅗ: { - ㅏ: 'ㅘ', - ㅐ: 'ㅙ', - ㅣ: 'ㅚ', - }, - ㅜ: { - ㅓ: 'ㅝ', - ㅔ: 'ㅞ', - ㅣ: 'ㅟ', - }, - ㅡ: { - ㅣ: 'ㅢ', - }, - ㄴ: { - ㅈ: 'ㄵ', - ㅎ: 'ㄶ', - ㄴ: 'ㅥ', - ㄷ: 'ㅦ', - ㅅ: 'ㅧ', - ㅿ: 'ㅨ', - }, - ㄹ: { - ㄱ: { - $: 'ㄺ', - ㅅ: 'ㅩ', - }, - ㅁ: 'ㄻ', - ㅂ: { - $: 'ㄼ', - ㅅ: 'ㅫ', - }, - ㅅ: 'ㄽ', - ㅌ: 'ㄾ', - ㅍ: 'ㄿ', - ㅎ: 'ㅀ', - ㄷ: 'ㅪ', - ㅿ: 'ㅬ', - ㆆ: 'ㅭ', - }, - ㅁ: { - ㅂ: 'ㅮ', - ㅅ: 'ㅯ', - ㅿ: 'ㅰ', - }, - ㅇ: { - ㅇ: 'ㆀ', - }, - ㆁ: { - ㅅ: 'ㆁ', - ㅿ: 'ㅿ', - }, - ㅎ: { - ㅎ: 'ㆅ', - }, - ㅛ: { - ㅑ: 'ㆇ', - ㅒ: 'ㆈ', - ㅣ: 'ㆉ', - }, - ㅠ: { - ㅕ: 'ㆊ', - ㅖ: 'ㆋ', - ㅣ: 'ㆌ', - }, - ㆍ: { - ㅣ: 'ㆎ', - }, - }; - - const standardizeCharacterBase = (mode) => { - const cc = composeComplex(mode); - return (datum) => { - const res = transformDatum(datum); - if (Array.isArray(res)) { - // atempt compose only if the value is an array - // it's unfortunate, but any compFn is untrusting - // since it's basically accessed publicly - // we know that v will always have good types - // but compFn will still check for Characters - return cc(res); - // returns an Array - } - return res; - }; - }; - const standardizeFactory = ((mode) => { - const currentStandardize = standardizeCharacterBase(mode); - return (data, grouped) => (grouped ? deepMap : deepFlatMap)(data, currentStandardize); - }); - var standardize = ((data, grouped, mode) => standardizeFactory(mode)(data, grouped)); - - // since these functions are exposed, the characters must be - // standardized so that the libaray can function properly - const standardizeCharacter = standardizeCharacterBase(useComp3 | useArchaic); - const complex$1 = (first, second, third = '', hardFail) => { - if (first === undefined || second === undefined) { - throw Error('Cannot compose a complex with less than two values!'); - } - const d1 = all$1[standardizeCharacter(first)]; - // depth 1 - if (!d1) { - if (hardFail) { - throw Error(`There's no complex character that starts with ${first}`); - } - return `${first}${second}${third}`; - } - const d2 = d1[standardizeCharacter(second)]; - // depth 2 - if (!d2) { - if (hardFail) { - throw Error(`Cannot combine ${first} and ${second}`); - } - return `${first}${second}${third}`; - } - const d2val = d2.$ || d2; - if (third) { - // if there's a third character (optional) - const d3 = d2[standardizeCharacter(third)]; - // depth 3 - if (!d3) { - // if depth 3 doesn't exist - if (hardFail) { - throw Error(`Found ${d2val} but cannot combine ${first}, ${second}, and ${third}`); - // the reason for this ^^^ is because sometimes - // d2 is a string rather than an object - } - return `${d2val}${third}`; - // at depth three, there should be a complex formed from - // the first and second characters so return that instead - // of the inputs concatenated - } - return d3; // this should always be a string - } - // the third character was falsy so just return the composition - return d2val; - }; - // this function will always return a String or it'll error (hardFail) - // there's probably a better way to structure these if-statements - // so if anyone comes up with one, I'll take it - - const syllable = (choChar, jungChar = '', jongChar = '', hardFail) => { - const cho = choNum[standardizeCharacter(choChar)]; - const jung = jungNum[standardizeCharacter(jungChar)]; - let jong; - if (jongChar) { - jong = jongNum[standardizeCharacter(jongChar)]; - } if (!Number.isInteger(cho)) { - if (hardFail) { - throw Error(`"${choChar}" is not a valid cho Character`); - } - return `${choChar}${jungChar}${jongChar}`; - } if (!Number.isInteger(jung)) { - if (hardFail) { - throw Error(`"${jungChar}" is not a valid jung Character`); - } - return `${choChar}${jungChar}${jongChar}`; - } if (jongChar && !Number.isInteger(jong)) { - // check if it exists because !Number.isInteger(undefined) - // is true and we don't want that happening since jongChar - // is optional - if (hardFail) { - throw Error(`"${jongChar}" is not a valid jong character`); - } - // getting here means that the cho and jung - // characters were valid, so call composeSyllable - return `${composeSyllable(cho, jung)}${jongChar}`; - } - return composeSyllable(cho, jung, jong); - }; - // by nesting all if-statements under if (hardFail) - // there might be a little better performance but I'm - // sure that it's pretty trivial. - - const standardizeComp3Archaic = standardizeFactory(useComp3 | useArchaic); - // support all types of complex - var stronger$1 = (data => standardizeComp3Archaic(data).map(char => stronger[char] || char)); - - const hangulToKeyFn = char => hangulToKey[char] || char; - const keyToHangulFn = char => keyToHangul[char]; - const transformToKeys = (hangulChar) => { - const res = transformExceptCho(hangulChar); - return Array.isArray(res) ? res.map(hangulToKeyFn) : hangulToKeyFn(res); - }; - const disassembleToKeys = disassembleFactory(transformToKeys); - const toKeys = (data, grouped) => (grouped ? deepMap : deepFlatMap)(data, disassembleToKeys); - const transformCharToHangul = (latinDatum) => { - const latinChar = Character(latinDatum); - const res = keyToHangulFn(latinChar); - if (!res) { - // couldn't find a key for that characters - const lowerCaseRes = keyToHangulFn(latinChar.toLowerCase()); - if (!lowerCaseRes) { - return latinChar; - } - return lowerCaseRes; - } - return res; - }; - // it's okay that we're not standarizing because the data - // in hangulToKey is already standard :) - const transformToHangul = data => deepMap(data, transformCharToHangul); - const assembleFromKeys = assembleFactory(transformToHangul); - const fromKeys = data => assembleFromKeys(data, noCompDouble); - - var testMulti = (aryFnName => isFn => data => deepFlatMap(data, transformEveryDatum)[aryFnName](isFn)); - - var contains = (testMulti('some')); - - var is = (isFn => (datum) => { - const res = transformEveryDatum(datum); - // it's okay that we don't check if data is - // a Character since transformEveryCharacter does. - return Array.isArray(res) ? res.every(isFn) : isFn(res); - }); - - var isAll = (testMulti('every')); - - const consonant = char => consonants[char]; - const isConsonant = is(consonant); - const isConsonantAll = isAll(consonant); - const containsConsonant = contains(consonant); - name({ - isConsonant, - isConsonantAll, - containsConsonant, - }); - - const isAll$1 = testFn => (data) => { - const len = data.length; - if (Array.isArray(data)) { - for (let i = 0; i < len; i++) { - const val = data[i]; - if (isCharacterGroup(val) ? isAll$1(testFn)(val) : testFn(val)) { - continue; - } - // the loop will get here if it doesn't satisfy the testing function - return false; - } - return true; - } if (typeof data === 'string') { - for (let i = 0; i < len; i++) { - const val = data[i]; - if (testFn(val)) { - continue; - } - return false; - } - return true; - } - throw TypeError('The data must be an Array or a String!'); - }; - const contains$1 = testFn => (data) => { - const len = data.length; - if (Array.isArray(data)) { - for (let i = 0; i < len; i++) { - const val = data[i]; - if (isCharacterGroup(val) ? isAll$1(testFn)(val) : testFn(val)) { - return true; - // this allows the function to short circut - } - } - return false; - } if (typeof data === 'string') { - for (let i = 0; i < len; i++) { - const val = data[i]; - if (testFn(val)) { - return true; - } - } - return false; - } - throw TypeError('The data must be an Array or a String!'); - }; - - const isJamo = datum => jamo.contains(Character(datum)); - const isCompatibilityJamo = datum => compatibilityJamo.contains(Character(datum)); - const isJamoExtendedA = datum => jamoExtendedA.char(Character(datum)); - const isSyllable = datum => syllables.contains(Character(datum)); - const isJamoExtendedB = datum => jamoExtendedB.contains(Character(datum)); - const isHalfwidth = datum => halfwidth.contains(Character(datum)); - const isReserved = datum => reserved.contains(Character(datum)); - const isStandardHangul = datum => standardHangul.contains(Character(datum)); - const isHangul = datum => hangul.contains(Character(datum)); - - const isAllJamo = isAll$1(isJamo); - const containsJamo = contains$1(isJamo); - - const isAllCompatibilityJamo = isAll$1(isCompatibilityJamo); - const containsCompatibilityJamo = contains$1(isCompatibilityJamo); - - const isAllJamoExtendedA = isAll$1(isJamoExtendedA); - const containsJamoExtendedA = contains$1(isJamoExtendedA); - - const isAllSyllable = isAll$1(isSyllable); - const containsSyllable = contains$1(isSyllable); - - const isAllJamoExtendedB = isAll$1(isJamoExtendedB); - const containsJamoExtendedB = contains$1(isJamoExtendedB); - - const isAllHalfwidth = isAll$1(isHalfwidth); - const containsHalfwidth = contains$1(isHalfwidth); - - const isAllReserved = isAll$1(isReserved); - const containsReserved = contains$1(isReserved); - - const isAllStandardHangul = isAll$1(isStandardHangul); - const containsStandardHangul = contains$1(isStandardHangul); - - const isAllHangul = isAll$1(isHangul); - const containsHangul = contains$1(isHangul); - name({ - isJamo, - isAllJamo, - containsJamo, - - isCompatibilityJamo, - isAllCompatibilityJamo, - containsCompatibilityJamo, - - isJamoExtendedA, - isAllJamoExtendedA, - containsJamoExtendedA, - - isSyllable, - isAllSyllable, - containsSyllable, - - isJamoExtendedB, - isAllJamoExtendedB, - containsJamoExtendedB, - - isHalfwidth, - isAllHalfwidth, - containsHalfwidth, - - isReserved, - isAllReserved, - containsReserved, - - isStandardHangul, - isAllStandardHangul, - containsStandardHangul, - - isHangul, - isAllHangul, - containsHangul, - }); - - const vowel = char => vowels[char]; - const isVowel$1 = is(vowel); - const isVowelAll = isAll(vowel); - const containsVowel = contains(vowel); - name({ - isVowel: isVowel$1, - isVowelAll, - containsVowel, - }); - - name({ - assemble, - - disassemble: disassemble$1, - disassembleCharacter: disassembleChar, - - composeComplex: complex$1, - composeSyllable: syllable, - - stronger: stronger$1, - }); - - exports.assemble = assemble; - exports.a = assemble; - exports.disassemble = disassemble$1; - exports.d = disassemble$1; - exports.disassembleCharacter = disassembleChar; - exports.composeComplex = complex$1; - exports.composeSyllable = syllable; - exports.stronger = stronger$1; - exports.useComp3 = useComp3; - exports.useArchaic = useArchaic; - exports.noUseJungJong = noUseJungJong; - exports.noCompDouble = noCompDouble; - exports.decomposeComplex = decomposeComplex; - exports.decomposeSyllable = decomposeSyllable; - exports.standardize = standardize; - exports.flatten = flatten; - exports.deepMap = deepMap; - exports.toKeys = toKeys; - exports.fromKeys = fromKeys; - exports.isConsonant = isConsonant; - exports.isConsonantAll = isConsonantAll; - exports.containsConsonant = containsConsonant; - exports.isJamo = isJamo; - exports.isCompatibilityJamo = isCompatibilityJamo; - exports.isJamoExtendedA = isJamoExtendedA; - exports.isSyllable = isSyllable; - exports.isJamoExtendedB = isJamoExtendedB; - exports.isHalfwidth = isHalfwidth; - exports.isReserved = isReserved; - exports.isStandardHangul = isStandardHangul; - exports.isHangul = isHangul; - exports.isAllJamo = isAllJamo; - exports.containsJamo = containsJamo; - exports.isAllCompatibilityJamo = isAllCompatibilityJamo; - exports.containsCompatibilityJamo = containsCompatibilityJamo; - exports.isAllJamoExtendedA = isAllJamoExtendedA; - exports.containsJamoExtendedA = containsJamoExtendedA; - exports.isAllSyllable = isAllSyllable; - exports.containsSyllable = containsSyllable; - exports.isAllJamoExtendedB = isAllJamoExtendedB; - exports.containsJamoExtendedB = containsJamoExtendedB; - exports.isAllHalfwidth = isAllHalfwidth; - exports.containsHalfwidth = containsHalfwidth; - exports.isAllReserved = isAllReserved; - exports.containsReserved = containsReserved; - exports.isAllStandardHangul = isAllStandardHangul; - exports.containsStandardHangul = containsStandardHangul; - exports.isAllHangul = isAllHangul; - exports.containsHangul = containsHangul; - exports.isVowel = isVowel$1; - exports.isVowelAll = isVowelAll; - exports.containsVowel = containsVowel; - - return exports; - -}({})); diff --git a/dist/iife/Hangul.min.js b/dist/iife/Hangul.min.js deleted file mode 100644 index 4005914..0000000 --- a/dist/iife/Hangul.min.js +++ /dev/null @@ -1 +0,0 @@ -var Hangul=function(n){"use strict";const t={"ㄱ":1,"ㄴ":1,"ㄷ":1,"ㄹ":1,"ㅁ":1,"ㅂ":1,"ㅅ":1,"ㅇ":1,"ㅈ":1,"ㅊ":1,"ㅋ":1,"ㅌ":1,"ㅍ":1,"ㅎ":1,"ㆁ":1,"ㆄ":1,"ㅱ":1,"ㅿ":1},r={"ㅏ":1,"ㅐ":1,"ㅑ":1,"ㅓ":1,"ㅔ":1,"ㅕ":1,"ㅖ":1,"ㅗ":1,"ㅛ":1,"ㅜ":1,"ㅠ":1,"ㅡ":1,"ㅣ":1,"ㆍ":1},e={"ㅂ":"q","ㅃ":"Q","ㅈ":"w","ㅉ":"W","ㄷ":"e","ㄸ":"E","ㄱ":"r","ㄲ":"R","ㅅ":"t","ㅆ":"T","ㅛ":"y","ㅕ":"u","ㅑ":"i","ㅐ":"o","ㅒ":"O","ㅔ":"p","ㅖ":"P","ㅁ":"a","ㄴ":"s","ㅇ":"d","ㄹ":"f","ㅎ":"g","ㅗ":"h","ㅓ":"j","ㅏ":"k","ㅣ":"l","ㅋ":"z","ㅌ":"x","ㅊ":"c","ㅍ":"v","ㅠ":"b","ㅜ":"n","ㅡ":"m"},s={q:"ㅂ",Q:"ㅃ",w:"ㅈ",W:"ㅉ",e:"ㄷ",E:"ㄸ",r:"ㄱ",R:"ㄲ",t:"ㅅ",T:"ㅆ",y:"ㅛ",u:"ㅕ",i:"ㅑ",o:"ㅐ",O:"ㅒ",p:"ㅔ",P:"ㅖ",a:"ㅁ",s:"ㄴ",d:"ㅇ",f:"ㄹ",g:"ㅎ",h:"ㅗ",j:"ㅓ",k:"ㅏ",l:"ㅣ",z:"ㅋ",x:"ㅌ",c:"ㅊ",v:"ㅍ",b:"ㅠ",n:"ㅜ",m:"ㅡ"},o={"ㄱㄱ":"ㄲ","ㄷㄷ":"ㄸ","ㅅㅅ":"ㅆ","ㅈㅈ":"ㅉ","ㅂㅂ":"ㅃ"},i={"ㅗㅏ":"ㅘ","ㅗㅐ":"ㅙ","ㅗㅣ":"ㅚ","ㅜㅓ":"ㅝ","ㅜㅔ":"ㅞ","ㅜㅣ":"ㅟ","ㅡㅣ":"ㅢ"},a={"ㄱㄱ":"ㄲ","ㄱㅅ":"ㄳ","ㄴㅈ":"ㄵ","ㄴㅎ":"ㄶ","ㄹㄱ":"ㄺ","ㄹㅁ":"ㄻ","ㄹㅂ":"ㄼ","ㄹㅅ":"ㄽ","ㄹㅌ":"ㄾ","ㄹㅍ":"ㄿ","ㄹㅎ":"ㅀ","ㅂㅅ":"ㅄ","ㅅㅅ":"ㅆ"},l={"ㄴㄴ":"ㅥ","ㄴㄷ":"ㅦ","ㄴㅅ":"ㅧ","ㄴㅿ":"ㅨ","ㄹㄱㅅ":"ㅩ","ㄹㄷ":"ㅪ","ㄹㅂㅅ":"ㅫ","ㄹㅿ":"ㅬ","ㄹㆆ":"ㅭ","ㅁㅂ":"ㅮ","ㅁㅅ":"ㅯ","ㅁㅿ":"ㅰ","ㅂㄱ":"ㅲ","ㅂㄷ":"ㅳ","ㅂㅅㄱ":"ㅴ","ㅂㅅㄷ":"ㅵ","ㅂㅈ":"ㅶ","ㅂㅌ":"ㅷ","ㅅㄱ":"ㅺ","ㅅㄴ":"ㅻ","ㅅㄷ":"ㅼ","ㅅㅂ":"ㅽ","ㅅㅈ":"ㅾ","ㅇㅇ":"ㆀ","ㆁㅅ":"ㆁ","ㆁㅿ":"ㅿ","ㅎㅎ":"ㆅ","ㅛㅑ":"ㆇ","ㅛㅒ":"ㆈ","ㅛㅣ":"ㆉ","ㅠㅕ":"ㆊ","ㅠㅖ":"ㆋ","ㅠㅣ":"ㆌ","ㆍㅣ":"ㆎ"},c={"ㄲ":["ㄱ","ㄱ"],"ㄳ":["ㄱ","ㅅ"],"ㄵ":["ㄴ","ㅈ"],"ㄶ":["ㄴ","ㅎ"],"ㄸ":["ㄷ","ㄷ"],"ㄻ":["ㄹ","ㅁ"],"ㄺ":["ㄹ","ㄱ"],"ㄼ":["ㄹ","ㅂ"],"ㄽ":["ㄹ","ㅅ"],"ㄾ":["ㄹ","ㅌ"],"ㄿ":["ㄹ","ㅍ"],"ㅀ":["ㄹ","ㅎ"],"ㅃ":["ㅂ","ㅂ"],"ㅄ":["ㅂ","ㅅ"],"ㅆ":["ㅅ","ㅅ"],"ㅉ":["ㅈ","ㅈ"],"ㅘ":["ㅗ","ㅏ"],"ㅙ":["ㅗ","ㅐ"],"ㅚ":["ㅗ","ㅣ"],"ㅝ":["ㅜ","ㅓ"],"ㅞ":["ㅜ","ㅔ"],"ㅟ":["ㅜ","ㅣ"],"ㅢ":["ㅡ","ㅣ"],"ㅥ":["ㄴ","ㄴ"],"ㅦ":["ㄴ","ㄷ"],"ㅧ":["ㄴ","ㅅ"],"ㅨ":["ㄴ","ㅿ"],"ㅩ":["ㄹ","ㄱ","ㅅ"],"ㅪ":["ㄹ","ㄷ"],"ㅫ":["ㄹ","ㅂ","ㅅ"],"ㅬ":["ㄹ","ㅿ"],"ㅭ":["ㄹ","ㆆ"],"ㅮ":["ㅁ","ㅂ"],"ㅯ":["ㅁ","ㅅ"],"ㅰ":["ㅁ","ㅿ"],"ㅲ":["ㅂ","ㄱ"],"ㅳ":["ㅂ","ㄷ"],"ㅴ":["ㅂ","ㅅ","ㄱ"],"ㅵ":["ㅂ","ㅅ","ㄷ"],"ㅶ":["ㅂ","ㅈ"],"ㅷ":["ㅂ","ㅌ"],"ㅺ":["ㅅ","ㄱ"],"ㅻ":["ㅅ","ㄴ"],"ㅼ":["ㅅ","ㄷ"],"ㅽ":["ㅅ","ㅂ"],"ㅾ":["ㅅ","ㅈ"],"ㆀ":["ㅇ","ㅇ"],"ㆂ":["ㆁ","ㅅ"],"ㆃ":["ㆁ","ㅿ"],"ㆅ":["ㅎ","ㅎ"],"ㆇ":["ㅛ","ㅑ"],"ㆈ":["ㅛ","ㅒ"],"ㆉ":["ㅛ","ㅣ"],"ㆊ":["ㅠ","ㅕ"],"ㆋ":["ㅠ","ㅖ"],"ㆌ":["ㅠ","ㅣ"],"ㆎ":["ㆍ","ㅣ"]},u=(Object.assign({},{"ㄲ":1,"ㄳ":1,"ㄵ":1,"ㄶ":1,"ㄸ":1,"ㄺ":1,"ㄻ":1,"ㄼ":1,"ㄽ":1,"ㄾ":1,"ㄿ":1,"ㅀ":1,"ㅃ":1,"ㅄ":1,"ㅆ":1,"ㅉ":1,"ㅘ":1,"ㅙ":1,"ㅚ":1,"ㅝ":1,"ㅞ":1,"ㅟ":1,"ㅢ":1},{"ㅥ":1,"ㅦ":1,"ㅧ":1,"ㅨ":1,"ㅩ":1,"ㅪ":1,"ㅫ":1,"ㅬ":1,"ㅭ":1,"ㅮ":1,"ㅯ":1,"ㅰ":1,"ㅱ":1,"ㅲ":1,"ㅳ":1,"ㅴ":1,"ㅵ":1,"ㅶ":1,"ㅷ":1}),{"ㄱ":"ㄲ","ㅋ":"ㄲ","ㄷ":"ㄸ","ㅌ":"ㄸ","ㅂ":"ㅃ","ㅍ":"ㅃ","ㅅ":"ㅆ","ㅈ":"ㅉ","ㅊ":"ㅉ"}),d=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],m=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],h=[null,"ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],f={"ㄱ":0,"ㄲ":1,"ㄴ":2,"ㄷ":3,"ㄸ":4,"ㄹ":5,"ㅁ":6,"ㅂ":7,"ㅃ":8,"ㅅ":9,"ㅆ":10,"ㅇ":11,"ㅈ":12,"ㅉ":13,"ㅊ":14,"ㅋ":15,"ㅌ":16,"ㅍ":17,"ㅎ":18},y={"ㅏ":0,"ㅐ":1,"ㅑ":2,"ㅒ":3,"ㅓ":4,"ㅔ":5,"ㅕ":6,"ㅖ":7,"ㅗ":8,"ㅘ":9,"ㅙ":10,"ㅚ":11,"ㅛ":12,"ㅜ":13,"ㅝ":14,"ㅞ":15,"ㅟ":16,"ㅠ":17,"ㅡ":18,"ㅢ":19,"ㅣ":20},g={"ㄱ":1,"ㄲ":2,"ㄳ":3,"ㄴ":4,"ㄵ":5,"ㄶ":6,"ㄷ":7,"ㄹ":8,"ㄺ":9,"ㄻ":10,"ㄼ":11,"ㄽ":12,"ㄾ":13,"ㄿ":14,"ㅀ":15,"ㅁ":16,"ㅂ":17,"ㅄ":18,"ㅅ":19,"ㅆ":20,"ㅇ":21,"ㅈ":22,"ㅊ":23,"ㅋ":24,"ㅌ":25,"ㅍ":26,"ㅎ":27};class A{constructor(n,t){this.start=n,this.end=t}containsCodePoint(n){return n>=this.start&&n<=this.end}contains(n){return this.containsCodePoint(n.codePointAt(0))}}class w{constructor(n,t={}){this.ranges=n,this.codePoints=t}containsCodePoint(n){return this.codePoints&&this.codePoints[n]||this.ranges.some(t=>t.containsCodePoint(n))}contains(n){const t=n.codePointAt(0);return this.containsCodePoint(t)}}const p=new A(4352,4607),b=new A(12592,12687),C=new A(43360,43391),$=new A(44032,55215),E=new A(55216,55295),J=new A(65440,65503),v=new w([new A(43389,43391),new A(55204,55215),new A(55239,55242),new A(55292,55295)],{12592:1,12687:1}),x=new w([b,$]),H=new w([p,b,C,$,E,J,v]);var S=(n,t,r=0)=>String.fromCodePoint(588*n+28*t+r+$.start);class P{constructor(n="",t=[]){this.result=n,this.remainder=t}}const T=n=>{const t=`${n}`;if(1!==t.length)throw Error(`"${t}" is not a Character!`);return t},j=()=>{throw TypeError("The data must be an Array or a String!")},R=n=>Array.isArray(n)?n:n.split(""),B=n=>!(n.length<1)&&(Array.isArray(n)?n.length>1||B(n[0]):"string"==typeof n&&n.length>1),N=n=>n,O=(n,t,r)=>{const e=r?R:N;return Array.isArray(n)?n.map(n=>B(n)?O(n,t,r):e(t(n))):"string"==typeof n?n.split("").map(n=>e(t(n))):void j()},V=(n,t)=>{let r="";if(Array.isArray(n)){const e=n.length;for(let s=0;s{if(Array.isArray(n)){let t="";const r=n.length;for(let e=0;e{let r,e="";if(Array.isArray(n)){r=[];const e=n.length;for(let s=0;s{if(n<0||n>8)throw Error("The mode cannot be less than zero or greater than eight!");const t=2&n,r=t&&1&n,e=8&n;let s=k[n];if(!s){const r=[o];4&n||r.push(i,a),t&&r.push(l),s=Object.assign({},...r),k[n]=s}return n=>{const t=n.length;if(t<1)throw Error("Cannot compose array of zero characters!");const o=n[0];if(t<2)return new P(o);const i=n[1];if(e&&o===i)return new P(o,n.slice(1));const a=s[o+i];if(a){if(r&&t>2){const t=s[o+i+n[2]];if(t)return new P(t,n.slice(3))}return new P(a,n.slice(2))}return new P(o,n.slice(1))}},D=n=>{const t=q(n);return n=>I(n,t)};var K=n=>{const t=q(n);return n=>{if(n.length<2)return new P(n[0]);const e=t(n),s=e.result,o=e.remainder,i=f[s];if(o.length<1||!Number.isInteger(i))return e;const a=t(o),l=a.result,c=a.remainder,u=y[l];if(!Number.isInteger(u))return new P(s,[l,...c]);if(c.length&&!(n=>n&&"ㆍ"!==n&&r[n])(c[1])){const n=t(c),r=n.result,e=n.remainder,s=g[r];if(s)return new P(S(i,u,s),e)}return new P(S(i,u),c)}};const Q=Object.assign({},{"ᄀ":"ㄱ","ᄁ":["ㄱ","ㄱ"],"ᄂ":"ㄴ","ᄃ":"ㄷ","ᄄ":["ㄷ","ㄷ"],"ᄅ":"ㄹ","ᄆ":"ㅁ","ᄇ":"ㅂ","ᄈ":["ㅂ","ㅂ"],"ᄉ":"ㅅ","ᄊ":["ㅅ","ㅅ"],"ᄋ":"ㅇ","ᄌ":"ㅈ","ᄍ":["ㅈ","ㅈ"],"ᄎ":"ㅊ","ᄏ":"ㅋ","ᄐ":"ㅌ","ᄑ":"ㅍ","ᄒ":"ㅎ","ᄓ":["ㄴ","ㄱ"],"ᄔ":["ㄴ","ㄴ"],"ᄕ":["ㄴ","ㄷ"],"ᄖ":["ㄴ","ㅂ"],"ᄗ":["ㄷ","ㄱ"],"ᄘ":["ㄹ","ㄴ"],"ᄙ":["ㄹ","ㄹ"],"ᄚ":["ㄹ","ㅎ"],"ᄛ":["ㄹ","ㅇ"],"ᄜ":["ㅁ","ㅂ"],"ᄝ":"ㅱ","ᄞ":["ㅂ","ㄱ"],"ᄟ":["ㅂ","ㄴ"],"ᄠ":["ㅂ","ㄷ"],"ᄡ":["ㅂ","ㅅ"],"ᄢ":["ㅂ","ㅅ","ㄱ"],"ᄣ":["ㅂ","ㅅ","ㄷ"],"ᄤ":["ㅂ","ㅅ","ㅂ"],"ᄥ":["ㅂ","ㅅ","ㅅ"],"ᄦ":["ㅂ","ㅅ","ㅈ"],"ᄧ":["ㅂ","ㅈ"],"ᄨ":["ㅂ","ㅊ"],"ᄩ":["ㅂ","ㅌ"],"ᄪ":["ㅂ","ㅍ"],"ᄫ":["ㅂ","ㅇ"],"ᄬ":[["ㅂ","ㅂ"],"ㅇ"],"ᄭ":["ㅅ","ㄱ"],"ᄮ":["ㅅ","ㄴ"],"ᄯ":["ㅅ","ㄷ"],"ᄰ":["ㅅ","ㄹ"],"ᄱ":["ㅅ","ㅁ"],"ᄲ":["ㅅ","ㅂ"],"ᄳ":["ㅅ","ㅂ","ㄱ"],"ᄴ":["ㅅ","ㅅ","ㅅ"],"ᄵ":["ㅅ","ㅇ"],"ᄶ":["ㅅ","ㅈ"],"ᄷ":["ㅅ","ㅊ"],"ᄸ":["ㅅ","ㅋ"],"ᄹ":["ㅅ","ㅌ"],"ᄺ":["ㅅ","ㅍ"],"ᄻ":["ㅅ","ㅎ"],"ᄼ":null,"ᄽ":null,"ᄾ":null,"ᄿ":null,"ᅀ":"ㅿ","ᅁ":["ㅇ","ㄱ"],"ᅂ":["ㅇ","ㄷ"],"ᅃ":["ㅇ","ㅁ"],"ᅄ":["ㅇ","ㅂ"],"ᅅ":["ㅇ","ㅅ"],"ᅆ":["ㅇ","ㅿ"],"ᅇ":["ㅇ","ㅇ"],"ᅈ":["ㅇ","ㅈ"],"ᅉ":["ㅇ","ㅊ"],"ᅊ":["ㅇ","ㅌ"],"ᅋ":["ㅇ","ㅍ"],"ᅌ":"ㆁ","ᅍ":["ㅈ","ㅇ"],"ᅎ":null,"ᅏ":null,"ᅐ":null,"ᅑ":null,"ᅒ":["ㅊ","ㅋ"],"ᅓ":["ㅊ","ㅎ"],"ᅔ":null,"ᅕ":null,"ᅖ":["ㅍ","ㅂ"],"ᅗ":"ㆄ","ᅘ":["ㅎ","ㅎ"],"ᅙ":"ㆆ","ᅚ":["ㄱ","ㄷ"],"ᅛ":["ㄱ","ㅅ"],"ᅜ":["ㄱ","ㅈ"],"ᅝ":["ㄱ","ㅎ"],"ᅞ":["ㄷ","ㄹ"],"ᅡ":"ㅏ","ᅢ":"ㅐ","ᅣ":"ㅑ","ᅤ":"ㅒ","ᅥ":"ㅓ","ᅦ":"ㅔ","ᅧ":"ㅕ","ᅨ":"ㅖ","ᅩ":"ㅗ","ᅪ":["ㅗ","ㅏ"],"ᅫ":["ㅗ","ㅐ"],"ᅬ":["ㅗ","ㅣ"],"ᅭ":"ㅛ","ᅮ":"ㅜ","ᅯ":["ㅜ","ㅓ"],"ᅰ":["ㅜ","ㅔ"],"ᅱ":["ㅜ","ㅣ"],"ᅲ":"ㅠ","ᅳ":"ㅡ","ᅴ":["ㅡ","ㅣ"],"ᅵ":"ㅣ","ᅶ":["ㅏ","ㅗ"],"ᅷ":["ㅏ","ㅜ"],"ᅸ":["ㅑ","ㅗ"],"ᅹ":["ㅑ","ㅛ"],"ᅺ":["ㅓ","ㅗ"],"ᅻ":["ㅓ","ㅜ"],"ᅼ":["ㅓ","ㅡ"],"ᅽ":["ㅕ","ㅗ"],"ᅾ":["ㅕ","ㅜ"],"ᅿ":["ㅗ","ㅓ"],"ᆀ":["ㅔ","ㅗ"],"ᆁ":["ㅖ","ㅗ"],"ᆂ":["ㅗ","ㅗ"],"ᆃ":["ㅗ","ㅜ"],"ᆄ":["ㅛ","ㅑ"],"ᆅ":["ㅛ","ㅒ"],"ᆆ":["ㅛ","ㅕ"],"ᆇ":["ㅛ","ㅗ"],"ᆈ":["ㅛ","ㅣ"],"ᆉ":["ㅜ","ㅏ"],"ᆊ":["ㅜ","ㅐ"],"ᆋ":["ㅜ","ㅓ","ㅡ"],"ᆌ":["ㅜ","ㅖ"],"ᆍ":["ㅜ","ㅜ"],"ᆎ":["ㅠ","ㅏ"],"ᆏ":["ㅠ","ㅓ"],"ᆐ":["ㅠ","ㅔ"],"ᆑ":["ㅠ","ㅕ"],"ᆒ":["ㅠ","ㅔ"],"ᆓ":["ㅠ","ㅜ"],"ᆔ":["ㅠ","ㅣ"],"ᆕ":["ㅡ","ㅜ"],"ᆖ":["ㅡ","ㅡ"],"ᆗ":["ㅡ","ㅣ","ㅜ"],"ᆘ":["ㅣ","ㅏ"],"ᆙ":["ㅣ","ㅑ"],"ᆚ":["ㅣ","ㅗ"],"ᆛ":["ㅣ","ㅜ"],"ᆜ":["ㅣ","ㅡ"],"ᆝ":null,"ᆞ":"ㆍ","ᆟ":["ㆍ","ㅓ"],"ᆠ":["ㆍ","ㅜ"],"ᆡ":["ㆍ","ㅣ"],"ᆢ":["ㆍ","ㆍ"],"ᆣ":["ㅏ","ㅡ"],"ᆤ":["ㅑ","ㅜ"],"ᆥ":["ㅕ","ㅑ"],"ᆦ":["ㅗ","ㅑ"],"ᆧ":["ㅗ","ㅒ"],"ᆨ":"ㄱ","ᆩ":["ㄱ","ㄱ"],"ᆪ":["ㄱ","ㅅ"],"ᆫ":"ㄴ","ᆬ":["ㄴ","ㅈ"],"ᆭ":["ㄴ","ㅎ"],"ᆮ":"ㄷ","ᆯ":"ㄹ","ᆰ":["ㄹ","ㄱ"],"ᆱ":["ㄹ","ㅁ"],"ᆲ":["ㄹ","ㅂ"],"ᆳ":["ㄹ","ㅅ"],"ᆴ":["ㄹ","ㅌ"],"ᆵ":["ㄹ","ㅍ"],"ᆶ":["ㄹ","ㅎ"],"ᆷ":"ㅁ","ᆸ":"ㅂ","ᆹ":["ㅂ","ㅅ"],"ᆺ":"ㅅ","ᆻ":["ㅅ","ㅅ"],"ᆼ":"ㅇ","ᆽ":"ㅈ","ᆾ":"ㅊ","ᆿ":"ㅋ","ᇀ":"ㅌ","ᇁ":"ㅍ","ᇂ":"ㅎ","ᇃ":["ㄱ","ㄹ"],"ᇄ":["ㄱ","ㅅ","ㄱ"],"ᇅ":["ㄴ","ㄱ"],"ᇆ":["ㄴ","ㄷ"],"ᇇ":["ㄴ","ㅅ"],"ᇈ":["ㄴ","ㅿ"],"ᇉ":["ㄴ","ㅌ"],"ᇊ":["ㄷ","ㄱ"],"ᇋ":["ㄷ","ㄹ"],"ᇌ":["ㄹ","ㄱ","ㅅ"],"ᇍ":["ㄹ","ㄴ"],"ᇎ":["ㄹ","ㄷ"],"ᇏ":["ㄹ","ㄷ","ㅎ"],"ᇐ":["ㄹ","ㄹ"],"ᇑ":["ㄹ","ㅁ","ㄱ"],"ᇒ":["ㄹ","ㅁ","ㅅ"],"ᇓ":["ㄹ","ㅂ","ㅅ"],"ᇔ":["ㄹ","ㅂ","ㅎ"],"ᇕ":["ㄹ","ㅸ"],"ᇖ":["ㄹ","ㅅ","ㅅ"],"ᇗ":["ㄹ","ㅿ"],"ᇘ":["ㄹ","ㅋ"],"ᇙ":["ㄹ","ㆆ"],"ᇚ":["ㅁ","ㄱ"],"ᇛ":["ㅁ","ㄹ"],"ᇜ":["ㅁ","ㅂ"],"ᇝ":["ㅁ","ㅅ"],"ᇞ":["ㅁ","ㅅ","ㅅ"],"ᇟ":["ㅁ","ㅿ"],"ᇠ":["ㅁ","ㅊ"],"ᇡ":["ㅁ","ㅎ"],"ᇢ":"ㅱ","ᇣ":["ㅂ","ㄹ"],"ᇤ":["ㅂ","ㅍ"],"ᇥ":["ㅂ","ㅎ"],"ᇦ":["ㅂ","ㅇ"],"ᇧ":["ㅅ","ㄱ"],"ᇨ":["ㅅ","ㄷ"],"ᇩ":["ㅅ","ㄹ"],"ᇪ":["ㅅ","ㅂ"],"ᇫ":"ㅿ","ᇬ":["ㆁ","ㄱ"],"ᇭ":["ㆁ","ㄱ","ㄱ"],"ᇮ":["ㆁ","ㆁ"],"ᇯ":["ㆁ","ㅋ"],"ᇰ":"ㆁ","ᇱ":["ㆁ","ㅅ"],"ᇲ":["ㆁ","ㅿ"],"ᇳ":["ㅍ","ㅂ"],"ᇴ":"ㆄ","ᇵ":["ㅎ","ㄴ"],"ᇶ":["ㅎ","ㄹ"],"ᇷ":["ㅎ","ㅁ"],"ᇸ":["ㅎ","ㅂ"],"ᇹ":"ㆆ","ᇺ":["ㄱ","ㄴ"],"ᇻ":["ㄱ","ㅂ"],"ᇼ":["ㄱ","ㅊ"],"ᇽ":["ㄱ","ㅋ"],"ᇾ":["ㄱ","ㅎ"],"ᇿ":["ㄴ","ㄴ"]},{"ꥠ":["ㄷ","ㅁ"],"ꥡ":["ㄷ","ㅂ"],"ꥢ":["ㄷ","ㅅ"],"ꥣ":["ㄷ","ㅈ"],"ꥤ":["ㄹ","ㄱ"],"ꥥ":["ㄹ","ㄱ","ㄱ"],"ꥦ":["ㄹ","ㄷ"],"ꥧ":["ㄹ","ㄷ","ㄷ"],"ꥨ":["ㄹ","ㅁ"],"ꥩ":["ㄹ","ㅂ"],"ꥪ":["ㄹ","ㅂ","ㅂ"],"ꥫ":["ㄹ","ㅸ"],"ꥬ":["ㄹ","ㅅ"],"ꥭ":["ㄹ","ㅈ"],"ꥮ":["ㄹ","ㅋ"],"ꥯ":["ㅁ","ㄱ"],"ꥰ":["ㅁ","ㄷ"],"ꥱ":["ㅁ","ㅅ"],"ꥲ":["ㅂ","ㅅ","ㅌ"],"ꥳ":["ㅂ","ㅋ"],"ꥴ":["ㅂ","ㅎ"],"ꥵ":["ㅅ","ㅅ","ㅂ"],"ꥶ":["ㅇ","ㄹ"],"ꥷ":["ㅇ","ㅎ"],"ꥸ":["ㅈ","ㅈ","ㅎ"],"ꥹ":["ㅌ","ㅌ"],"ꥺ":["ㅍ","ㅎ"],"ꥻ":["ㅎ","ㅅ"],"ꥼ":["ㆆ","ㆆ"]},{"ힰ":["ㅗ","ㅕ"],"ힱ":["ㅗ","ㅗ","ㅣ"],"ힲ":["ㅛ","ㅏ"],"ힳ":["ㅛ","ㅐ"],"ힴ":["ㅛ","ㅓ"],"ힵ":["ㅜ","ㅕ"],"ힶ":["ㅜ","ㅣ","ㅣ"],"ힷ":["ㅠ","ㅐ"],"ힸ":["ㅠ","ㅗ"],"ힹ":["ㅡ","ㅏ"],"ힺ":["ㅡ","ㅓ"],"ힻ":["ㅡ","ㅔ"],"ힼ":["ㅡ","ㅗ"],"ힽ":["ㅣ","ㅏ","ㅗ"],"ힾ":["ㅣ","ㅒ"],"ힿ":["ㅣ","ㅕ"],"ퟀ":["ㅣ","ㅖ"],"ퟁ":["ㅣ","ㅗ","ㅣ"],"ퟂ":["ㅣ","ㅛ"],"ퟃ":["ㅣ","ㅠ"],"ퟄ":["ㅣ","ㅣ"],"ퟅ":["ㆍ","ㅏ"],"ퟆ":["ㆍ","ㅔ"],"ퟋ":["ㄴ","ㄹ"],"ퟌ":["ㄴ","ㅈ"],"ퟍ":["ㄷ","ㄷ"],"ퟎ":["ㄷ","ㄷ","ㅂ"],"ퟏ":["ㄷ","ㅂ"],"ퟐ":["ㄷ","ㅅ"],"ퟑ":["ㄷ","ㅅ","ㄱ"],"ퟒ":["ㄷ","ㅈ"],"ퟓ":["ㄷ","ㅊ"],"ퟔ":["ㄷ","ㅌ"],"ퟕ":["ㄹ","ㄱ","ㄱ"],"ퟖ":["ㄹ","ㄱ","ㅎ"],"ퟗ":["ㄹ","ㄹ","ㅋ"],"ퟘ":["ㄹ","ㅁ","ㅎ"],"ퟙ":["ㄹ","ㅂ","ㄷ"],"ퟚ":["ㄹ","ㅂ","ㅍ"],"ퟛ":["ㄹ","ㆁ"],"ퟜ":["ㄹ","ㆆ","ㅎ"],"ퟝ":null,"ퟞ":["ㅁ","ㄴ"],"ퟟ":["ㅁ","ㄴ","ㄴ"],"ퟠ":["ㅁ","ㅁ"],"ퟡ":["ㅁ","ㅂ","ㅅ"],"ퟢ":["ㅁ","ㅈ"],"ퟣ":["ㅂ","ㄷ"],"ퟤ":["ㅂ","ㄹ","ㅍ"],"ퟥ":["ㅂ","ㅁ"],"ퟦ":["ㅂ","ㅂ"],"ퟧ":["ㅂ","ㅅ","ㄷ"],"ퟨ":["ㅂ","ㅈ"],"ퟩ":["ㅂ","ㅊ"],"ퟪ":["ㅅ","ㅁ"],"ퟫ":["ㅅ","ㅸ"],"ퟬ":["ㅅ","ㅅ","ㄱ"],"ퟭ":["ㅅ","ㅅ","ㄷ"],"ퟮ":["ㅅ","ㅿ"],"ퟯ":["ㅅ","ㅈ"],"ퟰ":["ㅅ","ㅊ"],"ퟱ":["ㅅ","ㅌ"],"ퟲ":["ㅅ","ㅎ"],"ퟳ":["ㅿ","ㅂ"],"ퟴ":["ㅿ","ㅸ"],"ퟵ":["ㆁ","ㅁ"],"ퟶ":["ㆁ","ㅎ"],"ퟷ":["ㅈ","ㅂ"],"ퟸ":["ㅈ","ㅂ","ㅂ"],"ퟹ":["ㅈ","ㅈ"],"ퟺ":["ㅍ","ㅅ"],"ퟻ":["ㅍ","ㅌ"]},{"ᄀ":"ㄱ","ᄁ":["ㄱ","ㄱ"],"ᆪ":["ㄱ","ㅅ"],"ᄂ":"ㄴ","ᆬ":["ㄴ","ㅈ"],"ᆭ":["ㄴ","ㅎ"],"ᄃ":"ㄷ","ᄄ":["ㄷ","ㄷ"],"ᄅ":"ㄹ","ᆰ":["ㄹ","ㄱ"],"ᆱ":["ㄹ","ㅁ"],"ᆲ":["ㄹ","ㅂ"],"ᆳ":["ㄹ","ㅅ"],"ᆴ":["ㄹ","ㅌ"],"ᆵ":["ㄹ","ㅍ"],"ᄚ":["ㄹ","ㅎ"],"ᄆ":"ㅁ","ᄇ":"ㅂ","ᄈ":["ㅂ","ㅂ"],"ᄡ":["ㅂ","ㅅ"],"ᄉ":"ㅅ","ᄊ":["ㅅ","ㅅ"],"ᄋ":"ㅇ","ᄌ":"ㅈ","ᄍ":["ㅈ","ㅈ"],"ᄎ":"ㅊ","ᄏ":"ㅋ","ᄐ":"ㅌ","ᄑ":"ㅍ","ᄒ":"ㅎ","ᅡ":"ㅏ","ᅢ":"ㅐ","ᅣ":"ㅑ","ᅤ":"ㅒ","ᅥ":"ㅓ","ᅦ":"ㅔ","ᅧ":"ㅕ","ᅨ":"ㅖ","ᅩ":"ㅗ","ᅪ":["ㅗ","ㅏ"],"ᅫ":["ㅗ","ㅐ"],"ᅬ":["ㅗ","ㅣ"],"ᅭ":"ㅛ","ᅮ":"ㅜ","ᅯ":["ㅜ","ㅓ"],"ᅰ":["ㅜ","ㅔ"],"ᅱ":["ㅜ","ㅣ"],"ᅲ":"ㅠ","ᅳ":"ㅡ","ᅴ":["ㅡ","ㅣ"],"ᅵ":"ㅣ"}),W=n=>(n=>!x.contains(n)&&Q[n]||n)(T(n)),F=n=>(x.contains(n)?c:Q)[n]||n,L=n=>F(T(n)),M=n=>(t,r)=>I(n(t),K(r));var U=M(n=>O(n,L));const G=D(4),X=n=>{const t=F(n);if(Array.isArray(t)){const n=G(t);return Array.isArray(n)&&1===n.length?T(n):n}return t};const Y=n=>{const t=n.codePointAt(0)-$.start,r=t%28,e=(t-r)/28,s=e%21;return[d[0|e/21],m[s],h[r]].filter(n=>n)};const Z=n=>t=>{const r=T(t);return $.contains(r)?Y(r).map(n):n(r)},_=Z(F),nn=Z(X),tn=(n,t,r)=>{const e=(r?_:nn)(n);return t?e:z(e)};var rn=(n,t,r)=>(t?O:V)(n,r?_:nn,!0),en=n=>{Object.keys(n).forEach(t=>{n[t].displayName=t})};const sn={"ㄱ":{"ㄱ":"ㄲ","ㅅ":"ㄳ"},"ㄷ":{"ㄷ":"ㄸ"},"ㅅ":{"ㅅ":"ㅆ","ㄱ":"ㅺ","ㄴ":"ㅻ","ㄷ":"ㅼ","ㅂ":"ㅽ","ㅈ":"ㅾ"},"ㅈ":{"ㅈ":"ㅉ"},"ㅂ":{"ㅂ":"ㅃ","ㅅ":{$:"ㅄ","ㄱ":"ㅴ","ㄷ":"ㅵ"},"ㄱ":"ㅲ","ㄷ":"ㅳ","ㅈ":"ㅶ","ㅌ":"ㅷ"},"ㅗ":{"ㅏ":"ㅘ","ㅐ":"ㅙ","ㅣ":"ㅚ"},"ㅜ":{"ㅓ":"ㅝ","ㅔ":"ㅞ","ㅣ":"ㅟ"},"ㅡ":{"ㅣ":"ㅢ"},"ㄴ":{"ㅈ":"ㄵ","ㅎ":"ㄶ","ㄴ":"ㅥ","ㄷ":"ㅦ","ㅅ":"ㅧ","ㅿ":"ㅨ"},"ㄹ":{"ㄱ":{$:"ㄺ","ㅅ":"ㅩ"},"ㅁ":"ㄻ","ㅂ":{$:"ㄼ","ㅅ":"ㅫ"},"ㅅ":"ㄽ","ㅌ":"ㄾ","ㅍ":"ㄿ","ㅎ":"ㅀ","ㄷ":"ㅪ","ㅿ":"ㅬ","ㆆ":"ㅭ"},"ㅁ":{"ㅂ":"ㅮ","ㅅ":"ㅯ","ㅿ":"ㅰ"},"ㅇ":{"ㅇ":"ㆀ"},"ㆁ":{"ㅅ":"ㆁ","ㅿ":"ㅿ"},"ㅎ":{"ㅎ":"ㆅ"},"ㅛ":{"ㅑ":"ㆇ","ㅒ":"ㆈ","ㅣ":"ㆉ"},"ㅠ":{"ㅕ":"ㆊ","ㅖ":"ㆋ","ㅣ":"ㆌ"},"ㆍ":{"ㅣ":"ㆎ"}},on=n=>{const t=D(n);return n=>{const r=W(n);return Array.isArray(r)?t(r):r}},an=n=>{const t=on(n);return(n,r)=>(r?O:V)(n,t)};const ln=on(3),cn=(n,t,r="",e)=>{if(void 0===n||void 0===t)throw Error("Cannot compose a complex with less than two values!");const s=sn[ln(n)];if(!s){if(e)throw Error(`There's no complex character that starts with ${n}`);return`${n}${t}${r}`}const o=s[ln(t)];if(!o){if(e)throw Error(`Cannot combine ${n} and ${t}`);return`${n}${t}${r}`}const i=o.$||o;if(r){const s=o[ln(r)];if(!s){if(e)throw Error(`Found ${i} but cannot combine ${n}, ${t}, and ${r}`);return`${i}${r}`}return s}return i},un=(n,t="",r="",e)=>{const s=f[ln(n)],o=y[ln(t)];let i;if(r&&(i=g[ln(r)]),!Number.isInteger(s)){if(e)throw Error(`"${n}" is not a valid cho Character`);return`${n}${t}${r}`}if(!Number.isInteger(o)){if(e)throw Error(`"${t}" is not a valid jung Character`);return`${n}${t}${r}`}if(r&&!Number.isInteger(i)){if(e)throw Error(`"${r}" is not a valid jong character`);return`${S(s,o)}${r}`}return S(s,o,i)},dn=an(3);var mn=n=>dn(n).map(n=>u[n]||n);const hn=n=>e[n]||n,fn=n=>s[n],yn=Z(n=>{const t=X(n);return Array.isArray(t)?t.map(hn):hn(t)}),gn=n=>{const t=T(n),r=fn(t);if(!r){const n=fn(t.toLowerCase());return n||t}return r},An=M(n=>O(n,gn));var wn=n=>t=>r=>V(r,L)[n](t),pn=wn("some"),bn=n=>t=>{const r=L(t);return Array.isArray(r)?r.every(n):n(r)},Cn=wn("every");const $n=n=>t[n],En=bn($n),Jn=Cn($n),vn=pn($n);en({isConsonant:En,isConsonantAll:Jn,containsConsonant:vn});const xn=n=>t=>{const r=t.length;if(Array.isArray(t)){for(let e=0;et=>{const r=t.length;if(Array.isArray(t)){for(let e=0;ep.contains(T(n)),Pn=n=>b.contains(T(n)),Tn=n=>C.char(T(n)),jn=n=>$.contains(T(n)),Rn=n=>E.contains(T(n)),Bn=n=>J.contains(T(n)),Nn=n=>v.contains(T(n)),On=n=>x.contains(T(n)),Vn=n=>H.contains(T(n)),zn=xn(Sn),In=Hn(Sn),kn=xn(Pn),qn=Hn(Pn),Dn=xn(Tn),Kn=Hn(Tn),Qn=xn(jn),Wn=Hn(jn),Fn=xn(Rn),Ln=Hn(Rn),Mn=xn(Bn),Un=Hn(Bn),Gn=xn(Nn),Xn=Hn(Nn),Yn=xn(On),Zn=Hn(On),_n=xn(Vn),nt=Hn(Vn);en({isJamo:Sn,isAllJamo:zn,containsJamo:In,isCompatibilityJamo:Pn,isAllCompatibilityJamo:kn,containsCompatibilityJamo:qn,isJamoExtendedA:Tn,isAllJamoExtendedA:Dn,containsJamoExtendedA:Kn,isSyllable:jn,isAllSyllable:Qn,containsSyllable:Wn,isJamoExtendedB:Rn,isAllJamoExtendedB:Fn,containsJamoExtendedB:Ln,isHalfwidth:Bn,isAllHalfwidth:Mn,containsHalfwidth:Un,isReserved:Nn,isAllReserved:Gn,containsReserved:Xn,isStandardHangul:On,isAllStandardHangul:Yn,containsStandardHangul:Zn,isHangul:Vn,isAllHangul:_n,containsHangul:nt});const tt=n=>r[n],rt=bn(tt),et=Cn(tt),st=pn(tt);return en({isVowel:rt,isVowelAll:et,containsVowel:st}),en({assemble:U,disassemble:rn,disassembleCharacter:tn,composeComplex:cn,composeSyllable:un,stronger:mn}),n.assemble=U,n.a=U,n.disassemble=rn,n.d=rn,n.disassembleCharacter=tn,n.composeComplex=cn,n.composeSyllable=un,n.stronger=mn,n.useComp3=1,n.useArchaic=2,n.noUseJungJong=4,n.noCompDouble=8,n.decomposeComplex=((n,t)=>R((t?F:X)(T(n)))),n.decomposeSyllable=((n,t)=>{const r=T(n);if(!$.contains(r)){if(t)throw Error("Decomposing a syllable requires a syllable to decompose!");return[n]}return Y(r)}),n.standardize=((n,t,r)=>an(r)(n,t)),n.flatten=z,n.deepMap=O,n.toKeys=((n,t)=>(t?O:V)(n,yn)),n.fromKeys=(n=>An(n,8)),n.isConsonant=En,n.isConsonantAll=Jn,n.containsConsonant=vn,n.isJamo=Sn,n.isCompatibilityJamo=Pn,n.isJamoExtendedA=Tn,n.isSyllable=jn,n.isJamoExtendedB=Rn,n.isHalfwidth=Bn,n.isReserved=Nn,n.isStandardHangul=On,n.isHangul=Vn,n.isAllJamo=zn,n.containsJamo=In,n.isAllCompatibilityJamo=kn,n.containsCompatibilityJamo=qn,n.isAllJamoExtendedA=Dn,n.containsJamoExtendedA=Kn,n.isAllSyllable=Qn,n.containsSyllable=Wn,n.isAllJamoExtendedB=Fn,n.containsJamoExtendedB=Ln,n.isAllHalfwidth=Mn,n.containsHalfwidth=Un,n.isAllReserved=Gn,n.containsReserved=Xn,n.isAllStandardHangul=Yn,n.containsStandardHangul=Zn,n.isAllHangul=_n,n.containsHangul=nt,n.isVowel=rt,n.isVowelAll=et,n.containsVowel=st,n}({}); diff --git a/dist/umd/Hangul.js b/dist/umd/Hangul.js deleted file mode 100644 index b0a5f36..0000000 --- a/dist/umd/Hangul.js +++ /dev/null @@ -1,1708 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (factory((global.Hangul = {}))); -}(this, (function (exports) { 'use strict'; - - const consonants = { - ㄱ: 1, - ㄴ: 1, - ㄷ: 1, - ㄹ: 1, - ㅁ: 1, - ㅂ: 1, - ㅅ: 1, - ㅇ: 1, - ㅈ: 1, - ㅊ: 1, - ㅋ: 1, - ㅌ: 1, - ㅍ: 1, - ㅎ: 1, - ㆁ: 1, // apparently this is now "ㅇ" - ㆄ: 1, - ㅱ: 1, - ㅿ: 1, - }; - const vowels = { - ㅏ: 1, - ㅐ: 1, - ㅑ: 1, - ㅓ: 1, - ㅔ: 1, - ㅕ: 1, - ㅖ: 1, - ㅗ: 1, - ㅛ: 1, - ㅜ: 1, - ㅠ: 1, - ㅡ: 1, - ㅣ: 1, - ㆍ: 1, - }; - const hangulToKey = { - ㅂ: 'q', - ㅃ: 'Q', - ㅈ: 'w', - ㅉ: 'W', - ㄷ: 'e', - ㄸ: 'E', - ㄱ: 'r', - ㄲ: 'R', - ㅅ: 't', - ㅆ: 'T', - ㅛ: 'y', - ㅕ: 'u', - ㅑ: 'i', - ㅐ: 'o', - ㅒ: 'O', - ㅔ: 'p', - ㅖ: 'P', - ㅁ: 'a', - ㄴ: 's', - ㅇ: 'd', - ㄹ: 'f', - ㅎ: 'g', - ㅗ: 'h', - ㅓ: 'j', - ㅏ: 'k', - ㅣ: 'l', - ㅋ: 'z', - ㅌ: 'x', - ㅊ: 'c', - ㅍ: 'v', - ㅠ: 'b', - ㅜ: 'n', - ㅡ: 'm', - }; - const keyToHangul = { - q: 'ㅂ', - Q: 'ㅃ', - w: 'ㅈ', - W: 'ㅉ', - e: 'ㄷ', - E: 'ㄸ', - r: 'ㄱ', - R: 'ㄲ', - t: 'ㅅ', - T: 'ㅆ', - y: 'ㅛ', - u: 'ㅕ', - i: 'ㅑ', - o: 'ㅐ', - O: 'ㅒ', - p: 'ㅔ', - P: 'ㅖ', - a: 'ㅁ', - s: 'ㄴ', - d: 'ㅇ', - f: 'ㄹ', - g: 'ㅎ', - h: 'ㅗ', - j: 'ㅓ', - k: 'ㅏ', - l: 'ㅣ', - z: 'ㅋ', - x: 'ㅌ', - c: 'ㅊ', - v: 'ㅍ', - b: 'ㅠ', - n: 'ㅜ', - m: 'ㅡ', - }; - // the reason the data is stored like this is because iterating - // through an array is slower than just getting a key from an object - // In this case though, it might be faster since arrays are allocated - // on the heap instead of the stack? - - // I realize that I can programmatically reverse the key-value pairs during - // runtime but since I can just do it now, it's just a little faster. - - const cho = { - ㄱㄱ: 'ㄲ', - ㄷㄷ: 'ㄸ', - ㅅㅅ: 'ㅆ', - ㅈㅈ: 'ㅉ', - ㅂㅂ: 'ㅃ', - }; - const jung = { - ㅗㅏ: 'ㅘ', - ㅗㅐ: 'ㅙ', - ㅗㅣ: 'ㅚ', - ㅜㅓ: 'ㅝ', - ㅜㅔ: 'ㅞ', - ㅜㅣ: 'ㅟ', - ㅡㅣ: 'ㅢ', - }; - const jong = { - ㄱㄱ: 'ㄲ', - ㄱㅅ: 'ㄳ', - ㄴㅈ: 'ㄵ', - ㄴㅎ: 'ㄶ', - ㄹㄱ: 'ㄺ', - ㄹㅁ: 'ㄻ', - ㄹㅂ: 'ㄼ', - ㄹㅅ: 'ㄽ', - ㄹㅌ: 'ㄾ', - ㄹㅍ: 'ㄿ', - ㄹㅎ: 'ㅀ', - ㅂㅅ: 'ㅄ', - ㅅㅅ: 'ㅆ', - }; - const archaic = { - ㄴㄴ: 'ㅥ', - ㄴㄷ: 'ㅦ', - ㄴㅅ: 'ㅧ', - ㄴㅿ: 'ㅨ', - ㄹㄱㅅ: 'ㅩ', - ㄹㄷ: 'ㅪ', - ㄹㅂㅅ: 'ㅫ', - ㄹㅿ: 'ㅬ', - ㄹㆆ: 'ㅭ', - ㅁㅂ: 'ㅮ', - ㅁㅅ: 'ㅯ', - ㅁㅿ: 'ㅰ', - ㅂㄱ: 'ㅲ', - ㅂㄷ: 'ㅳ', - ㅂㅅㄱ: 'ㅴ', - ㅂㅅㄷ: 'ㅵ', - ㅂㅈ: 'ㅶ', - ㅂㅌ: 'ㅷ', - ㅅㄱ: 'ㅺ', - ㅅㄴ: 'ㅻ', - ㅅㄷ: 'ㅼ', - ㅅㅂ: 'ㅽ', - ㅅㅈ: 'ㅾ', - ㅇㅇ: 'ㆀ', - ㆁㅅ: 'ㆁ', - ㆁㅿ: 'ㅿ', - ㅎㅎ: 'ㆅ', - ㅛㅑ: 'ㆇ', - ㅛㅒ: 'ㆈ', - ㅛㅣ: 'ㆉ', - ㅠㅕ: 'ㆊ', - ㅠㅖ: 'ㆋ', - ㅠㅣ: 'ㆌ', - ㆍㅣ: 'ㆎ', - }; - const pairs = { - ㄲ: ['ㄱ', 'ㄱ'], - ㄳ: ['ㄱ', 'ㅅ'], - ㄵ: ['ㄴ', 'ㅈ'], - ㄶ: ['ㄴ', 'ㅎ'], - ㄸ: ['ㄷ', 'ㄷ'], - ㄻ: ['ㄹ', 'ㅁ'], - ㄺ: ['ㄹ', 'ㄱ'], - ㄼ: ['ㄹ', 'ㅂ'], - ㄽ: ['ㄹ', 'ㅅ'], - ㄾ: ['ㄹ', 'ㅌ'], - ㄿ: ['ㄹ', 'ㅍ'], - ㅀ: ['ㄹ', 'ㅎ'], - ㅃ: ['ㅂ', 'ㅂ'], - ㅄ: ['ㅂ', 'ㅅ'], - ㅆ: ['ㅅ', 'ㅅ'], - ㅉ: ['ㅈ', 'ㅈ'], - ㅘ: ['ㅗ', 'ㅏ'], - ㅙ: ['ㅗ', 'ㅐ'], - ㅚ: ['ㅗ', 'ㅣ'], - ㅝ: ['ㅜ', 'ㅓ'], - ㅞ: ['ㅜ', 'ㅔ'], - ㅟ: ['ㅜ', 'ㅣ'], - ㅢ: ['ㅡ', 'ㅣ'], - ㅥ: ['ㄴ', 'ㄴ'], - ㅦ: ['ㄴ', 'ㄷ'], - ㅧ: ['ㄴ', 'ㅅ'], - ㅨ: ['ㄴ', 'ㅿ'], - ㅩ: ['ㄹ', 'ㄱ', 'ㅅ'], - ㅪ: ['ㄹ', 'ㄷ'], - ㅫ: ['ㄹ', 'ㅂ', 'ㅅ'], - ㅬ: ['ㄹ', 'ㅿ'], - ㅭ: ['ㄹ', 'ㆆ'], - ㅮ: ['ㅁ', 'ㅂ'], - ㅯ: ['ㅁ', 'ㅅ'], - ㅰ: ['ㅁ', 'ㅿ'], - ㅲ: ['ㅂ', 'ㄱ'], - ㅳ: ['ㅂ', 'ㄷ'], - ㅴ: ['ㅂ', 'ㅅ', 'ㄱ'], - ㅵ: ['ㅂ', 'ㅅ', 'ㄷ'], - ㅶ: ['ㅂ', 'ㅈ'], - ㅷ: ['ㅂ', 'ㅌ'], - ㅺ: ['ㅅ', 'ㄱ'], - ㅻ: ['ㅅ', 'ㄴ'], - ㅼ: ['ㅅ', 'ㄷ'], - ㅽ: ['ㅅ', 'ㅂ'], - ㅾ: ['ㅅ', 'ㅈ'], - ㆀ: ['ㅇ', 'ㅇ'], - ㆂ: ['ㆁ', 'ㅅ'], - ㆃ: ['ㆁ', 'ㅿ'], - ㆅ: ['ㅎ', 'ㅎ'], - ㆇ: ['ㅛ', 'ㅑ'], - ㆈ: ['ㅛ', 'ㅒ'], - ㆉ: ['ㅛ', 'ㅣ'], - ㆊ: ['ㅠ', 'ㅕ'], - ㆋ: ['ㅠ', 'ㅖ'], - ㆌ: ['ㅠ', 'ㅣ'], - ㆎ: ['ㆍ', 'ㅣ'], - }; - const complex = { - ㄲ: 1, - ㄳ: 1, - ㄵ: 1, - ㄶ: 1, - ㄸ: 1, - ㄺ: 1, - ㄻ: 1, - ㄼ: 1, - ㄽ: 1, - ㄾ: 1, - ㄿ: 1, - ㅀ: 1, - ㅃ: 1, - ㅄ: 1, - ㅆ: 1, - ㅉ: 1, - ㅘ: 1, - ㅙ: 1, - ㅚ: 1, - ㅝ: 1, - ㅞ: 1, - ㅟ: 1, - ㅢ: 1, - }; - const irregularComplex = { - ㅥ: 1, - ㅦ: 1, - ㅧ: 1, - ㅨ: 1, - ㅩ: 1, - ㅪ: 1, - ㅫ: 1, - ㅬ: 1, - ㅭ: 1, - ㅮ: 1, - ㅯ: 1, - ㅰ: 1, - ㅱ: 1, - ㅲ: 1, - ㅳ: 1, - ㅴ: 1, - ㅵ: 1, - ㅶ: 1, - ㅷ: 1, - }; - const complexList = Object.assign({}, complex, irregularComplex); - // yes, I know that this is not a list. - const stronger = { - ㄱ: 'ㄲ', - ㅋ: 'ㄲ', - ㄷ: 'ㄸ', - ㅌ: 'ㄸ', - ㅂ: 'ㅃ', - ㅍ: 'ㅃ', - ㅅ: 'ㅆ', - ㅈ: 'ㅉ', - ㅊ: 'ㅉ', - }; - // I would add a weaker export - // except that I can't reverse the outputs - - const cho$1 = [ - 'ㄱ', 'ㄲ', 'ㄴ', 'ㄷ', 'ㄸ', 'ㄹ', 'ㅁ', - 'ㅂ', 'ㅃ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅉ', - 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ', - ]; - const jung$1 = [ - 'ㅏ', 'ㅐ', 'ㅑ', 'ㅒ', 'ㅓ', 'ㅔ', 'ㅕ', - 'ㅖ', 'ㅗ', 'ㅘ', 'ㅙ', 'ㅚ', 'ㅛ', 'ㅜ', - 'ㅝ', 'ㅞ', 'ㅟ', 'ㅠ', 'ㅡ', 'ㅢ', 'ㅣ', - ]; - const jong$1 = [ - null, 'ㄱ', 'ㄲ', 'ㄳ', 'ㄴ', 'ㄵ', 'ㄶ', - 'ㄷ', 'ㄹ', 'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', - 'ㄿ', 'ㅀ', 'ㅁ', 'ㅂ', 'ㅄ', 'ㅅ', 'ㅆ', - 'ㅇ', 'ㅈ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ', - ]; - const choNum = { - ㄱ: 0, - ㄲ: 1, - ㄴ: 2, - ㄷ: 3, - ㄸ: 4, - ㄹ: 5, - ㅁ: 6, - ㅂ: 7, - ㅃ: 8, - ㅅ: 9, - ㅆ: 10, - ㅇ: 11, - ㅈ: 12, - ㅉ: 13, - ㅊ: 14, - ㅋ: 15, - ㅌ: 16, - ㅍ: 17, - ㅎ: 18, - }; - const jungNum = { - ㅏ: 0, - ㅐ: 1, - ㅑ: 2, - ㅒ: 3, - ㅓ: 4, - ㅔ: 5, - ㅕ: 6, - ㅖ: 7, - ㅗ: 8, - ㅘ: 9, - ㅙ: 10, - ㅚ: 11, - ㅛ: 12, - ㅜ: 13, - ㅝ: 14, - ㅞ: 15, - ㅟ: 16, - ㅠ: 17, - ㅡ: 18, - ㅢ: 19, - ㅣ: 20, - }; - const jongNum = { - ㄱ: 1, - ㄲ: 2, - ㄳ: 3, - ㄴ: 4, - ㄵ: 5, - ㄶ: 6, - ㄷ: 7, - ㄹ: 8, - ㄺ: 9, - ㄻ: 10, - ㄼ: 11, - ㄽ: 12, - ㄾ: 13, - ㄿ: 14, - ㅀ: 15, - ㅁ: 16, - ㅂ: 17, - ㅄ: 18, - ㅅ: 19, - ㅆ: 20, - ㅇ: 21, - ㅈ: 22, - ㅊ: 23, - ㅋ: 24, - ㅌ: 25, - ㅍ: 26, - ㅎ: 27, - }; - - class UnicodeRange { - constructor(start, end) { - this.start = start; - this.end = end; - } - - containsCodePoint(num) { - return num >= this.start && num <= this.end; - } - - contains(char) { - return this.containsCodePoint(char.codePointAt(0)); - } - } - class CombinedRange { - constructor(ranges, codePoints = {}) { - this.ranges = ranges; - this.codePoints = codePoints; - } - - containsCodePoint(num) { - return ( - (this.codePoints && this.codePoints[num]) - || this.ranges.some(range => range.containsCodePoint(num)) - ); - } - - contains(char) { - const num = char.codePointAt(0); - return this.containsCodePoint(num); - } - } - - const jamo = new UnicodeRange(0x1100, 0x11FF); - const compatibilityJamo = new UnicodeRange(0x3130, 0x318F); - const jamoExtendedA = new UnicodeRange(0xA960, 0xA97F); - const syllables = new UnicodeRange(0xAC00, 0xD7AF); - const jamoExtendedB = new UnicodeRange(0xD7B0, 0xD7FF); - const halfwidth = new UnicodeRange(0xFFA0, 0xFFDF); - const reserved = new CombinedRange([ - new UnicodeRange(0xA97D, 0xA97F), // jamoExtendedA - new UnicodeRange(0xD7A4, 0xD7AF), // syllables - new UnicodeRange(0xD7C7, 0xD7CA), // jamoExtendedB - new UnicodeRange(0xD7FC, 0xD7FF), // jamoExtendedB - ], { 0x3130: 1, 0x318F: 1 }); - const standardHangul = new CombinedRange([compatibilityJamo, syllables]); - const hangul = new CombinedRange([ - jamo, - compatibilityJamo, - jamoExtendedA, - syllables, - jamoExtendedB, - halfwidth, - reserved, - ]); - - var composeSyllable = ((cho, jung, jong = 0) => ( - String.fromCodePoint(cho * 588 + jung * 28 + jong + syllables.start) - // this is the actual function that makes unicode syllable characters - // where the characters are mapped to numbers. Take a look at - // { choNum, jungNum, jongNum } from './unicode/syllable' - )); - - class Result { - constructor(result = '', remainder = []) { - this.result = result; - this.remainder = remainder; - } - } - - const Character = (val) => { - const str = `${val}`; - // not using .toString because Symbol.toPrimitive overrides when present - if (str.length !== 1) { - throw Error(`"${str}" is not a Character!`); - } - return str; - }; - // this function turns values into characters if it can - // otherwise it just fails - const ENOARYLIKE = () => { throw TypeError('The data must be an Array or a String!'); }; - const toArray = aryOrStr => (Array.isArray(aryOrStr) ? aryOrStr : aryOrStr.split('')); - // as a general note, calling .split like that instead of .split`` is faster - const isCharacterGroup = (val) => { - if (val.length < 1) { - return false; - } if (Array.isArray(val)) { - if (val.length > 1) { - return true; - } - return isCharacterGroup(val[0]); - } if (typeof val === 'string' && val.length > 1) { - return true; - } - return false; - }; - // while Characters can be a CharacterGroup, - // this function ignores characters - const identity = i => i; - const deepMap = (data, func, useToArray) => { - const modifier = useToArray ? toArray : identity; - if (Array.isArray(data)) { - return data.map(val => (isCharacterGroup(val) ? deepMap(val, func, useToArray) : modifier(func(val)))); - } if (typeof data === 'string') { - // since the data was a string, the array created from - // the string won't contain any character groups - return data.split('').map(char => modifier(func(char))); - } - ENOARYLIKE(); - }; - const deepFlatMap = (data, func) => { - let res = ''; - if (Array.isArray(data)) { - const len = data.length; - for (let i = 0; i < len; i++) { - // for is faster than forEach - // this function is used a lot so I'll - // take any optimization that I can get - const val = data[i]; - if (isCharacterGroup(val)) { - res += deepFlatMap(val, func); - } else { - const recurseRes = func(val); - if (isCharacterGroup(recurseRes)) { - res += deepFlatMap(recurseRes, identity); - } else { - res += recurseRes; - } - } - } - } else if (typeof data === 'string') { - const len = data.length; - for (let i = 0; i < len; i++) { - const recurseRes = func(data[i]); - if (isCharacterGroup(recurseRes)) { - res += deepFlatMap(recurseRes, identity); - } else { - res += recurseRes; - } - } - } else { - ENOARYLIKE(); - } - return res; - }; - const flatten = (data) => { - if (Array.isArray(data)) { - let res = ''; - const len = data.length; - for (let i = 0; i < len; i++) { - const val = data[i]; - if (isCharacterGroup(val)) { - res += flatten(val); - } else { - res += val; - } - } - return res; - } if (typeof data === 'string') { - return data; - } - ENOARYLIKE(); - }; - const deepFlatResMap = (data, func) => { - // this is different since it deals with functions that return Result objects. - // consumeLeftovers - let rem; - // remaining - let res = ''; - // result - if (Array.isArray(data)) { - rem = []; - const len = data.length; - for (let i = 0; i < len; i++) { - const val = data[i]; - if (isCharacterGroup(val)) { - rem.push(...deepFlatResMap(val, func)); - // deepFlatResMap always returns an array - // (or at least it should) - } else { - rem.push(val); - } - } - } else if (typeof data === 'string') { - rem = data.split(''); - // could have used toArray but since we already know - // the type of this, there's no need to - } else { - // it's not an Array or a String - ENOARYLIKE(); - } - while (rem.length) { - const comp = func(rem); - // func needs to return a Result like interface for this to work - // otherwise we'll get a really nasty to debug error - res += comp.result; - rem = comp.remainder; - } - return res; - }; - - // important note! - // these functions aren't going to really make any sense until - // you understand how they work in conjunction with the stuff - // that's in './types'. Read './Result' and './types' first. - // then read this. - const objCache = []; - const useComp3 = 0b001; - const useArchaic = 0b010; - const noUseJungJong = 0b100; - const noCompDouble = 0b1000; - const composeComplexBase = (mode) => { - // mode is being used as a bitfield - if (mode < 0 || mode > 8) { - throw Error('The mode cannot be less than zero or greater than eight!'); - } - const usingArchaic = mode & useArchaic; - const usingComp3 = usingArchaic && mode & useComp3; - const usingNoCompDouble = mode & noCompDouble; - let obj = objCache[mode]; - if (!obj) { - const objs = [cho]; - // there are no comp3 values in non archaic complex objects - if (!(mode & noUseJungJong)) { - // if you're usingJungJong - objs.push(jung, jong); - } if (usingArchaic) { - objs.push(archaic); - } - obj = Object.assign({}, ...objs); - objCache[mode] = obj; - // eslint got mad at me for chaining assignments - } - return (chars) => { - const len = chars.length; - if (len < 1) { - throw Error('Cannot compose array of zero characters!'); - } - const char1 = chars[0]; - if (len < 2) { - // if there aren't even two Characters to use - return new Result(char1); - } - const char2 = chars[1]; - if (usingNoCompDouble && char1 === char2) { - return new Result(char1, chars.slice(1)); - } - const comp2 = obj[char1 + char2]; - // comp2 = composition of 2 characters - if (comp2) { - if (usingComp3 && len > 2) { - // if there's more data, try to compose a tripple - const comp3 = obj[char1 + char2 + chars[2]]; - if (comp3) { - return new Result(comp3, chars.slice(3)); - } - } - // there's no more data or couldn't find a comp3 - return new Result(comp2, chars.slice(2)); - } - // couldn't find a comp2 - return new Result(char1, chars.slice(1)); - }; - }; - const composeComplex = (mode) => { - const cc = composeComplexBase(mode); - return ary => deepFlatResMap(ary, cc); - }; - const isVowel = char => char && char !== 'ㆍ' && vowels[char]; - var composeAnything = ((mode) => { - const cc = composeComplexBase(mode); - return (ary) => { - // while this function is named "composeSyllable", it actually - // can be used to compose anything, really. - if (ary.length < 2) { - return new Result(ary[0]); - // don't do extra computing for small operations - } - // the composeComplex function with the mode that is specified - const choRes = cc(ary); - // ^^ that's a Result object - const choChar = choRes.result; - // the result of the composition, should be a Character - const choRem = choRes.remainder; - // the remainder of the composition - const cho$$1 = choNum[choChar]; - // the number that the character is mapped to - if (choRem.length < 1 || !Number.isInteger(cho$$1)) { - // check if there's any more characters remaining - // also check if it's not an integer since 0 == false - // if it's not an integer, then return the potential - // complex or Character that was made from composeAnyComplex - return choRes; - // choRes is already a Result so no need to make another - } - const jungRes = cc(choRem); - - const jungChar = jungRes.result; - const jungRem = jungRes.remainder; - const jung$$1 = jungNum[jungChar]; - if (!Number.isInteger(jung$$1)) { - // there's no need to check to see if there's any more - // remaining since cho and jung are all that's needed - // to compose a syllable - return new Result(choChar, [jungChar, ...jungRem]); - // still only return choChar as a result since we want - // to try starting a syllable off with the jungChar next - // time this function is called - } if (jungRem.length) { - // there's no point in trying to add anything on to the complex - // if there aren't any characters left - if (!isVowel(jungRem[1])) { - // we need this part so that - // ㅁㅣㅇㅏ => 미아 - const jongRes = cc(jungRem); - - const jongChar = jongRes.result; - const jongRem = jongRes.remainder; - const jong$$1 = jongNum[jongChar]; - if (jong$$1) { - // if the character after the syllable is not a vowel - // and the jong character is valid - return new Result(composeSyllable(cho$$1, jung$$1, jong$$1), jongRem); - } - } - } - // there aren't any characters left - // or the character after the syllable is a vowel - // or the jong character isn't valid - return new Result(composeSyllable(cho$$1, jung$$1), jungRem); - // The last argument is optional for the Result constructor - }; - }); - - // if you're gonna copy this part, at least give me credit. - // I had to do all of this manually. - // also, I think turning all of these arrays into strings - // might speed up composition by a bit. - const jamo$1 = { - ᄀ: 'ㄱ', - ᄁ: ['ㄱ', 'ㄱ'], - ᄂ: 'ㄴ', - ᄃ: 'ㄷ', - ᄄ: ['ㄷ', 'ㄷ'], - ᄅ: 'ㄹ', - ᄆ: 'ㅁ', - ᄇ: 'ㅂ', - ᄈ: ['ㅂ', 'ㅂ'], - ᄉ: 'ㅅ', - ᄊ: ['ㅅ', 'ㅅ'], - ᄋ: 'ㅇ', - ᄌ: 'ㅈ', - ᄍ: ['ㅈ', 'ㅈ'], - ᄎ: 'ㅊ', - ᄏ: 'ㅋ', - ᄐ: 'ㅌ', - ᄑ: 'ㅍ', - ᄒ: 'ㅎ', - ᄓ: ['ㄴ', 'ㄱ'], - ᄔ: ['ㄴ', 'ㄴ'], - ᄕ: ['ㄴ', 'ㄷ'], - ᄖ: ['ㄴ', 'ㅂ'], - ᄗ: ['ㄷ', 'ㄱ'], - ᄘ: ['ㄹ', 'ㄴ'], - ᄙ: ['ㄹ', 'ㄹ'], - ᄚ: ['ㄹ', 'ㅎ'], - ᄛ: ['ㄹ', 'ㅇ'], - ᄜ: ['ㅁ', 'ㅂ'], - ᄝ: 'ㅱ', - ᄞ: ['ㅂ', 'ㄱ'], - ᄟ: ['ㅂ', 'ㄴ'], - ᄠ: ['ㅂ', 'ㄷ'], - ᄡ: ['ㅂ', 'ㅅ'], - ᄢ: ['ㅂ', 'ㅅ', 'ㄱ'], - ᄣ: ['ㅂ', 'ㅅ', 'ㄷ'], - ᄤ: ['ㅂ', 'ㅅ', 'ㅂ'], - ᄥ: ['ㅂ', 'ㅅ', 'ㅅ'], - ᄦ: ['ㅂ', 'ㅅ', 'ㅈ'], - ᄧ: ['ㅂ', 'ㅈ'], - ᄨ: ['ㅂ', 'ㅊ'], - ᄩ: ['ㅂ', 'ㅌ'], - ᄪ: ['ㅂ', 'ㅍ'], - ᄫ: ['ㅂ', 'ㅇ'], - ᄬ: [['ㅂ', 'ㅂ'], 'ㅇ'], - ᄭ: ['ㅅ', 'ㄱ'], - ᄮ: ['ㅅ', 'ㄴ'], - ᄯ: ['ㅅ', 'ㄷ'], - ᄰ: ['ㅅ', 'ㄹ'], - ᄱ: ['ㅅ', 'ㅁ'], - ᄲ: ['ㅅ', 'ㅂ'], - ᄳ: ['ㅅ', 'ㅂ', 'ㄱ'], - ᄴ: ['ㅅ', 'ㅅ', 'ㅅ'], - ᄵ: ['ㅅ', 'ㅇ'], - ᄶ: ['ㅅ', 'ㅈ'], - ᄷ: ['ㅅ', 'ㅊ'], - ᄸ: ['ㅅ', 'ㅋ'], - ᄹ: ['ㅅ', 'ㅌ'], - ᄺ: ['ㅅ', 'ㅍ'], - ᄻ: ['ㅅ', 'ㅎ'], - ᄼ: null, - ᄽ: null, - ᄾ: null, - ᄿ: null, - ᅀ: 'ㅿ', - ᅁ: ['ㅇ', 'ㄱ'], - ᅂ: ['ㅇ', 'ㄷ'], - ᅃ: ['ㅇ', 'ㅁ'], - ᅄ: ['ㅇ', 'ㅂ'], - ᅅ: ['ㅇ', 'ㅅ'], - ᅆ: ['ㅇ', 'ㅿ'], - ᅇ: ['ㅇ', 'ㅇ'], - ᅈ: ['ㅇ', 'ㅈ'], - ᅉ: ['ㅇ', 'ㅊ'], - ᅊ: ['ㅇ', 'ㅌ'], - ᅋ: ['ㅇ', 'ㅍ'], - ᅌ: 'ㆁ', - ᅍ: ['ㅈ', 'ㅇ'], - ᅎ: null, - ᅏ: null, - ᅐ: null, - ᅑ: null, - ᅒ: ['ㅊ', 'ㅋ'], - ᅓ: ['ㅊ', 'ㅎ'], - ᅔ: null, - ᅕ: null, - ᅖ: ['ㅍ', 'ㅂ'], - ᅗ: 'ㆄ', - ᅘ: ['ㅎ', 'ㅎ'], - ᅙ: 'ㆆ', - ᅚ: ['ㄱ', 'ㄷ'], - ᅛ: ['ㄱ', 'ㅅ'], - ᅜ: ['ㄱ', 'ㅈ'], - ᅝ: ['ㄱ', 'ㅎ'], - ᅞ: ['ㄷ', 'ㄹ'], - ᅡ: 'ㅏ', - ᅢ: 'ㅐ', - ᅣ: 'ㅑ', - ᅤ: 'ㅒ', - ᅥ: 'ㅓ', - ᅦ: 'ㅔ', - ᅧ: 'ㅕ', - ᅨ: 'ㅖ', - ᅩ: 'ㅗ', - ᅪ: ['ㅗ', 'ㅏ'], - ᅫ: ['ㅗ', 'ㅐ'], - ᅬ: ['ㅗ', 'ㅣ'], - ᅭ: 'ㅛ', - ᅮ: 'ㅜ', - ᅯ: ['ㅜ', 'ㅓ'], - ᅰ: ['ㅜ', 'ㅔ'], - ᅱ: ['ㅜ', 'ㅣ'], - ᅲ: 'ㅠ', - ᅳ: 'ㅡ', - ᅴ: ['ㅡ', 'ㅣ'], - ᅵ: 'ㅣ', - ᅶ: ['ㅏ', 'ㅗ'], - ᅷ: ['ㅏ', 'ㅜ'], - ᅸ: ['ㅑ', 'ㅗ'], - ᅹ: ['ㅑ', 'ㅛ'], - ᅺ: ['ㅓ', 'ㅗ'], - ᅻ: ['ㅓ', 'ㅜ'], - ᅼ: ['ㅓ', 'ㅡ'], - ᅽ: ['ㅕ', 'ㅗ'], - ᅾ: ['ㅕ', 'ㅜ'], - ᅿ: ['ㅗ', 'ㅓ'], - ᆀ: ['ㅔ', 'ㅗ'], - ᆁ: ['ㅖ', 'ㅗ'], - ᆂ: ['ㅗ', 'ㅗ'], - ᆃ: ['ㅗ', 'ㅜ'], - ᆄ: ['ㅛ', 'ㅑ'], - ᆅ: ['ㅛ', 'ㅒ'], - ᆆ: ['ㅛ', 'ㅕ'], - ᆇ: ['ㅛ', 'ㅗ'], - ᆈ: ['ㅛ', 'ㅣ'], - ᆉ: ['ㅜ', 'ㅏ'], - ᆊ: ['ㅜ', 'ㅐ'], - ᆋ: ['ㅜ', 'ㅓ', 'ㅡ'], - ᆌ: ['ㅜ', 'ㅖ'], - ᆍ: ['ㅜ', 'ㅜ'], - ᆎ: ['ㅠ', 'ㅏ'], - ᆏ: ['ㅠ', 'ㅓ'], - ᆐ: ['ㅠ', 'ㅔ'], - ᆑ: ['ㅠ', 'ㅕ'], - ᆒ: ['ㅠ', 'ㅔ'], - ᆓ: ['ㅠ', 'ㅜ'], - ᆔ: ['ㅠ', 'ㅣ'], - ᆕ: ['ㅡ', 'ㅜ'], - ᆖ: ['ㅡ', 'ㅡ'], - ᆗ: ['ㅡ', 'ㅣ', 'ㅜ'], - ᆘ: ['ㅣ', 'ㅏ'], - ᆙ: ['ㅣ', 'ㅑ'], - ᆚ: ['ㅣ', 'ㅗ'], - ᆛ: ['ㅣ', 'ㅜ'], - ᆜ: ['ㅣ', 'ㅡ'], - ᆝ: null, - ᆞ: 'ㆍ', - ᆟ: ['ㆍ', 'ㅓ'], - ᆠ: ['ㆍ', 'ㅜ'], - ᆡ: ['ㆍ', 'ㅣ'], - ᆢ: ['ㆍ', 'ㆍ'], - ᆣ: ['ㅏ', 'ㅡ'], - ᆤ: ['ㅑ', 'ㅜ'], - ᆥ: ['ㅕ', 'ㅑ'], - ᆦ: ['ㅗ', 'ㅑ'], - ᆧ: ['ㅗ', 'ㅒ'], - ᆨ: 'ㄱ', - ᆩ: ['ㄱ', 'ㄱ'], - ᆪ: ['ㄱ', 'ㅅ'], - ᆫ: 'ㄴ', - ᆬ: ['ㄴ', 'ㅈ'], - ᆭ: ['ㄴ', 'ㅎ'], - ᆮ: 'ㄷ', - ᆯ: 'ㄹ', - ᆰ: ['ㄹ', 'ㄱ'], - ᆱ: ['ㄹ', 'ㅁ'], - ᆲ: ['ㄹ', 'ㅂ'], - ᆳ: ['ㄹ', 'ㅅ'], - ᆴ: ['ㄹ', 'ㅌ'], - ᆵ: ['ㄹ', 'ㅍ'], - ᆶ: ['ㄹ', 'ㅎ'], - ᆷ: 'ㅁ', - ᆸ: 'ㅂ', - ᆹ: ['ㅂ', 'ㅅ'], - ᆺ: 'ㅅ', - ᆻ: ['ㅅ', 'ㅅ'], - ᆼ: 'ㅇ', - ᆽ: 'ㅈ', - ᆾ: 'ㅊ', - ᆿ: 'ㅋ', - ᇀ: 'ㅌ', - ᇁ: 'ㅍ', - ᇂ: 'ㅎ', - ᇃ: ['ㄱ', 'ㄹ'], - ᇄ: ['ㄱ', 'ㅅ', 'ㄱ'], - ᇅ: ['ㄴ', 'ㄱ'], - ᇆ: ['ㄴ', 'ㄷ'], - ᇇ: ['ㄴ', 'ㅅ'], - ᇈ: ['ㄴ', 'ㅿ'], - ᇉ: ['ㄴ', 'ㅌ'], - ᇊ: ['ㄷ', 'ㄱ'], - ᇋ: ['ㄷ', 'ㄹ'], - ᇌ: ['ㄹ', 'ㄱ', 'ㅅ'], - ᇍ: ['ㄹ', 'ㄴ'], - ᇎ: ['ㄹ', 'ㄷ'], - ᇏ: ['ㄹ', 'ㄷ', 'ㅎ'], - ᇐ: ['ㄹ', 'ㄹ'], - ᇑ: ['ㄹ', 'ㅁ', 'ㄱ'], - ᇒ: ['ㄹ', 'ㅁ', 'ㅅ'], - ᇓ: ['ㄹ', 'ㅂ', 'ㅅ'], - ᇔ: ['ㄹ', 'ㅂ', 'ㅎ'], - ᇕ: ['ㄹ', 'ㅸ'], - ᇖ: ['ㄹ', 'ㅅ', 'ㅅ'], - ᇗ: ['ㄹ', 'ㅿ'], - ᇘ: ['ㄹ', 'ㅋ'], - ᇙ: ['ㄹ', 'ㆆ'], - ᇚ: ['ㅁ', 'ㄱ'], - ᇛ: ['ㅁ', 'ㄹ'], - ᇜ: ['ㅁ', 'ㅂ'], - ᇝ: ['ㅁ', 'ㅅ'], - ᇞ: ['ㅁ', 'ㅅ', 'ㅅ'], - ᇟ: ['ㅁ', 'ㅿ'], - ᇠ: ['ㅁ', 'ㅊ'], - ᇡ: ['ㅁ', 'ㅎ'], - ᇢ: 'ㅱ', - ᇣ: ['ㅂ', 'ㄹ'], - ᇤ: ['ㅂ', 'ㅍ'], - ᇥ: ['ㅂ', 'ㅎ'], - ᇦ: ['ㅂ', 'ㅇ'], - ᇧ: ['ㅅ', 'ㄱ'], - ᇨ: ['ㅅ', 'ㄷ'], - ᇩ: ['ㅅ', 'ㄹ'], - ᇪ: ['ㅅ', 'ㅂ'], - ᇫ: 'ㅿ', - ᇬ: ['ㆁ', 'ㄱ'], - ᇭ: ['ㆁ', 'ㄱ', 'ㄱ'], - ᇮ: ['ㆁ', 'ㆁ'], - ᇯ: ['ㆁ', 'ㅋ'], - ᇰ: 'ㆁ', - ᇱ: ['ㆁ', 'ㅅ'], - ᇲ: ['ㆁ', 'ㅿ'], - ᇳ: ['ㅍ', 'ㅂ'], - ᇴ: 'ㆄ', - ᇵ: ['ㅎ', 'ㄴ'], - ᇶ: ['ㅎ', 'ㄹ'], - ᇷ: ['ㅎ', 'ㅁ'], - ᇸ: ['ㅎ', 'ㅂ'], - ᇹ: 'ㆆ', - ᇺ: ['ㄱ', 'ㄴ'], - ᇻ: ['ㄱ', 'ㅂ'], - ᇼ: ['ㄱ', 'ㅊ'], - ᇽ: ['ㄱ', 'ㅋ'], - ᇾ: ['ㄱ', 'ㅎ'], - ᇿ: ['ㄴ', 'ㄴ'], - }; - const jamoExtendedA$1 = { - ꥠ: ['ㄷ', 'ㅁ'], - ꥡ: ['ㄷ', 'ㅂ'], - ꥢ: ['ㄷ', 'ㅅ'], - ꥣ: ['ㄷ', 'ㅈ'], - ꥤ: ['ㄹ', 'ㄱ'], - ꥥ: ['ㄹ', 'ㄱ', 'ㄱ'], - ꥦ: ['ㄹ', 'ㄷ'], - ꥧ: ['ㄹ', 'ㄷ', 'ㄷ'], - ꥨ: ['ㄹ', 'ㅁ'], - ꥩ: ['ㄹ', 'ㅂ'], - ꥪ: ['ㄹ', 'ㅂ', 'ㅂ'], - ꥫ: ['ㄹ', 'ㅸ'], - ꥬ: ['ㄹ', 'ㅅ'], - ꥭ: ['ㄹ', 'ㅈ'], - ꥮ: ['ㄹ', 'ㅋ'], - ꥯ: ['ㅁ', 'ㄱ'], - ꥰ: ['ㅁ', 'ㄷ'], - ꥱ: ['ㅁ', 'ㅅ'], - ꥲ: ['ㅂ', 'ㅅ', 'ㅌ'], - ꥳ: ['ㅂ', 'ㅋ'], - ꥴ: ['ㅂ', 'ㅎ'], - ꥵ: ['ㅅ', 'ㅅ', 'ㅂ'], - ꥶ: ['ㅇ', 'ㄹ'], - ꥷ: ['ㅇ', 'ㅎ'], - ꥸ: ['ㅈ', 'ㅈ', 'ㅎ'], - ꥹ: ['ㅌ', 'ㅌ'], - ꥺ: ['ㅍ', 'ㅎ'], - ꥻ: ['ㅎ', 'ㅅ'], - ꥼ: ['ㆆ', 'ㆆ'], - }; - const jamoExtendedB$1 = { - ힰ: ['ㅗ', 'ㅕ'], - ힱ: ['ㅗ', 'ㅗ', 'ㅣ'], - ힲ: ['ㅛ', 'ㅏ'], - ힳ: ['ㅛ', 'ㅐ'], - ힴ: ['ㅛ', 'ㅓ'], - ힵ: ['ㅜ', 'ㅕ'], - ힶ: ['ㅜ', 'ㅣ', 'ㅣ'], - ힷ: ['ㅠ', 'ㅐ'], - ힸ: ['ㅠ', 'ㅗ'], - ힹ: ['ㅡ', 'ㅏ'], - ힺ: ['ㅡ', 'ㅓ'], - ힻ: ['ㅡ', 'ㅔ'], - ힼ: ['ㅡ', 'ㅗ'], - ힽ: ['ㅣ', 'ㅏ', 'ㅗ'], - ힾ: ['ㅣ', 'ㅒ'], - ힿ: ['ㅣ', 'ㅕ'], - ퟀ: ['ㅣ', 'ㅖ'], - ퟁ: ['ㅣ', 'ㅗ', 'ㅣ'], - ퟂ: ['ㅣ', 'ㅛ'], - ퟃ: ['ㅣ', 'ㅠ'], - ퟄ: ['ㅣ', 'ㅣ'], - ퟅ: ['ㆍ', 'ㅏ'], - ퟆ: ['ㆍ', 'ㅔ'], - ퟋ: ['ㄴ', 'ㄹ'], - ퟌ: ['ㄴ', 'ㅈ'], - ퟍ: ['ㄷ', 'ㄷ'], - ퟎ: ['ㄷ', 'ㄷ', 'ㅂ'], - ퟏ: ['ㄷ', 'ㅂ'], - ퟐ: ['ㄷ', 'ㅅ'], - ퟑ: ['ㄷ', 'ㅅ', 'ㄱ'], - ퟒ: ['ㄷ', 'ㅈ'], - ퟓ: ['ㄷ', 'ㅊ'], - ퟔ: ['ㄷ', 'ㅌ'], - ퟕ: ['ㄹ', 'ㄱ', 'ㄱ'], - ퟖ: ['ㄹ', 'ㄱ', 'ㅎ'], - ퟗ: ['ㄹ', 'ㄹ', 'ㅋ'], - ퟘ: ['ㄹ', 'ㅁ', 'ㅎ'], - ퟙ: ['ㄹ', 'ㅂ', 'ㄷ'], - ퟚ: ['ㄹ', 'ㅂ', 'ㅍ'], - ퟛ: ['ㄹ', 'ㆁ'], - ퟜ: ['ㄹ', 'ㆆ', 'ㅎ'], - ퟝ: null, - ퟞ: ['ㅁ', 'ㄴ'], - ퟟ: ['ㅁ', 'ㄴ', 'ㄴ'], - ퟠ: ['ㅁ', 'ㅁ'], - ퟡ: ['ㅁ', 'ㅂ', 'ㅅ'], - ퟢ: ['ㅁ', 'ㅈ'], - ퟣ: ['ㅂ', 'ㄷ'], - ퟤ: ['ㅂ', 'ㄹ', 'ㅍ'], - ퟥ: ['ㅂ', 'ㅁ'], - ퟦ: ['ㅂ', 'ㅂ'], - ퟧ: ['ㅂ', 'ㅅ', 'ㄷ'], - ퟨ: ['ㅂ', 'ㅈ'], - ퟩ: ['ㅂ', 'ㅊ'], - ퟪ: ['ㅅ', 'ㅁ'], - ퟫ: ['ㅅ', 'ㅸ'], - ퟬ: ['ㅅ', 'ㅅ', 'ㄱ'], - ퟭ: ['ㅅ', 'ㅅ', 'ㄷ'], - ퟮ: ['ㅅ', 'ㅿ'], - ퟯ: ['ㅅ', 'ㅈ'], - ퟰ: ['ㅅ', 'ㅊ'], - ퟱ: ['ㅅ', 'ㅌ'], - ퟲ: ['ㅅ', 'ㅎ'], - ퟳ: ['ㅿ', 'ㅂ'], - ퟴ: ['ㅿ', 'ㅸ'], - ퟵ: ['ㆁ', 'ㅁ'], - ퟶ: ['ㆁ', 'ㅎ'], - ퟷ: ['ㅈ', 'ㅂ'], - ퟸ: ['ㅈ', 'ㅂ', 'ㅂ'], - ퟹ: ['ㅈ', 'ㅈ'], - ퟺ: ['ㅍ', 'ㅅ'], - ퟻ: ['ㅍ', 'ㅌ'], - }; - const halfwidth$1 = { - ᄀ: 'ㄱ', - ᄁ: ['ㄱ', 'ㄱ'], - ᆪ: ['ㄱ', 'ㅅ'], - ᄂ: 'ㄴ', - ᆬ: ['ㄴ', 'ㅈ'], - ᆭ: ['ㄴ', 'ㅎ'], - ᄃ: 'ㄷ', - ᄄ: ['ㄷ', 'ㄷ'], - ᄅ: 'ㄹ', - ᆰ: ['ㄹ', 'ㄱ'], - ᆱ: ['ㄹ', 'ㅁ'], - ᆲ: ['ㄹ', 'ㅂ'], - ᆳ: ['ㄹ', 'ㅅ'], - ᆴ: ['ㄹ', 'ㅌ'], - ᆵ: ['ㄹ', 'ㅍ'], - ᄚ: ['ㄹ', 'ㅎ'], - ᄆ: 'ㅁ', - ᄇ: 'ㅂ', - ᄈ: ['ㅂ', 'ㅂ'], - ᄡ: ['ㅂ', 'ㅅ'], - ᄉ: 'ㅅ', - ᄊ: ['ㅅ', 'ㅅ'], - ᄋ: 'ㅇ', - ᄌ: 'ㅈ', - ᄍ: ['ㅈ', 'ㅈ'], - ᄎ: 'ㅊ', - ᄏ: 'ㅋ', - ᄐ: 'ㅌ', - ᄑ: 'ㅍ', - ᄒ: 'ㅎ', - ᅡ: 'ㅏ', - ᅢ: 'ㅐ', - ᅣ: 'ㅑ', - ᅤ: 'ㅒ', - ᅥ: 'ㅓ', - ᅦ: 'ㅔ', - ᅧ: 'ㅕ', - ᅨ: 'ㅖ', - ᅩ: 'ㅗ', - ᅪ: ['ㅗ', 'ㅏ'], - ᅫ: ['ㅗ', 'ㅐ'], - ᅬ: ['ㅗ', 'ㅣ'], - ᅭ: 'ㅛ', - ᅮ: 'ㅜ', - ᅯ: ['ㅜ', 'ㅓ'], - ᅰ: ['ㅜ', 'ㅔ'], - ᅱ: ['ㅜ', 'ㅣ'], - ᅲ: 'ㅠ', - ᅳ: 'ㅡ', - ᅴ: ['ㅡ', 'ㅣ'], - ᅵ: 'ㅣ', - }; - const all = Object.assign({}, jamo$1, jamoExtendedA$1, jamoExtendedB$1, halfwidth$1); - - // tries to transform everything into disassembled standard hangul - - const transformChar = char => (!standardHangul.contains(char) && all[char]) || char; - const transformDatum = datum => transformChar(Character(datum)); - const transformEveryChar = char => ( - (standardHangul.contains(char) ? pairs : all)[char] - || char - ); - const transformEveryDatum = datum => transformEveryChar(Character(datum)); - // transform everything just means that it also transforms - // standard hangul characters instead of ignoring them - - // this way, we can trust the inputs to composeAnything - const assembleFactory = transformer => (data, mode) => deepFlatResMap(transformer(data), composeAnything(mode)); - // the transformer should verify that each datum is a Character! - const assembleTransformer = data => deepMap(data, transformEveryDatum); - // this takes a CharacterGroup and transforms characters and - // complex characters, effectively leaving behind only the - // base Characters - // it doesn't decomposeSyllables though - var assemble = (assembleFactory(assembleTransformer)); - - const composeComplexCho = composeComplex(noUseJungJong); - const transformExceptCho = (char) => { - const res = transformEveryChar(char); - if (Array.isArray(res)) { - const comp = composeComplexCho(res); - // the default composeComplex only composes cho - // HACK: this bug might be an issue with composeComplex - if (Array.isArray(comp) && comp.length === 1) { - // if the composition actually ends up composing - // something and it's only one Character, just - // return the Character instead of an Array - return Character(comp); - } - return comp; - } - return res; - }; - // this function is needed by disassemble so it's trusting - var decomposeComplex = ((datum, decomposeDoubles) => toArray((decomposeDoubles ? transformEveryChar : transformExceptCho)(Character(datum)))); - - const trustMe = (char) => { - const code = char.codePointAt(0) - syllables.start; - const jongNum$$1 = code % 28; - const q = (code - jongNum$$1) / 28; - const jungNum$$1 = q % 21; - const choNum$$1 = 0 | q / 21; // basically Math.floor(q / 21) - return [cho$1[choNum$$1], jung$1[jungNum$$1], jong$1[jongNum$$1]].filter(v => v); - // the .filter(v => v) removes blank space in the array - }; - var decomposeSyllable = ((datum, hardFail) => { - const char = Character(datum); - if (!syllables.contains(char)) { - if (hardFail) { - throw Error('Decomposing a syllable requires a syllable to decompose!'); - } - return [datum]; - // if there's no hardFail, the function must - // still return the same type as it would have - // if it didn't fail - } - return trustMe(char); - }); - - const disassembleFactory = transformer => (datum) => { - const char = Character(datum); - if (syllables.contains(char)) { - return trustMe(char).map(transformer); - // that .map(transformEverything) catches the complex - // characters that decomposeSyllable returns - } - // otherwise try breaking complex characters apart - return transformer(char); - }; - const disassembleAll = disassembleFactory(transformEveryChar); - const disassemble = disassembleFactory(transformExceptCho); - // not to be confused with Hangul.disassemble - // this disassemble takes Characters as inputs, not CharacterGroups - const disassembleChar = (datum, grouped, decomposeDoubles) => { - const res = (decomposeDoubles ? disassembleAll : disassemble)(datum); - if (!grouped) { - return flatten(res); - } - return res; - }; - var disassemble$1 = ((data, grouped, decomposeDoubles) => (grouped ? deepMap : deepFlatMap)(data, decomposeDoubles ? disassembleAll : disassemble, true)); - // I know this looks really bad since it's all on - // one line but ESlint was being really finicky - - var name = ((obj) => { - Object.keys(obj).forEach((key) => { - obj[key].displayName = key; - }); - }); - - // This file is only used in ../publicCompose - // all is the only one of these that's actually used - // I can't Object.assign them all together unfortunately - const all$1 = { - ㄱ: { - ㄱ: 'ㄲ', - ㅅ: 'ㄳ', - }, - ㄷ: { - ㄷ: 'ㄸ', - }, - ㅅ: { - ㅅ: 'ㅆ', - ㄱ: 'ㅺ', - ㄴ: 'ㅻ', - ㄷ: 'ㅼ', - ㅂ: 'ㅽ', - ㅈ: 'ㅾ', - }, - ㅈ: { - ㅈ: 'ㅉ', - }, - ㅂ: { - ㅂ: 'ㅃ', - ㅅ: { - $: 'ㅄ', - ㄱ: 'ㅴ', - ㄷ: 'ㅵ', - }, - ㄱ: 'ㅲ', - ㄷ: 'ㅳ', - ㅈ: 'ㅶ', - ㅌ: 'ㅷ', - }, - ㅗ: { - ㅏ: 'ㅘ', - ㅐ: 'ㅙ', - ㅣ: 'ㅚ', - }, - ㅜ: { - ㅓ: 'ㅝ', - ㅔ: 'ㅞ', - ㅣ: 'ㅟ', - }, - ㅡ: { - ㅣ: 'ㅢ', - }, - ㄴ: { - ㅈ: 'ㄵ', - ㅎ: 'ㄶ', - ㄴ: 'ㅥ', - ㄷ: 'ㅦ', - ㅅ: 'ㅧ', - ㅿ: 'ㅨ', - }, - ㄹ: { - ㄱ: { - $: 'ㄺ', - ㅅ: 'ㅩ', - }, - ㅁ: 'ㄻ', - ㅂ: { - $: 'ㄼ', - ㅅ: 'ㅫ', - }, - ㅅ: 'ㄽ', - ㅌ: 'ㄾ', - ㅍ: 'ㄿ', - ㅎ: 'ㅀ', - ㄷ: 'ㅪ', - ㅿ: 'ㅬ', - ㆆ: 'ㅭ', - }, - ㅁ: { - ㅂ: 'ㅮ', - ㅅ: 'ㅯ', - ㅿ: 'ㅰ', - }, - ㅇ: { - ㅇ: 'ㆀ', - }, - ㆁ: { - ㅅ: 'ㆁ', - ㅿ: 'ㅿ', - }, - ㅎ: { - ㅎ: 'ㆅ', - }, - ㅛ: { - ㅑ: 'ㆇ', - ㅒ: 'ㆈ', - ㅣ: 'ㆉ', - }, - ㅠ: { - ㅕ: 'ㆊ', - ㅖ: 'ㆋ', - ㅣ: 'ㆌ', - }, - ㆍ: { - ㅣ: 'ㆎ', - }, - }; - - const standardizeCharacterBase = (mode) => { - const cc = composeComplex(mode); - return (datum) => { - const res = transformDatum(datum); - if (Array.isArray(res)) { - // atempt compose only if the value is an array - // it's unfortunate, but any compFn is untrusting - // since it's basically accessed publicly - // we know that v will always have good types - // but compFn will still check for Characters - return cc(res); - // returns an Array - } - return res; - }; - }; - const standardizeFactory = ((mode) => { - const currentStandardize = standardizeCharacterBase(mode); - return (data, grouped) => (grouped ? deepMap : deepFlatMap)(data, currentStandardize); - }); - var standardize = ((data, grouped, mode) => standardizeFactory(mode)(data, grouped)); - - // since these functions are exposed, the characters must be - // standardized so that the libaray can function properly - const standardizeCharacter = standardizeCharacterBase(useComp3 | useArchaic); - const complex$1 = (first, second, third = '', hardFail) => { - if (first === undefined || second === undefined) { - throw Error('Cannot compose a complex with less than two values!'); - } - const d1 = all$1[standardizeCharacter(first)]; - // depth 1 - if (!d1) { - if (hardFail) { - throw Error(`There's no complex character that starts with ${first}`); - } - return `${first}${second}${third}`; - } - const d2 = d1[standardizeCharacter(second)]; - // depth 2 - if (!d2) { - if (hardFail) { - throw Error(`Cannot combine ${first} and ${second}`); - } - return `${first}${second}${third}`; - } - const d2val = d2.$ || d2; - if (third) { - // if there's a third character (optional) - const d3 = d2[standardizeCharacter(third)]; - // depth 3 - if (!d3) { - // if depth 3 doesn't exist - if (hardFail) { - throw Error(`Found ${d2val} but cannot combine ${first}, ${second}, and ${third}`); - // the reason for this ^^^ is because sometimes - // d2 is a string rather than an object - } - return `${d2val}${third}`; - // at depth three, there should be a complex formed from - // the first and second characters so return that instead - // of the inputs concatenated - } - return d3; // this should always be a string - } - // the third character was falsy so just return the composition - return d2val; - }; - // this function will always return a String or it'll error (hardFail) - // there's probably a better way to structure these if-statements - // so if anyone comes up with one, I'll take it - - const syllable = (choChar, jungChar = '', jongChar = '', hardFail) => { - const cho = choNum[standardizeCharacter(choChar)]; - const jung = jungNum[standardizeCharacter(jungChar)]; - let jong; - if (jongChar) { - jong = jongNum[standardizeCharacter(jongChar)]; - } if (!Number.isInteger(cho)) { - if (hardFail) { - throw Error(`"${choChar}" is not a valid cho Character`); - } - return `${choChar}${jungChar}${jongChar}`; - } if (!Number.isInteger(jung)) { - if (hardFail) { - throw Error(`"${jungChar}" is not a valid jung Character`); - } - return `${choChar}${jungChar}${jongChar}`; - } if (jongChar && !Number.isInteger(jong)) { - // check if it exists because !Number.isInteger(undefined) - // is true and we don't want that happening since jongChar - // is optional - if (hardFail) { - throw Error(`"${jongChar}" is not a valid jong character`); - } - // getting here means that the cho and jung - // characters were valid, so call composeSyllable - return `${composeSyllable(cho, jung)}${jongChar}`; - } - return composeSyllable(cho, jung, jong); - }; - // by nesting all if-statements under if (hardFail) - // there might be a little better performance but I'm - // sure that it's pretty trivial. - - const standardizeComp3Archaic = standardizeFactory(useComp3 | useArchaic); - // support all types of complex - var stronger$1 = (data => standardizeComp3Archaic(data).map(char => stronger[char] || char)); - - const hangulToKeyFn = char => hangulToKey[char] || char; - const keyToHangulFn = char => keyToHangul[char]; - const transformToKeys = (hangulChar) => { - const res = transformExceptCho(hangulChar); - return Array.isArray(res) ? res.map(hangulToKeyFn) : hangulToKeyFn(res); - }; - const disassembleToKeys = disassembleFactory(transformToKeys); - const toKeys = (data, grouped) => (grouped ? deepMap : deepFlatMap)(data, disassembleToKeys); - const transformCharToHangul = (latinDatum) => { - const latinChar = Character(latinDatum); - const res = keyToHangulFn(latinChar); - if (!res) { - // couldn't find a key for that characters - const lowerCaseRes = keyToHangulFn(latinChar.toLowerCase()); - if (!lowerCaseRes) { - return latinChar; - } - return lowerCaseRes; - } - return res; - }; - // it's okay that we're not standarizing because the data - // in hangulToKey is already standard :) - const transformToHangul = data => deepMap(data, transformCharToHangul); - const assembleFromKeys = assembleFactory(transformToHangul); - const fromKeys = data => assembleFromKeys(data, noCompDouble); - - var testMulti = (aryFnName => isFn => data => deepFlatMap(data, transformEveryDatum)[aryFnName](isFn)); - - var contains = (testMulti('some')); - - var is = (isFn => (datum) => { - const res = transformEveryDatum(datum); - // it's okay that we don't check if data is - // a Character since transformEveryCharacter does. - return Array.isArray(res) ? res.every(isFn) : isFn(res); - }); - - var isAll = (testMulti('every')); - - const consonant = char => consonants[char]; - const isConsonant = is(consonant); - const isConsonantAll = isAll(consonant); - const containsConsonant = contains(consonant); - name({ - isConsonant, - isConsonantAll, - containsConsonant, - }); - - const isAll$1 = testFn => (data) => { - const len = data.length; - if (Array.isArray(data)) { - for (let i = 0; i < len; i++) { - const val = data[i]; - if (isCharacterGroup(val) ? isAll$1(testFn)(val) : testFn(val)) { - continue; - } - // the loop will get here if it doesn't satisfy the testing function - return false; - } - return true; - } if (typeof data === 'string') { - for (let i = 0; i < len; i++) { - const val = data[i]; - if (testFn(val)) { - continue; - } - return false; - } - return true; - } - throw TypeError('The data must be an Array or a String!'); - }; - const contains$1 = testFn => (data) => { - const len = data.length; - if (Array.isArray(data)) { - for (let i = 0; i < len; i++) { - const val = data[i]; - if (isCharacterGroup(val) ? isAll$1(testFn)(val) : testFn(val)) { - return true; - // this allows the function to short circut - } - } - return false; - } if (typeof data === 'string') { - for (let i = 0; i < len; i++) { - const val = data[i]; - if (testFn(val)) { - return true; - } - } - return false; - } - throw TypeError('The data must be an Array or a String!'); - }; - - const isJamo = datum => jamo.contains(Character(datum)); - const isCompatibilityJamo = datum => compatibilityJamo.contains(Character(datum)); - const isJamoExtendedA = datum => jamoExtendedA.char(Character(datum)); - const isSyllable = datum => syllables.contains(Character(datum)); - const isJamoExtendedB = datum => jamoExtendedB.contains(Character(datum)); - const isHalfwidth = datum => halfwidth.contains(Character(datum)); - const isReserved = datum => reserved.contains(Character(datum)); - const isStandardHangul = datum => standardHangul.contains(Character(datum)); - const isHangul = datum => hangul.contains(Character(datum)); - - const isAllJamo = isAll$1(isJamo); - const containsJamo = contains$1(isJamo); - - const isAllCompatibilityJamo = isAll$1(isCompatibilityJamo); - const containsCompatibilityJamo = contains$1(isCompatibilityJamo); - - const isAllJamoExtendedA = isAll$1(isJamoExtendedA); - const containsJamoExtendedA = contains$1(isJamoExtendedA); - - const isAllSyllable = isAll$1(isSyllable); - const containsSyllable = contains$1(isSyllable); - - const isAllJamoExtendedB = isAll$1(isJamoExtendedB); - const containsJamoExtendedB = contains$1(isJamoExtendedB); - - const isAllHalfwidth = isAll$1(isHalfwidth); - const containsHalfwidth = contains$1(isHalfwidth); - - const isAllReserved = isAll$1(isReserved); - const containsReserved = contains$1(isReserved); - - const isAllStandardHangul = isAll$1(isStandardHangul); - const containsStandardHangul = contains$1(isStandardHangul); - - const isAllHangul = isAll$1(isHangul); - const containsHangul = contains$1(isHangul); - name({ - isJamo, - isAllJamo, - containsJamo, - - isCompatibilityJamo, - isAllCompatibilityJamo, - containsCompatibilityJamo, - - isJamoExtendedA, - isAllJamoExtendedA, - containsJamoExtendedA, - - isSyllable, - isAllSyllable, - containsSyllable, - - isJamoExtendedB, - isAllJamoExtendedB, - containsJamoExtendedB, - - isHalfwidth, - isAllHalfwidth, - containsHalfwidth, - - isReserved, - isAllReserved, - containsReserved, - - isStandardHangul, - isAllStandardHangul, - containsStandardHangul, - - isHangul, - isAllHangul, - containsHangul, - }); - - const vowel = char => vowels[char]; - const isVowel$1 = is(vowel); - const isVowelAll = isAll(vowel); - const containsVowel = contains(vowel); - name({ - isVowel: isVowel$1, - isVowelAll, - containsVowel, - }); - - name({ - assemble, - - disassemble: disassemble$1, - disassembleCharacter: disassembleChar, - - composeComplex: complex$1, - composeSyllable: syllable, - - stronger: stronger$1, - }); - - exports.assemble = assemble; - exports.a = assemble; - exports.disassemble = disassemble$1; - exports.d = disassemble$1; - exports.disassembleCharacter = disassembleChar; - exports.composeComplex = complex$1; - exports.composeSyllable = syllable; - exports.stronger = stronger$1; - exports.useComp3 = useComp3; - exports.useArchaic = useArchaic; - exports.noUseJungJong = noUseJungJong; - exports.noCompDouble = noCompDouble; - exports.decomposeComplex = decomposeComplex; - exports.decomposeSyllable = decomposeSyllable; - exports.standardize = standardize; - exports.flatten = flatten; - exports.deepMap = deepMap; - exports.toKeys = toKeys; - exports.fromKeys = fromKeys; - exports.isConsonant = isConsonant; - exports.isConsonantAll = isConsonantAll; - exports.containsConsonant = containsConsonant; - exports.isJamo = isJamo; - exports.isCompatibilityJamo = isCompatibilityJamo; - exports.isJamoExtendedA = isJamoExtendedA; - exports.isSyllable = isSyllable; - exports.isJamoExtendedB = isJamoExtendedB; - exports.isHalfwidth = isHalfwidth; - exports.isReserved = isReserved; - exports.isStandardHangul = isStandardHangul; - exports.isHangul = isHangul; - exports.isAllJamo = isAllJamo; - exports.containsJamo = containsJamo; - exports.isAllCompatibilityJamo = isAllCompatibilityJamo; - exports.containsCompatibilityJamo = containsCompatibilityJamo; - exports.isAllJamoExtendedA = isAllJamoExtendedA; - exports.containsJamoExtendedA = containsJamoExtendedA; - exports.isAllSyllable = isAllSyllable; - exports.containsSyllable = containsSyllable; - exports.isAllJamoExtendedB = isAllJamoExtendedB; - exports.containsJamoExtendedB = containsJamoExtendedB; - exports.isAllHalfwidth = isAllHalfwidth; - exports.containsHalfwidth = containsHalfwidth; - exports.isAllReserved = isAllReserved; - exports.containsReserved = containsReserved; - exports.isAllStandardHangul = isAllStandardHangul; - exports.containsStandardHangul = containsStandardHangul; - exports.isAllHangul = isAllHangul; - exports.containsHangul = containsHangul; - exports.isVowel = isVowel$1; - exports.isVowelAll = isVowelAll; - exports.containsVowel = containsVowel; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); diff --git a/dist/umd/Hangul.min.js b/dist/umd/Hangul.min.js deleted file mode 100644 index e793de3..0000000 --- a/dist/umd/Hangul.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.Hangul={})}(this,function(n){"use strict";const t={"ㄱ":1,"ㄴ":1,"ㄷ":1,"ㄹ":1,"ㅁ":1,"ㅂ":1,"ㅅ":1,"ㅇ":1,"ㅈ":1,"ㅊ":1,"ㅋ":1,"ㅌ":1,"ㅍ":1,"ㅎ":1,"ㆁ":1,"ㆄ":1,"ㅱ":1,"ㅿ":1},r={"ㅏ":1,"ㅐ":1,"ㅑ":1,"ㅓ":1,"ㅔ":1,"ㅕ":1,"ㅖ":1,"ㅗ":1,"ㅛ":1,"ㅜ":1,"ㅠ":1,"ㅡ":1,"ㅣ":1,"ㆍ":1},e={"ㅂ":"q","ㅃ":"Q","ㅈ":"w","ㅉ":"W","ㄷ":"e","ㄸ":"E","ㄱ":"r","ㄲ":"R","ㅅ":"t","ㅆ":"T","ㅛ":"y","ㅕ":"u","ㅑ":"i","ㅐ":"o","ㅒ":"O","ㅔ":"p","ㅖ":"P","ㅁ":"a","ㄴ":"s","ㅇ":"d","ㄹ":"f","ㅎ":"g","ㅗ":"h","ㅓ":"j","ㅏ":"k","ㅣ":"l","ㅋ":"z","ㅌ":"x","ㅊ":"c","ㅍ":"v","ㅠ":"b","ㅜ":"n","ㅡ":"m"},o={q:"ㅂ",Q:"ㅃ",w:"ㅈ",W:"ㅉ",e:"ㄷ",E:"ㄸ",r:"ㄱ",R:"ㄲ",t:"ㅅ",T:"ㅆ",y:"ㅛ",u:"ㅕ",i:"ㅑ",o:"ㅐ",O:"ㅒ",p:"ㅔ",P:"ㅖ",a:"ㅁ",s:"ㄴ",d:"ㅇ",f:"ㄹ",g:"ㅎ",h:"ㅗ",j:"ㅓ",k:"ㅏ",l:"ㅣ",z:"ㅋ",x:"ㅌ",c:"ㅊ",v:"ㅍ",b:"ㅠ",n:"ㅜ",m:"ㅡ"},s={"ㄱㄱ":"ㄲ","ㄷㄷ":"ㄸ","ㅅㅅ":"ㅆ","ㅈㅈ":"ㅉ","ㅂㅂ":"ㅃ"},i={"ㅗㅏ":"ㅘ","ㅗㅐ":"ㅙ","ㅗㅣ":"ㅚ","ㅜㅓ":"ㅝ","ㅜㅔ":"ㅞ","ㅜㅣ":"ㅟ","ㅡㅣ":"ㅢ"},a={"ㄱㄱ":"ㄲ","ㄱㅅ":"ㄳ","ㄴㅈ":"ㄵ","ㄴㅎ":"ㄶ","ㄹㄱ":"ㄺ","ㄹㅁ":"ㄻ","ㄹㅂ":"ㄼ","ㄹㅅ":"ㄽ","ㄹㅌ":"ㄾ","ㄹㅍ":"ㄿ","ㄹㅎ":"ㅀ","ㅂㅅ":"ㅄ","ㅅㅅ":"ㅆ"},l={"ㄴㄴ":"ㅥ","ㄴㄷ":"ㅦ","ㄴㅅ":"ㅧ","ㄴㅿ":"ㅨ","ㄹㄱㅅ":"ㅩ","ㄹㄷ":"ㅪ","ㄹㅂㅅ":"ㅫ","ㄹㅿ":"ㅬ","ㄹㆆ":"ㅭ","ㅁㅂ":"ㅮ","ㅁㅅ":"ㅯ","ㅁㅿ":"ㅰ","ㅂㄱ":"ㅲ","ㅂㄷ":"ㅳ","ㅂㅅㄱ":"ㅴ","ㅂㅅㄷ":"ㅵ","ㅂㅈ":"ㅶ","ㅂㅌ":"ㅷ","ㅅㄱ":"ㅺ","ㅅㄴ":"ㅻ","ㅅㄷ":"ㅼ","ㅅㅂ":"ㅽ","ㅅㅈ":"ㅾ","ㅇㅇ":"ㆀ","ㆁㅅ":"ㆁ","ㆁㅿ":"ㅿ","ㅎㅎ":"ㆅ","ㅛㅑ":"ㆇ","ㅛㅒ":"ㆈ","ㅛㅣ":"ㆉ","ㅠㅕ":"ㆊ","ㅠㅖ":"ㆋ","ㅠㅣ":"ㆌ","ㆍㅣ":"ㆎ"},c={"ㄲ":["ㄱ","ㄱ"],"ㄳ":["ㄱ","ㅅ"],"ㄵ":["ㄴ","ㅈ"],"ㄶ":["ㄴ","ㅎ"],"ㄸ":["ㄷ","ㄷ"],"ㄻ":["ㄹ","ㅁ"],"ㄺ":["ㄹ","ㄱ"],"ㄼ":["ㄹ","ㅂ"],"ㄽ":["ㄹ","ㅅ"],"ㄾ":["ㄹ","ㅌ"],"ㄿ":["ㄹ","ㅍ"],"ㅀ":["ㄹ","ㅎ"],"ㅃ":["ㅂ","ㅂ"],"ㅄ":["ㅂ","ㅅ"],"ㅆ":["ㅅ","ㅅ"],"ㅉ":["ㅈ","ㅈ"],"ㅘ":["ㅗ","ㅏ"],"ㅙ":["ㅗ","ㅐ"],"ㅚ":["ㅗ","ㅣ"],"ㅝ":["ㅜ","ㅓ"],"ㅞ":["ㅜ","ㅔ"],"ㅟ":["ㅜ","ㅣ"],"ㅢ":["ㅡ","ㅣ"],"ㅥ":["ㄴ","ㄴ"],"ㅦ":["ㄴ","ㄷ"],"ㅧ":["ㄴ","ㅅ"],"ㅨ":["ㄴ","ㅿ"],"ㅩ":["ㄹ","ㄱ","ㅅ"],"ㅪ":["ㄹ","ㄷ"],"ㅫ":["ㄹ","ㅂ","ㅅ"],"ㅬ":["ㄹ","ㅿ"],"ㅭ":["ㄹ","ㆆ"],"ㅮ":["ㅁ","ㅂ"],"ㅯ":["ㅁ","ㅅ"],"ㅰ":["ㅁ","ㅿ"],"ㅲ":["ㅂ","ㄱ"],"ㅳ":["ㅂ","ㄷ"],"ㅴ":["ㅂ","ㅅ","ㄱ"],"ㅵ":["ㅂ","ㅅ","ㄷ"],"ㅶ":["ㅂ","ㅈ"],"ㅷ":["ㅂ","ㅌ"],"ㅺ":["ㅅ","ㄱ"],"ㅻ":["ㅅ","ㄴ"],"ㅼ":["ㅅ","ㄷ"],"ㅽ":["ㅅ","ㅂ"],"ㅾ":["ㅅ","ㅈ"],"ㆀ":["ㅇ","ㅇ"],"ㆂ":["ㆁ","ㅅ"],"ㆃ":["ㆁ","ㅿ"],"ㆅ":["ㅎ","ㅎ"],"ㆇ":["ㅛ","ㅑ"],"ㆈ":["ㅛ","ㅒ"],"ㆉ":["ㅛ","ㅣ"],"ㆊ":["ㅠ","ㅕ"],"ㆋ":["ㅠ","ㅖ"],"ㆌ":["ㅠ","ㅣ"],"ㆎ":["ㆍ","ㅣ"]},u=(Object.assign({},{"ㄲ":1,"ㄳ":1,"ㄵ":1,"ㄶ":1,"ㄸ":1,"ㄺ":1,"ㄻ":1,"ㄼ":1,"ㄽ":1,"ㄾ":1,"ㄿ":1,"ㅀ":1,"ㅃ":1,"ㅄ":1,"ㅆ":1,"ㅉ":1,"ㅘ":1,"ㅙ":1,"ㅚ":1,"ㅝ":1,"ㅞ":1,"ㅟ":1,"ㅢ":1},{"ㅥ":1,"ㅦ":1,"ㅧ":1,"ㅨ":1,"ㅩ":1,"ㅪ":1,"ㅫ":1,"ㅬ":1,"ㅭ":1,"ㅮ":1,"ㅯ":1,"ㅰ":1,"ㅱ":1,"ㅲ":1,"ㅳ":1,"ㅴ":1,"ㅵ":1,"ㅶ":1,"ㅷ":1}),{"ㄱ":"ㄲ","ㅋ":"ㄲ","ㄷ":"ㄸ","ㅌ":"ㄸ","ㅂ":"ㅃ","ㅍ":"ㅃ","ㅅ":"ㅆ","ㅈ":"ㅉ","ㅊ":"ㅉ"}),d=["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],f=["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"],m=[null,"ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],h={"ㄱ":0,"ㄲ":1,"ㄴ":2,"ㄷ":3,"ㄸ":4,"ㄹ":5,"ㅁ":6,"ㅂ":7,"ㅃ":8,"ㅅ":9,"ㅆ":10,"ㅇ":11,"ㅈ":12,"ㅉ":13,"ㅊ":14,"ㅋ":15,"ㅌ":16,"ㅍ":17,"ㅎ":18},y={"ㅏ":0,"ㅐ":1,"ㅑ":2,"ㅒ":3,"ㅓ":4,"ㅔ":5,"ㅕ":6,"ㅖ":7,"ㅗ":8,"ㅘ":9,"ㅙ":10,"ㅚ":11,"ㅛ":12,"ㅜ":13,"ㅝ":14,"ㅞ":15,"ㅟ":16,"ㅠ":17,"ㅡ":18,"ㅢ":19,"ㅣ":20},g={"ㄱ":1,"ㄲ":2,"ㄳ":3,"ㄴ":4,"ㄵ":5,"ㄶ":6,"ㄷ":7,"ㄹ":8,"ㄺ":9,"ㄻ":10,"ㄼ":11,"ㄽ":12,"ㄾ":13,"ㄿ":14,"ㅀ":15,"ㅁ":16,"ㅂ":17,"ㅄ":18,"ㅅ":19,"ㅆ":20,"ㅇ":21,"ㅈ":22,"ㅊ":23,"ㅋ":24,"ㅌ":25,"ㅍ":26,"ㅎ":27};class A{constructor(n,t){this.start=n,this.end=t}containsCodePoint(n){return n>=this.start&&n<=this.end}contains(n){return this.containsCodePoint(n.codePointAt(0))}}class p{constructor(n,t={}){this.ranges=n,this.codePoints=t}containsCodePoint(n){return this.codePoints&&this.codePoints[n]||this.ranges.some(t=>t.containsCodePoint(n))}contains(n){const t=n.codePointAt(0);return this.containsCodePoint(t)}}const w=new A(4352,4607),b=new A(12592,12687),C=new A(43360,43391),$=new A(44032,55215),E=new A(55216,55295),J=new A(65440,65503),v=new p([new A(43389,43391),new A(55204,55215),new A(55239,55242),new A(55292,55295)],{12592:1,12687:1}),x=new p([b,$]),H=new p([w,b,C,$,E,J,v]);var S=(n,t,r=0)=>String.fromCodePoint(588*n+28*t+r+$.start);class P{constructor(n="",t=[]){this.result=n,this.remainder=t}}const j=n=>{const t=`${n}`;if(1!==t.length)throw Error(`"${t}" is not a Character!`);return t},T=()=>{throw TypeError("The data must be an Array or a String!")},R=n=>Array.isArray(n)?n:n.split(""),O=n=>!(n.length<1)&&(Array.isArray(n)?n.length>1||O(n[0]):"string"==typeof n&&n.length>1),B=n=>n,N=(n,t,r)=>{const e=r?R:B;return Array.isArray(n)?n.map(n=>O(n)?N(n,t,r):e(t(n))):"string"==typeof n?n.split("").map(n=>e(t(n))):void T()},V=(n,t)=>{let r="";if(Array.isArray(n)){const e=n.length;for(let o=0;o{if(Array.isArray(n)){let t="";const r=n.length;for(let e=0;e{let r,e="";if(Array.isArray(n)){r=[];const e=n.length;for(let o=0;o{if(n<0||n>8)throw Error("The mode cannot be less than zero or greater than eight!");const t=2&n,r=t&&1&n,e=8&n;let o=k[n];if(!o){const r=[s];4&n||r.push(i,a),t&&r.push(l),o=Object.assign({},...r),k[n]=o}return n=>{const t=n.length;if(t<1)throw Error("Cannot compose array of zero characters!");const s=n[0];if(t<2)return new P(s);const i=n[1];if(e&&s===i)return new P(s,n.slice(1));const a=o[s+i];if(a){if(r&&t>2){const t=o[s+i+n[2]];if(t)return new P(t,n.slice(3))}return new P(a,n.slice(2))}return new P(s,n.slice(1))}},D=n=>{const t=q(n);return n=>I(n,t)};var K=n=>{const t=q(n);return n=>{if(n.length<2)return new P(n[0]);const e=t(n),o=e.result,s=e.remainder,i=h[o];if(s.length<1||!Number.isInteger(i))return e;const a=t(s),l=a.result,c=a.remainder,u=y[l];if(!Number.isInteger(u))return new P(o,[l,...c]);if(c.length&&!(n=>n&&"ㆍ"!==n&&r[n])(c[1])){const n=t(c),r=n.result,e=n.remainder,o=g[r];if(o)return new P(S(i,u,o),e)}return new P(S(i,u),c)}};const M=Object.assign({},{"ᄀ":"ㄱ","ᄁ":["ㄱ","ㄱ"],"ᄂ":"ㄴ","ᄃ":"ㄷ","ᄄ":["ㄷ","ㄷ"],"ᄅ":"ㄹ","ᄆ":"ㅁ","ᄇ":"ㅂ","ᄈ":["ㅂ","ㅂ"],"ᄉ":"ㅅ","ᄊ":["ㅅ","ㅅ"],"ᄋ":"ㅇ","ᄌ":"ㅈ","ᄍ":["ㅈ","ㅈ"],"ᄎ":"ㅊ","ᄏ":"ㅋ","ᄐ":"ㅌ","ᄑ":"ㅍ","ᄒ":"ㅎ","ᄓ":["ㄴ","ㄱ"],"ᄔ":["ㄴ","ㄴ"],"ᄕ":["ㄴ","ㄷ"],"ᄖ":["ㄴ","ㅂ"],"ᄗ":["ㄷ","ㄱ"],"ᄘ":["ㄹ","ㄴ"],"ᄙ":["ㄹ","ㄹ"],"ᄚ":["ㄹ","ㅎ"],"ᄛ":["ㄹ","ㅇ"],"ᄜ":["ㅁ","ㅂ"],"ᄝ":"ㅱ","ᄞ":["ㅂ","ㄱ"],"ᄟ":["ㅂ","ㄴ"],"ᄠ":["ㅂ","ㄷ"],"ᄡ":["ㅂ","ㅅ"],"ᄢ":["ㅂ","ㅅ","ㄱ"],"ᄣ":["ㅂ","ㅅ","ㄷ"],"ᄤ":["ㅂ","ㅅ","ㅂ"],"ᄥ":["ㅂ","ㅅ","ㅅ"],"ᄦ":["ㅂ","ㅅ","ㅈ"],"ᄧ":["ㅂ","ㅈ"],"ᄨ":["ㅂ","ㅊ"],"ᄩ":["ㅂ","ㅌ"],"ᄪ":["ㅂ","ㅍ"],"ᄫ":["ㅂ","ㅇ"],"ᄬ":[["ㅂ","ㅂ"],"ㅇ"],"ᄭ":["ㅅ","ㄱ"],"ᄮ":["ㅅ","ㄴ"],"ᄯ":["ㅅ","ㄷ"],"ᄰ":["ㅅ","ㄹ"],"ᄱ":["ㅅ","ㅁ"],"ᄲ":["ㅅ","ㅂ"],"ᄳ":["ㅅ","ㅂ","ㄱ"],"ᄴ":["ㅅ","ㅅ","ㅅ"],"ᄵ":["ㅅ","ㅇ"],"ᄶ":["ㅅ","ㅈ"],"ᄷ":["ㅅ","ㅊ"],"ᄸ":["ㅅ","ㅋ"],"ᄹ":["ㅅ","ㅌ"],"ᄺ":["ㅅ","ㅍ"],"ᄻ":["ㅅ","ㅎ"],"ᄼ":null,"ᄽ":null,"ᄾ":null,"ᄿ":null,"ᅀ":"ㅿ","ᅁ":["ㅇ","ㄱ"],"ᅂ":["ㅇ","ㄷ"],"ᅃ":["ㅇ","ㅁ"],"ᅄ":["ㅇ","ㅂ"],"ᅅ":["ㅇ","ㅅ"],"ᅆ":["ㅇ","ㅿ"],"ᅇ":["ㅇ","ㅇ"],"ᅈ":["ㅇ","ㅈ"],"ᅉ":["ㅇ","ㅊ"],"ᅊ":["ㅇ","ㅌ"],"ᅋ":["ㅇ","ㅍ"],"ᅌ":"ㆁ","ᅍ":["ㅈ","ㅇ"],"ᅎ":null,"ᅏ":null,"ᅐ":null,"ᅑ":null,"ᅒ":["ㅊ","ㅋ"],"ᅓ":["ㅊ","ㅎ"],"ᅔ":null,"ᅕ":null,"ᅖ":["ㅍ","ㅂ"],"ᅗ":"ㆄ","ᅘ":["ㅎ","ㅎ"],"ᅙ":"ㆆ","ᅚ":["ㄱ","ㄷ"],"ᅛ":["ㄱ","ㅅ"],"ᅜ":["ㄱ","ㅈ"],"ᅝ":["ㄱ","ㅎ"],"ᅞ":["ㄷ","ㄹ"],"ᅡ":"ㅏ","ᅢ":"ㅐ","ᅣ":"ㅑ","ᅤ":"ㅒ","ᅥ":"ㅓ","ᅦ":"ㅔ","ᅧ":"ㅕ","ᅨ":"ㅖ","ᅩ":"ㅗ","ᅪ":["ㅗ","ㅏ"],"ᅫ":["ㅗ","ㅐ"],"ᅬ":["ㅗ","ㅣ"],"ᅭ":"ㅛ","ᅮ":"ㅜ","ᅯ":["ㅜ","ㅓ"],"ᅰ":["ㅜ","ㅔ"],"ᅱ":["ㅜ","ㅣ"],"ᅲ":"ㅠ","ᅳ":"ㅡ","ᅴ":["ㅡ","ㅣ"],"ᅵ":"ㅣ","ᅶ":["ㅏ","ㅗ"],"ᅷ":["ㅏ","ㅜ"],"ᅸ":["ㅑ","ㅗ"],"ᅹ":["ㅑ","ㅛ"],"ᅺ":["ㅓ","ㅗ"],"ᅻ":["ㅓ","ㅜ"],"ᅼ":["ㅓ","ㅡ"],"ᅽ":["ㅕ","ㅗ"],"ᅾ":["ㅕ","ㅜ"],"ᅿ":["ㅗ","ㅓ"],"ᆀ":["ㅔ","ㅗ"],"ᆁ":["ㅖ","ㅗ"],"ᆂ":["ㅗ","ㅗ"],"ᆃ":["ㅗ","ㅜ"],"ᆄ":["ㅛ","ㅑ"],"ᆅ":["ㅛ","ㅒ"],"ᆆ":["ㅛ","ㅕ"],"ᆇ":["ㅛ","ㅗ"],"ᆈ":["ㅛ","ㅣ"],"ᆉ":["ㅜ","ㅏ"],"ᆊ":["ㅜ","ㅐ"],"ᆋ":["ㅜ","ㅓ","ㅡ"],"ᆌ":["ㅜ","ㅖ"],"ᆍ":["ㅜ","ㅜ"],"ᆎ":["ㅠ","ㅏ"],"ᆏ":["ㅠ","ㅓ"],"ᆐ":["ㅠ","ㅔ"],"ᆑ":["ㅠ","ㅕ"],"ᆒ":["ㅠ","ㅔ"],"ᆓ":["ㅠ","ㅜ"],"ᆔ":["ㅠ","ㅣ"],"ᆕ":["ㅡ","ㅜ"],"ᆖ":["ㅡ","ㅡ"],"ᆗ":["ㅡ","ㅣ","ㅜ"],"ᆘ":["ㅣ","ㅏ"],"ᆙ":["ㅣ","ㅑ"],"ᆚ":["ㅣ","ㅗ"],"ᆛ":["ㅣ","ㅜ"],"ᆜ":["ㅣ","ㅡ"],"ᆝ":null,"ᆞ":"ㆍ","ᆟ":["ㆍ","ㅓ"],"ᆠ":["ㆍ","ㅜ"],"ᆡ":["ㆍ","ㅣ"],"ᆢ":["ㆍ","ㆍ"],"ᆣ":["ㅏ","ㅡ"],"ᆤ":["ㅑ","ㅜ"],"ᆥ":["ㅕ","ㅑ"],"ᆦ":["ㅗ","ㅑ"],"ᆧ":["ㅗ","ㅒ"],"ᆨ":"ㄱ","ᆩ":["ㄱ","ㄱ"],"ᆪ":["ㄱ","ㅅ"],"ᆫ":"ㄴ","ᆬ":["ㄴ","ㅈ"],"ᆭ":["ㄴ","ㅎ"],"ᆮ":"ㄷ","ᆯ":"ㄹ","ᆰ":["ㄹ","ㄱ"],"ᆱ":["ㄹ","ㅁ"],"ᆲ":["ㄹ","ㅂ"],"ᆳ":["ㄹ","ㅅ"],"ᆴ":["ㄹ","ㅌ"],"ᆵ":["ㄹ","ㅍ"],"ᆶ":["ㄹ","ㅎ"],"ᆷ":"ㅁ","ᆸ":"ㅂ","ᆹ":["ㅂ","ㅅ"],"ᆺ":"ㅅ","ᆻ":["ㅅ","ㅅ"],"ᆼ":"ㅇ","ᆽ":"ㅈ","ᆾ":"ㅊ","ᆿ":"ㅋ","ᇀ":"ㅌ","ᇁ":"ㅍ","ᇂ":"ㅎ","ᇃ":["ㄱ","ㄹ"],"ᇄ":["ㄱ","ㅅ","ㄱ"],"ᇅ":["ㄴ","ㄱ"],"ᇆ":["ㄴ","ㄷ"],"ᇇ":["ㄴ","ㅅ"],"ᇈ":["ㄴ","ㅿ"],"ᇉ":["ㄴ","ㅌ"],"ᇊ":["ㄷ","ㄱ"],"ᇋ":["ㄷ","ㄹ"],"ᇌ":["ㄹ","ㄱ","ㅅ"],"ᇍ":["ㄹ","ㄴ"],"ᇎ":["ㄹ","ㄷ"],"ᇏ":["ㄹ","ㄷ","ㅎ"],"ᇐ":["ㄹ","ㄹ"],"ᇑ":["ㄹ","ㅁ","ㄱ"],"ᇒ":["ㄹ","ㅁ","ㅅ"],"ᇓ":["ㄹ","ㅂ","ㅅ"],"ᇔ":["ㄹ","ㅂ","ㅎ"],"ᇕ":["ㄹ","ㅸ"],"ᇖ":["ㄹ","ㅅ","ㅅ"],"ᇗ":["ㄹ","ㅿ"],"ᇘ":["ㄹ","ㅋ"],"ᇙ":["ㄹ","ㆆ"],"ᇚ":["ㅁ","ㄱ"],"ᇛ":["ㅁ","ㄹ"],"ᇜ":["ㅁ","ㅂ"],"ᇝ":["ㅁ","ㅅ"],"ᇞ":["ㅁ","ㅅ","ㅅ"],"ᇟ":["ㅁ","ㅿ"],"ᇠ":["ㅁ","ㅊ"],"ᇡ":["ㅁ","ㅎ"],"ᇢ":"ㅱ","ᇣ":["ㅂ","ㄹ"],"ᇤ":["ㅂ","ㅍ"],"ᇥ":["ㅂ","ㅎ"],"ᇦ":["ㅂ","ㅇ"],"ᇧ":["ㅅ","ㄱ"],"ᇨ":["ㅅ","ㄷ"],"ᇩ":["ㅅ","ㄹ"],"ᇪ":["ㅅ","ㅂ"],"ᇫ":"ㅿ","ᇬ":["ㆁ","ㄱ"],"ᇭ":["ㆁ","ㄱ","ㄱ"],"ᇮ":["ㆁ","ㆁ"],"ᇯ":["ㆁ","ㅋ"],"ᇰ":"ㆁ","ᇱ":["ㆁ","ㅅ"],"ᇲ":["ㆁ","ㅿ"],"ᇳ":["ㅍ","ㅂ"],"ᇴ":"ㆄ","ᇵ":["ㅎ","ㄴ"],"ᇶ":["ㅎ","ㄹ"],"ᇷ":["ㅎ","ㅁ"],"ᇸ":["ㅎ","ㅂ"],"ᇹ":"ㆆ","ᇺ":["ㄱ","ㄴ"],"ᇻ":["ㄱ","ㅂ"],"ᇼ":["ㄱ","ㅊ"],"ᇽ":["ㄱ","ㅋ"],"ᇾ":["ㄱ","ㅎ"],"ᇿ":["ㄴ","ㄴ"]},{"ꥠ":["ㄷ","ㅁ"],"ꥡ":["ㄷ","ㅂ"],"ꥢ":["ㄷ","ㅅ"],"ꥣ":["ㄷ","ㅈ"],"ꥤ":["ㄹ","ㄱ"],"ꥥ":["ㄹ","ㄱ","ㄱ"],"ꥦ":["ㄹ","ㄷ"],"ꥧ":["ㄹ","ㄷ","ㄷ"],"ꥨ":["ㄹ","ㅁ"],"ꥩ":["ㄹ","ㅂ"],"ꥪ":["ㄹ","ㅂ","ㅂ"],"ꥫ":["ㄹ","ㅸ"],"ꥬ":["ㄹ","ㅅ"],"ꥭ":["ㄹ","ㅈ"],"ꥮ":["ㄹ","ㅋ"],"ꥯ":["ㅁ","ㄱ"],"ꥰ":["ㅁ","ㄷ"],"ꥱ":["ㅁ","ㅅ"],"ꥲ":["ㅂ","ㅅ","ㅌ"],"ꥳ":["ㅂ","ㅋ"],"ꥴ":["ㅂ","ㅎ"],"ꥵ":["ㅅ","ㅅ","ㅂ"],"ꥶ":["ㅇ","ㄹ"],"ꥷ":["ㅇ","ㅎ"],"ꥸ":["ㅈ","ㅈ","ㅎ"],"ꥹ":["ㅌ","ㅌ"],"ꥺ":["ㅍ","ㅎ"],"ꥻ":["ㅎ","ㅅ"],"ꥼ":["ㆆ","ㆆ"]},{"ힰ":["ㅗ","ㅕ"],"ힱ":["ㅗ","ㅗ","ㅣ"],"ힲ":["ㅛ","ㅏ"],"ힳ":["ㅛ","ㅐ"],"ힴ":["ㅛ","ㅓ"],"ힵ":["ㅜ","ㅕ"],"ힶ":["ㅜ","ㅣ","ㅣ"],"ힷ":["ㅠ","ㅐ"],"ힸ":["ㅠ","ㅗ"],"ힹ":["ㅡ","ㅏ"],"ힺ":["ㅡ","ㅓ"],"ힻ":["ㅡ","ㅔ"],"ힼ":["ㅡ","ㅗ"],"ힽ":["ㅣ","ㅏ","ㅗ"],"ힾ":["ㅣ","ㅒ"],"ힿ":["ㅣ","ㅕ"],"ퟀ":["ㅣ","ㅖ"],"ퟁ":["ㅣ","ㅗ","ㅣ"],"ퟂ":["ㅣ","ㅛ"],"ퟃ":["ㅣ","ㅠ"],"ퟄ":["ㅣ","ㅣ"],"ퟅ":["ㆍ","ㅏ"],"ퟆ":["ㆍ","ㅔ"],"ퟋ":["ㄴ","ㄹ"],"ퟌ":["ㄴ","ㅈ"],"ퟍ":["ㄷ","ㄷ"],"ퟎ":["ㄷ","ㄷ","ㅂ"],"ퟏ":["ㄷ","ㅂ"],"ퟐ":["ㄷ","ㅅ"],"ퟑ":["ㄷ","ㅅ","ㄱ"],"ퟒ":["ㄷ","ㅈ"],"ퟓ":["ㄷ","ㅊ"],"ퟔ":["ㄷ","ㅌ"],"ퟕ":["ㄹ","ㄱ","ㄱ"],"ퟖ":["ㄹ","ㄱ","ㅎ"],"ퟗ":["ㄹ","ㄹ","ㅋ"],"ퟘ":["ㄹ","ㅁ","ㅎ"],"ퟙ":["ㄹ","ㅂ","ㄷ"],"ퟚ":["ㄹ","ㅂ","ㅍ"],"ퟛ":["ㄹ","ㆁ"],"ퟜ":["ㄹ","ㆆ","ㅎ"],"ퟝ":null,"ퟞ":["ㅁ","ㄴ"],"ퟟ":["ㅁ","ㄴ","ㄴ"],"ퟠ":["ㅁ","ㅁ"],"ퟡ":["ㅁ","ㅂ","ㅅ"],"ퟢ":["ㅁ","ㅈ"],"ퟣ":["ㅂ","ㄷ"],"ퟤ":["ㅂ","ㄹ","ㅍ"],"ퟥ":["ㅂ","ㅁ"],"ퟦ":["ㅂ","ㅂ"],"ퟧ":["ㅂ","ㅅ","ㄷ"],"ퟨ":["ㅂ","ㅈ"],"ퟩ":["ㅂ","ㅊ"],"ퟪ":["ㅅ","ㅁ"],"ퟫ":["ㅅ","ㅸ"],"ퟬ":["ㅅ","ㅅ","ㄱ"],"ퟭ":["ㅅ","ㅅ","ㄷ"],"ퟮ":["ㅅ","ㅿ"],"ퟯ":["ㅅ","ㅈ"],"ퟰ":["ㅅ","ㅊ"],"ퟱ":["ㅅ","ㅌ"],"ퟲ":["ㅅ","ㅎ"],"ퟳ":["ㅿ","ㅂ"],"ퟴ":["ㅿ","ㅸ"],"ퟵ":["ㆁ","ㅁ"],"ퟶ":["ㆁ","ㅎ"],"ퟷ":["ㅈ","ㅂ"],"ퟸ":["ㅈ","ㅂ","ㅂ"],"ퟹ":["ㅈ","ㅈ"],"ퟺ":["ㅍ","ㅅ"],"ퟻ":["ㅍ","ㅌ"]},{"ᄀ":"ㄱ","ᄁ":["ㄱ","ㄱ"],"ᆪ":["ㄱ","ㅅ"],"ᄂ":"ㄴ","ᆬ":["ㄴ","ㅈ"],"ᆭ":["ㄴ","ㅎ"],"ᄃ":"ㄷ","ᄄ":["ㄷ","ㄷ"],"ᄅ":"ㄹ","ᆰ":["ㄹ","ㄱ"],"ᆱ":["ㄹ","ㅁ"],"ᆲ":["ㄹ","ㅂ"],"ᆳ":["ㄹ","ㅅ"],"ᆴ":["ㄹ","ㅌ"],"ᆵ":["ㄹ","ㅍ"],"ᄚ":["ㄹ","ㅎ"],"ᄆ":"ㅁ","ᄇ":"ㅂ","ᄈ":["ㅂ","ㅂ"],"ᄡ":["ㅂ","ㅅ"],"ᄉ":"ㅅ","ᄊ":["ㅅ","ㅅ"],"ᄋ":"ㅇ","ᄌ":"ㅈ","ᄍ":["ㅈ","ㅈ"],"ᄎ":"ㅊ","ᄏ":"ㅋ","ᄐ":"ㅌ","ᄑ":"ㅍ","ᄒ":"ㅎ","ᅡ":"ㅏ","ᅢ":"ㅐ","ᅣ":"ㅑ","ᅤ":"ㅒ","ᅥ":"ㅓ","ᅦ":"ㅔ","ᅧ":"ㅕ","ᅨ":"ㅖ","ᅩ":"ㅗ","ᅪ":["ㅗ","ㅏ"],"ᅫ":["ㅗ","ㅐ"],"ᅬ":["ㅗ","ㅣ"],"ᅭ":"ㅛ","ᅮ":"ㅜ","ᅯ":["ㅜ","ㅓ"],"ᅰ":["ㅜ","ㅔ"],"ᅱ":["ㅜ","ㅣ"],"ᅲ":"ㅠ","ᅳ":"ㅡ","ᅴ":["ㅡ","ㅣ"],"ᅵ":"ㅣ"}),Q=n=>(n=>!x.contains(n)&&M[n]||n)(j(n)),W=n=>(x.contains(n)?c:M)[n]||n,_=n=>W(j(n)),F=n=>(t,r)=>I(n(t),K(r));var L=F(n=>N(n,_));const U=D(4),G=n=>{const t=W(n);if(Array.isArray(t)){const n=U(t);return Array.isArray(n)&&1===n.length?j(n):n}return t};const X=n=>{const t=n.codePointAt(0)-$.start,r=t%28,e=(t-r)/28,o=e%21;return[d[0|e/21],f[o],m[r]].filter(n=>n)};const Y=n=>t=>{const r=j(t);return $.contains(r)?X(r).map(n):n(r)},Z=Y(W),nn=Y(G),tn=(n,t,r)=>{const e=(r?Z:nn)(n);return t?e:z(e)};var rn=(n,t,r)=>(t?N:V)(n,r?Z:nn,!0),en=n=>{Object.keys(n).forEach(t=>{n[t].displayName=t})};const on={"ㄱ":{"ㄱ":"ㄲ","ㅅ":"ㄳ"},"ㄷ":{"ㄷ":"ㄸ"},"ㅅ":{"ㅅ":"ㅆ","ㄱ":"ㅺ","ㄴ":"ㅻ","ㄷ":"ㅼ","ㅂ":"ㅽ","ㅈ":"ㅾ"},"ㅈ":{"ㅈ":"ㅉ"},"ㅂ":{"ㅂ":"ㅃ","ㅅ":{$:"ㅄ","ㄱ":"ㅴ","ㄷ":"ㅵ"},"ㄱ":"ㅲ","ㄷ":"ㅳ","ㅈ":"ㅶ","ㅌ":"ㅷ"},"ㅗ":{"ㅏ":"ㅘ","ㅐ":"ㅙ","ㅣ":"ㅚ"},"ㅜ":{"ㅓ":"ㅝ","ㅔ":"ㅞ","ㅣ":"ㅟ"},"ㅡ":{"ㅣ":"ㅢ"},"ㄴ":{"ㅈ":"ㄵ","ㅎ":"ㄶ","ㄴ":"ㅥ","ㄷ":"ㅦ","ㅅ":"ㅧ","ㅿ":"ㅨ"},"ㄹ":{"ㄱ":{$:"ㄺ","ㅅ":"ㅩ"},"ㅁ":"ㄻ","ㅂ":{$:"ㄼ","ㅅ":"ㅫ"},"ㅅ":"ㄽ","ㅌ":"ㄾ","ㅍ":"ㄿ","ㅎ":"ㅀ","ㄷ":"ㅪ","ㅿ":"ㅬ","ㆆ":"ㅭ"},"ㅁ":{"ㅂ":"ㅮ","ㅅ":"ㅯ","ㅿ":"ㅰ"},"ㅇ":{"ㅇ":"ㆀ"},"ㆁ":{"ㅅ":"ㆁ","ㅿ":"ㅿ"},"ㅎ":{"ㅎ":"ㆅ"},"ㅛ":{"ㅑ":"ㆇ","ㅒ":"ㆈ","ㅣ":"ㆉ"},"ㅠ":{"ㅕ":"ㆊ","ㅖ":"ㆋ","ㅣ":"ㆌ"},"ㆍ":{"ㅣ":"ㆎ"}},sn=n=>{const t=D(n);return n=>{const r=Q(n);return Array.isArray(r)?t(r):r}},an=n=>{const t=sn(n);return(n,r)=>(r?N:V)(n,t)};const ln=sn(3),cn=(n,t,r="",e)=>{if(void 0===n||void 0===t)throw Error("Cannot compose a complex with less than two values!");const o=on[ln(n)];if(!o){if(e)throw Error(`There's no complex character that starts with ${n}`);return`${n}${t}${r}`}const s=o[ln(t)];if(!s){if(e)throw Error(`Cannot combine ${n} and ${t}`);return`${n}${t}${r}`}const i=s.$||s;if(r){const o=s[ln(r)];if(!o){if(e)throw Error(`Found ${i} but cannot combine ${n}, ${t}, and ${r}`);return`${i}${r}`}return o}return i},un=(n,t="",r="",e)=>{const o=h[ln(n)],s=y[ln(t)];let i;if(r&&(i=g[ln(r)]),!Number.isInteger(o)){if(e)throw Error(`"${n}" is not a valid cho Character`);return`${n}${t}${r}`}if(!Number.isInteger(s)){if(e)throw Error(`"${t}" is not a valid jung Character`);return`${n}${t}${r}`}if(r&&!Number.isInteger(i)){if(e)throw Error(`"${r}" is not a valid jong character`);return`${S(o,s)}${r}`}return S(o,s,i)},dn=an(3);var fn=n=>dn(n).map(n=>u[n]||n);const mn=n=>e[n]||n,hn=n=>o[n],yn=Y(n=>{const t=G(n);return Array.isArray(t)?t.map(mn):mn(t)}),gn=n=>{const t=j(n),r=hn(t);if(!r){const n=hn(t.toLowerCase());return n||t}return r},An=F(n=>N(n,gn));var pn=n=>t=>r=>V(r,_)[n](t),wn=pn("some"),bn=n=>t=>{const r=_(t);return Array.isArray(r)?r.every(n):n(r)},Cn=pn("every");const $n=n=>t[n],En=bn($n),Jn=Cn($n),vn=wn($n);en({isConsonant:En,isConsonantAll:Jn,containsConsonant:vn});const xn=n=>t=>{const r=t.length;if(Array.isArray(t)){for(let e=0;et=>{const r=t.length;if(Array.isArray(t)){for(let e=0;ew.contains(j(n)),Pn=n=>b.contains(j(n)),jn=n=>C.char(j(n)),Tn=n=>$.contains(j(n)),Rn=n=>E.contains(j(n)),On=n=>J.contains(j(n)),Bn=n=>v.contains(j(n)),Nn=n=>x.contains(j(n)),Vn=n=>H.contains(j(n)),zn=xn(Sn),In=Hn(Sn),kn=xn(Pn),qn=Hn(Pn),Dn=xn(jn),Kn=Hn(jn),Mn=xn(Tn),Qn=Hn(Tn),Wn=xn(Rn),_n=Hn(Rn),Fn=xn(On),Ln=Hn(On),Un=xn(Bn),Gn=Hn(Bn),Xn=xn(Nn),Yn=Hn(Nn),Zn=xn(Vn),nt=Hn(Vn);en({isJamo:Sn,isAllJamo:zn,containsJamo:In,isCompatibilityJamo:Pn,isAllCompatibilityJamo:kn,containsCompatibilityJamo:qn,isJamoExtendedA:jn,isAllJamoExtendedA:Dn,containsJamoExtendedA:Kn,isSyllable:Tn,isAllSyllable:Mn,containsSyllable:Qn,isJamoExtendedB:Rn,isAllJamoExtendedB:Wn,containsJamoExtendedB:_n,isHalfwidth:On,isAllHalfwidth:Fn,containsHalfwidth:Ln,isReserved:Bn,isAllReserved:Un,containsReserved:Gn,isStandardHangul:Nn,isAllStandardHangul:Xn,containsStandardHangul:Yn,isHangul:Vn,isAllHangul:Zn,containsHangul:nt});const tt=n=>r[n],rt=bn(tt),et=Cn(tt),ot=wn(tt);en({isVowel:rt,isVowelAll:et,containsVowel:ot}),en({assemble:L,disassemble:rn,disassembleCharacter:tn,composeComplex:cn,composeSyllable:un,stronger:fn}),n.assemble=L,n.a=L,n.disassemble=rn,n.d=rn,n.disassembleCharacter=tn,n.composeComplex=cn,n.composeSyllable=un,n.stronger=fn,n.useComp3=1,n.useArchaic=2,n.noUseJungJong=4,n.noCompDouble=8,n.decomposeComplex=((n,t)=>R((t?W:G)(j(n)))),n.decomposeSyllable=((n,t)=>{const r=j(n);if(!$.contains(r)){if(t)throw Error("Decomposing a syllable requires a syllable to decompose!");return[n]}return X(r)}),n.standardize=((n,t,r)=>an(r)(n,t)),n.flatten=z,n.deepMap=N,n.toKeys=((n,t)=>(t?N:V)(n,yn)),n.fromKeys=(n=>An(n,8)),n.isConsonant=En,n.isConsonantAll=Jn,n.containsConsonant=vn,n.isJamo=Sn,n.isCompatibilityJamo=Pn,n.isJamoExtendedA=jn,n.isSyllable=Tn,n.isJamoExtendedB=Rn,n.isHalfwidth=On,n.isReserved=Bn,n.isStandardHangul=Nn,n.isHangul=Vn,n.isAllJamo=zn,n.containsJamo=In,n.isAllCompatibilityJamo=kn,n.containsCompatibilityJamo=qn,n.isAllJamoExtendedA=Dn,n.containsJamoExtendedA=Kn,n.isAllSyllable=Mn,n.containsSyllable=Qn,n.isAllJamoExtendedB=Wn,n.containsJamoExtendedB=_n,n.isAllHalfwidth=Fn,n.containsHalfwidth=Ln,n.isAllReserved=Un,n.containsReserved=Gn,n.isAllStandardHangul=Xn,n.containsStandardHangul=Yn,n.isAllHangul=Zn,n.containsHangul=nt,n.isVowel=rt,n.isVowelAll=et,n.containsVowel=ot,Object.defineProperty(n,"__esModule",{value:!0})}); diff --git a/rollup.config.js b/rollup.config.js index c408659..e33318c 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -21,12 +21,9 @@ export default (function iife() { if (production) { const terse = [terser()]; return [ - makeOutput('iife', 'dist/iife/Hangul.js'), - makeOutput('iife', 'dist/iife/Hangul.min.js', terse), - makeOutput('cjs', 'dist/cjs/Hangul.js'), - makeOutput('cjs', 'dist/cjs/Hangul.min.js', terse), - makeOutput('umd', 'dist/umd/Hangul.js'), - makeOutput('umd', 'dist/umd/Hangul.min.js', terse), + makeOutput('iife', 'dist/Hangul.iife.min.js', terse), + makeOutput('cjs', 'dist/Hangul.cjs.min.js', terse), + makeOutput('umd', 'dist/Hangul.umd.min.js', terse), ]; } const o = makeOutput('iife', 'dev/bundle.js', [