docs(flow): Update docs (#630)

* docs(flow): Update docs

* Update docs/ko/reference/function/flow.md

* Update docs/ko/reference/function/flow.md

---------

Co-authored-by: Sojin Park <raon0211@gmail.com>
This commit is contained in:
Dongho Kim 2024-10-01 20:21:21 +09:00 committed by GitHub
parent 665f4409a4
commit 832ecc53da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 36 additions and 0 deletions

View File

@ -48,3 +48,21 @@ const square = (n: number) => n * n;
const combined = flow(add, square);
console.log(combined(1, 2)); // 9
```
## Lodash 互換性
`es-toolkit/compat` から `flow` をインポートすると、Lodash と互換になります。
- `flow` は関数の配列と個別の関数の両方を引数として受け入れます。
- 提供された関数が関数でない場合、`flow` はエラーをスローします。
```typescript
import { flow } from 'es-toolkit/compat';
const add = (x: number, y: number) => x + y;
const square = (n: number) => n * n;
const double = (n: number) => n * 2;
const combined = flow([add, square], double);
console.log(combined(1, 2)); // => 18
```

View File

@ -48,3 +48,21 @@ const square = (n: number) => n * n;
const combined = flow(add, square);
console.log(combined(1, 2)); // 9
```
## Lodash와 호환성
`es-toolkit/compat`에서 `flow`를 가져오면 lodash와 완전히 호환돼요.
- `flow`는 파라미터로 개별 함수뿐만 아니라 함수들의 배열도 받을 수 있어요.
- 파라미터로 함수가 아닌 값이 주어지면 `flow`는 오류를 발생시켜요.
```typescript
import { flow } from 'es-toolkit/compat';
const add = (x: number, y: number) => x + y;
const square = (n: number) => n * n;
const double = (n: number) => n * 2;
const combined = flow([add, square], double);
console.log(combined(1, 2)); // => 18
```