Skip to content

Commit

Permalink
docs: v2 migration 가이드를 작성합니다. (#231)
Browse files Browse the repository at this point in the history
* migraiotn

* english traslation

---------

Co-authored-by: Jonghyeon Ko <[email protected]>
  • Loading branch information
okinawaa and manudeli authored Aug 9, 2024
1 parent 0633b9f commit 90c9cd8
Show file tree
Hide file tree
Showing 2 changed files with 367 additions and 0 deletions.
187 changes: 187 additions & 0 deletions docs/src/pages/docs/migration/v2.en.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
---
title: Migrating to v2
---

# Migrating to v2

## New Features

### The `hasBatchim` function now has additional options.

The `hasBatchim` function has been updated with an `only` option, allowing you to check if a string has a single batchim, double batchim, or any batchim at all.

```tsx
// Check if there is only a single batchim
hasBatchim('', { only: 'single' });

// Check if there is only a double batchim
hasBatchim('', { only: 'double' });

// Check if there is a batchim
hasBatchim('');

## Handling BREAKING CHANGES

### The acronymizeHangul function has been removed.

This function was removed as it was not closely related to Hangul domain needs.
If you need to extract initials, you can use the following method:

```tsx
string.split(' ').map(word => word.charAt(0));
```

### The assembleHangul function has been renamed.


As specified in the [CONTRIBUTING.md](https://github.com/toss/es-hangul/blob/main/.github/CONTRIBUTING.md), the hangul suffix has been removed from the function name.

```tsx
// ASIS
assembleHangul('ㄱ', 'ㅏ', 'ㅁ')
// TOBE
assemble('ㄱ', 'ㅏ', 'ㅁ')
```

### The choseongIncludes and chosungIncludes functions have been removed.

The process of extracting the initial consonants (choseong) is provided by es-hangul, and checking for inclusion can be done with basic JavaScript methods, so these functions have been removed. You can use the getChoseong function to extract choseong, then use the includes method.


```tsx
// ASIS
chosungIncludes('바나나', 'ㅂㄴㄴ');
choseongIncludes('바나나', 'ㅂㄴㄴ');

// TOBE

const choseonged = getChoseing('바나나');
chosunged.includes('ㅂㄴㄴ');
```
### The curriedCombineHangulCharacter function has been removed.
The curriedCombineHangulCharacter function was removed as it was not intended for direct user use.
If needed, you can implement it as follows:
```tsx

export const curriedCombineHangulCharacter=
(firstCharacter: string) =>
(middleCharacter: string) =>
(lastCharacter = '') =>
combineCharacter(firstCharacter, middleCharacter, lastCharacter);
```
### The combineHangulCharacter function has been renamed.
As specified in the [CONTRIBUTING.md](https://github.com/toss/es-hangul/blob/main/.github/CONTRIBUTING.md), the hangul suffix has been removed from the function name.
```tsx
// ASIS
combineHangulCharacter('', '', '')

// TOBE
combineCharacter('', '', '')
```
### The convertQwertyToHangulAlphabet function has been renamed.
As specified in the [CONTRIBUTING.md](https://github.com/toss/es-hangul/blob/main/.github/CONTRIBUTING.md), the hangul suffix has been removed from the function name.
```tsx
// ASIS
convertQwertyToHangulAlphabet('r')

// TOBE
convertQwertyToAlphabet('r')
```
### The disassembleHangul, disassembleHangulToGroups, and disassembleCompleteHangulCharacter functions have been renamed.
As specified in the [CONTRIBUTING.md](https://github.com/toss/es-hangul/blob/main/.github/CONTRIBUTING.md), the hangul suffix has been removed from the function name.
```tsx
// ASIS
disassembleHangul('');
disassembleHangulToGroups('');
disassembleCompleteHangulCharacter('');

// TOBE
disassemble('');
disassembleToGroups('');
disassembleCompleteCharacter('');
```
### The `extractHangul` function has been removed.
It was removed as it is not closely related to the Hangul domain.<br/>
### The `hangulIncludes` function has been removed.
It was removed as it is not closely related to the Hangul domain.<br/>
If needed, you can use the following method:
```tsx
function hangulIncludes(x: string, y: string) {
const disassembledX = disassembleHangul(x);
const disassembledY = disassembleHangul(y);

return disassembledX.includes(disassembledY);
}

### The function name removeLastHangulCharacter has been changed.

As specified in the [CONTRIBUTING.md](https://github.com/toss/es-hangul/blob/main/.github/CONTRIBUTING.md), the hangul suffix has been removed from the function name.


```tsx
// ASIS
removeLastHangulCharacter('감');
// TOBE
removeLastCharacter('감');
```

### The hasProperty and hasValueInReadOnlyStringList functions have been removed.


They were removed as they are not closely related to the Hangul domain.

If needed, you can use the following method:

```tsx
export function hasValueInReadOnlyStringList<T extends string>(list: readonly T[], value: string): value is T {
return list.some(item => item === value);
}
export function hasProperty<T extends object, K extends PropertyKey>(obj: T, key: K): key is K & keyof T {
return Object.prototype.hasOwnProperty.call(obj, key);
}
```

### The hasSingleBatchim function has been removed.


The hasBatchim function now accepts an option to handle this use case.

```tsx
// ASIS
hasSingleBatchim('감');
// TOBE
hasBatchim('감', { only: "single" });
```


180 changes: 180 additions & 0 deletions docs/src/pages/docs/migration/v2.ko.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
---
title: v2로 마이그레이션하기
---

# v2로 마이그레이션하기

## 새로운 기능

### hasBatchim 함수에 옵션이 추가되었어요.

`hasBatchim` 함수에 `only` 옵션을 추가하여 단일 받침만 있는지, 복수 받침만 있는지, 받침이 있는지 없는지를 확인할 수 있어요.

```tsx
// 단일 받침만 있는지 확인
hasBatchim('', { only: 'single' });

// 복수 받침만 있는지 확인
hasBatchim('', { only: 'double' });

// 받침이 있는지 확인
hasBatchim('');
```

## BREAKING CHANGES 처리하기

### acronymizeHangul 함수가 삭제되었어요.

한글 도메인과 크게 관련이 없어서 제거되었어요.<br/>
두음을 추출해야하는 경우가 있으면 아래와 같이 사용하면 되어요.

```tsx
string.split(' ').map(word => word.charAt(0));
```

### assembleHangul의 함수명이 바뀌었어요.

[CONTRIBUTING.md](https://github.com/toss/es-hangul/blob/main/.github/CONTRIBUTING.md)에 적혀있는 대로 함수명에서 hangul을 제거하였어요.

```tsx
// ASIS
assembleHangul('', '', '')

// TOBE
assemble('', '', '')
```

### choseongIncludes, chosungIncludes 함수가 삭제되었어요.

초성화하는 과정은 es-hangul에서 제공하고, 문자열의 포함 여부는 자바스크립트 기본 메서드로 충분하다고 판단하여 제거하였어요.
[getChoseong](https://es-hangul.slash.page/docs/api/getChoseong) 함수를 사용하여 초성화한 후, includes 메서드를 사용하면 됩니다.

```tsx
// ASIS
chosungIncludes('바나나', 'ㅂㄴㄴ');
choseongIncludes('바나나', 'ㅂㄴㄴ');

// TOBE

const choseonged = getChoseing('바나나');
chosunged.includes('ㅂㄴㄴ');
```


### curriedCombineHangulCharacter 함수가 삭제되었어요.

curriedCombineHangulCharacter함수는 사용자가 직접 사용할 일이 없어서 제거되었어요.<br/>
사용이 필요하다면 아래와 같이 사용하면 됩니다.

```tsx

export const curriedCombineHangulCharacter=
(firstCharacter: string) =>
(middleCharacter: string) =>
(lastCharacter = '') =>
combineCharacter(firstCharacter, middleCharacter, lastCharacter);
```


### combineHangulCharacter의 함수명이 변경되었어요.

[CONTRIBUTING.md](https://github.com/toss/es-hangul/blob/main/.github/CONTRIBUTING.md)에 적혀있는 대로 함수명에서 hangul을 제거하였어요.

```tsx
// ASIS
combineHangulCharacter('', '', '')

// TOBE
combineCharacter('', '', '')
```


### convertQwertyToHangulAlphabet의 함수명이 변경되었어요.

[CONTRIBUTING.md](https://github.com/toss/es-hangul/blob/main/.github/CONTRIBUTING.md)에 적혀있는 대로 함수명에서 hangul을 제거하였어요.

```tsx
// ASIS
convertQwertyToHangulAlphabet('r')

// TOBE
convertQwertyToAlphabet('r')
```

### disassembleHangul, disassembleHangulToGroups, disassembleCompleteHangulCharacter의 함수명이 변경되었어요.

[CONTRIBUTING.md](https://github.com/toss/es-hangul/blob/main/.github/CONTRIBUTING.md)에 적혀있는 대로 함수명에서 hangul을 제거하였어요.


```tsx
// ASIS
disassembleHangul('');
disassembleHangulToGroups('');
disassembleCompleteHangulCharacter('');

// TOBE
disassemble('');
disassembleToGroups('');
disassembleCompleteCharacter('');
```

### extractHangul 함수가 삭제되었어요.

한글 도메인과 크게 관련이 없어서 제거되었어요.<br/>

### hangulIncludes 함수가 삭제되었어요.

한글 도메인과 크게 관련이 없어서 제거되었어요.<br/>

필요하다면 다음과 같이 사용해주세요.

```tsx
function hangulIncludes(x: string, y: string) {
const disassembledX = disassembleHangul(x);
const disassembledY = disassembleHangul(y);

return disassembledX.includes(disassembledY);
}
```

### removeLastHangulCharacter의 함수명이 변경되었어요.

[CONTRIBUTING.md](https://github.com/toss/es-hangul/blob/main/.github/CONTRIBUTING.md)에 적혀있는 대로 함수명에서 hangul을 제거하였어요.

```tsx
// ASIS
removeLastHangulCharacter('');

// TOBE
removeLastCharacter('');
```

### hasProperty, hasValueInReadOnlyStringList 함수가 삭제되었어요.

한글 도메인과 크게 관련이 없어서 제거되었어요.<br/>

필요하다면 다음과 같이 사용해주세요.

```tsx
export function hasValueInReadOnlyStringList<T extends string>(list: readonly T[], value: string): value is T {
return list.some(item => item === value);
}

export function hasProperty<T extends object, K extends PropertyKey>(obj: T, key: K): key is K & keyof T {
return Object.prototype.hasOwnProperty.call(obj, key);
}

```

### hasSingleBatchim함수가 삭제되었어요.

hasBatchim에 옵션을 주어 사용이 가능해요.

```tsx
// ASIS
hasSingleBatchim('');

// TOBE
hasBatchim('', { only: "single" });
```

0 comments on commit 90c9cd8

Please sign in to comment.