Skip to content

Commit

Permalink
feat: getFirstConsonants에 deprecated를추가
Browse files Browse the repository at this point in the history
  • Loading branch information
BO-LIKE-CHICKEN committed Apr 25, 2024
1 parent de72eee commit 546d51e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,28 @@ export function getChosung(word: string) {
}, '');
}

/**
* @name getFirstConsonants
* @deprecated getChosung을 사용해 주세요.
* @description
* 단어에서 초성을 추출합니다. (예: `사과` -> `'ㅅㄱ'`)
* ```typescript
* getFirstConsonants(
* // 초성을 추출할 단어
* word: string
* ): string
* ```
* @example
* getFirstConsonants('사과') // 'ㅅㄱ'
* getFirstConsonants('리액트') // 'ㄹㅇㅌ'
* getFirstConsonants('띄어 쓰기') // 'ㄸㅇ ㅆㄱ'
*/
export function getFirstConsonants(word: string) {
return disassembleHangulToGroups(word).reduce((firstConsonants, [consonant]) => {
return `${firstConsonants}${consonant}`;
}, '');
}

/**
* @name canBeChosung
* @description
Expand Down

0 comments on commit 546d51e

Please sign in to comment.