-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
canBeChoseong
, canBeJungseong
, canBeJongseong
을 utils에서 별…
…도 함수로 분리합니다. (#193) * canBe series를 별도 함수로 분리합니다 * add change set
- Loading branch information
Showing
12 changed files
with
261 additions
and
478 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"es-hangul": major | ||
--- | ||
|
||
canBeChoseong, canBeJungseong, canBeJongseong 을 utils에서 별도 함수로 분리합니다. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# canBeChoseong | ||
|
||
Check if a given character can be a choseong in Korean. | ||
|
||
```typescript | ||
function canBeChoseong(character: string): boolean; | ||
``` | ||
|
||
```typescript | ||
canBeChoseong('ㄱ'); // true | ||
canBeChoseong('ㅃ'); // true | ||
canBeChoseong('ㄱㅅ'); // false | ||
canBeChoseong('ㅏ'); // false | ||
canBeChoseong('가'); // false | ||
``` | ||
|
||
# canBeJungseong | ||
|
||
Check if a given character can be a jungseong in Korean. | ||
|
||
```typescript | ||
function canBeJungseong(character: string): boolean; | ||
``` | ||
|
||
```typescript | ||
canBeJungseong('ㅏ'); // true | ||
canBeJungseong('ㅗㅏ'); // true | ||
canBeJungseong('ㅏㅗ'); // false | ||
canBeJungseong('ㄱ'); // false | ||
canBeJungseong('ㄱㅅ'); // false | ||
canBeJungseong('가'); // false | ||
``` | ||
|
||
# canBeJongseong | ||
|
||
Check if a given character can be a jongseong in Korean. | ||
|
||
```typescript | ||
function canBeJongseong(character: string): boolean; | ||
``` | ||
|
||
```typescript | ||
canBeJongseong('ㄱ'); // true | ||
canBeJongseong('ㄱㅅ'); // true | ||
canBeJongseong('ㅎㄹ'); // false | ||
canBeJongseong('가'); // false | ||
canBeJongseong('ㅏ'); // false | ||
canBeJongseong('ㅗㅏ'); // false | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# canBeChoseong | ||
|
||
인자로 받은 문자가 초성으로 위치할 수 있는 문자인지 검사합니다. | ||
|
||
```typescript | ||
function canBeChoseong(character: string): boolean; | ||
``` | ||
|
||
```typescript | ||
canBeChoseong('ㄱ'); // true | ||
canBeChoseong('ㅃ'); // true | ||
canBeChoseong('ㄱㅅ'); // false | ||
canBeChoseong('ㅏ'); // false | ||
canBeChoseong('가'); // false | ||
``` | ||
|
||
# canBeJungseong | ||
|
||
인자로 받은 문자가 중성으로 위치할 수 있는 문자인지 검사합니다. | ||
|
||
```typescript | ||
function canBeJungseong(character: string): boolean; | ||
``` | ||
|
||
```typescript | ||
canBeJungseong('ㅏ'); // true | ||
canBeJungseong('ㅗㅏ'); // true | ||
canBeJungseong('ㅏㅗ'); // false | ||
canBeJungseong('ㄱ'); // false | ||
canBeJungseong('ㄱㅅ'); // false | ||
canBeJungseong('가'); // false | ||
``` | ||
|
||
# canBeJongseong | ||
|
||
인자로 받은 문자가 종성으로 위치할 수 있는 문자인지 검사합니다. | ||
|
||
```typescript | ||
function canBeJongseong(character: string): boolean; | ||
``` | ||
|
||
```typescript | ||
canBeJongseong('ㄱ'); // true | ||
canBeJongseong('ㄱㅅ'); // true | ||
canBeJongseong('ㅎㄹ'); // false | ||
canBeJongseong('가'); // false | ||
canBeJongseong('ㅏ'); // false | ||
canBeJongseong('ㅗㅏ'); // false | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { canBeChoseong, canBeJongseong, canBeJungseong } from './canBe'; | ||
|
||
describe('canBeChoseong', () => { | ||
describe('초성이 될 수 있다고 판단되는 경우', () => { | ||
it('ㄱ', () => { | ||
expect(canBeChoseong('ㄱ')).toBe(true); | ||
}); | ||
it('ㅃ', () => { | ||
expect(canBeChoseong('ㅃ')).toBe(true); | ||
}); | ||
}); | ||
|
||
describe('초성이 될 수 없다고 판단되는 경우', () => { | ||
it('ㅏ', () => { | ||
expect(canBeChoseong('ㅏ')).toBe(false); | ||
}); | ||
it('ㅘ', () => { | ||
expect(canBeChoseong('ㅘ')).toBe(false); | ||
}); | ||
it('ㄱㅅ', () => { | ||
expect(canBeChoseong('ㄱㅅ')).toBe(false); | ||
}); | ||
it('가', () => { | ||
expect(canBeChoseong('가')).toBe(false); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('canBeJungseong', () => { | ||
describe('중성이 될 수 있다고 판단되는 경우', () => { | ||
it('ㅗㅏ', () => { | ||
expect(canBeJungseong('ㅗㅏ')).toBe(true); | ||
}); | ||
it('ㅏ', () => { | ||
expect(canBeJungseong('ㅏ')).toBe(true); | ||
}); | ||
}); | ||
|
||
describe('중성이 될 수 없다고 판단되는 경우', () => { | ||
it('ㄱ', () => { | ||
expect(canBeJungseong('ㄱ')).toBe(false); | ||
}); | ||
it('ㄱㅅ', () => { | ||
expect(canBeJungseong('ㄱㅅ')).toBe(false); | ||
}); | ||
it('가', () => { | ||
expect(canBeJungseong('가')).toBe(false); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('canBeJongseong', () => { | ||
describe('종성이 될 수 있다고 판단되는 경우', () => { | ||
it('ㄱ', () => { | ||
expect(canBeJongseong('ㄱ')).toBe(true); | ||
}); | ||
it('ㄱㅅ', () => { | ||
expect(canBeJongseong('ㄱㅅ')).toBe(true); | ||
}); | ||
it('ㅂㅅ', () => { | ||
expect(canBeJongseong('ㅂㅅ')).toBe(true); | ||
}); | ||
}); | ||
|
||
describe('종성이 될 수 없다고 판단되는 경우', () => { | ||
it('ㅎㄹ', () => { | ||
expect(canBeJongseong('ㅎㄹ')).toBe(false); | ||
}); | ||
it('ㅗㅏ', () => { | ||
expect(canBeJongseong('ㅗㅏ')).toBe(false); | ||
}); | ||
it('ㅏ', () => { | ||
expect(canBeJongseong('ㅏ')).toBe(false); | ||
}); | ||
it('가', () => { | ||
expect(canBeJongseong('ㅏ')).toBe(false); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { | ||
HANGUL_CHARACTERS_BY_FIRST_INDEX, | ||
HANGUL_CHARACTERS_BY_LAST_INDEX, | ||
HANGUL_CHARACTERS_BY_MIDDLE_INDEX, | ||
} from './constants'; | ||
import { hasValueInReadOnlyStringList } from './utils'; | ||
|
||
/** | ||
* @name canBeChoseong | ||
* @description | ||
* 인자로 받은 문자가 초성으로 위치할 수 있는 문자인지 검사합니다. | ||
* ```typescript | ||
* canBeChoseong( | ||
* // 대상 문자 | ||
* character: string | ||
* ): boolean | ||
* ``` | ||
* @example | ||
* canBeChoseong('ㄱ') // true | ||
* canBeChoseong('ㅃ') // true | ||
* canBeChoseong('ㄱㅅ') // false | ||
* canBeChoseong('ㅏ') // false | ||
* canBeChoseong('가') // false | ||
*/ | ||
export function canBeChoseong(character: string): character is (typeof HANGUL_CHARACTERS_BY_FIRST_INDEX)[number] { | ||
return hasValueInReadOnlyStringList(HANGUL_CHARACTERS_BY_FIRST_INDEX, character); | ||
} | ||
|
||
/** | ||
* @name canBeJungseong | ||
* @description | ||
* 인자로 받은 문자가 중성으로 위치할 수 있는 문자인지 검사합니다. | ||
* ```typescript | ||
* canBeJungseong( | ||
* // 대상 문자 | ||
* character: string | ||
* ): boolean | ||
* ``` | ||
* @example | ||
* canBeJungseong('ㅏ') // true | ||
* canBeJungseong('ㅗㅏ') // true | ||
* canBeJungseong('ㅏㅗ') // false | ||
* canBeJungseong('ㄱ') // false | ||
* canBeJungseong('ㄱㅅ') // false | ||
* canBeJungseong('가') // false | ||
*/ | ||
export function canBeJungseong(character: string): character is (typeof HANGUL_CHARACTERS_BY_MIDDLE_INDEX)[number] { | ||
return hasValueInReadOnlyStringList(HANGUL_CHARACTERS_BY_MIDDLE_INDEX, character); | ||
} | ||
|
||
/** | ||
* @name canBeJongseong | ||
* @description | ||
* 인자로 받은 문자가 종성으로 위치할 수 있는 문자인지 검사합니다. | ||
* ```typescript | ||
* canBeJongseong( | ||
* // 대상 문자 | ||
* character: string | ||
* ): boolean | ||
* ``` | ||
* @example | ||
* canBeJongseong('ㄱ') // true | ||
* canBeJongseong('ㄱㅅ') // true | ||
* canBeJongseong('ㅎㄹ') // false | ||
* canBeJongseong('가') // false | ||
* canBeJongseong('ㅏ') // false | ||
* canBeJongseong('ㅗㅏ') // false | ||
*/ | ||
export function canBeJongseong(character: string): character is (typeof HANGUL_CHARACTERS_BY_LAST_INDEX)[number] { | ||
return hasValueInReadOnlyStringList(HANGUL_CHARACTERS_BY_LAST_INDEX, character); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
export { assembleHangul } from './assemble'; | ||
export { canBeChoseong, canBeJongseong, canBeJungseong } from './canBe'; | ||
export { choseongIncludes } from './choseongIncludes'; | ||
export { chosungIncludes } from './chosungIncludes'; | ||
export { combineHangulCharacter, combineVowels, curriedCombineHangulCharacter } from './combineHangulCharacter'; | ||
export { convertQwertyToHangul, convertQwertyToHangulAlphabet } from './convertQwertyToHangulAlphabet'; | ||
export { disassemble, disassembleToGroups } from './disassemble'; | ||
export { disassembleCompleteCharacter } from './disassembleCompleteCharacter'; | ||
export { getChoseong } from './getChoseong'; | ||
export { josa } from './josa'; | ||
export { removeLastHangulCharacter } from './removeLastHangulCharacter'; | ||
export { romanize } from './romanize'; | ||
export { standardizePronunciation } from './standardizePronunciation'; | ||
export { susa } from './susa'; | ||
export { getChoseong } from './getChoseong'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.