mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-30 18:23:22 +03:00
docs(flowRight): Add docs for flowRight
This commit is contained in:
parent
75ed97afa0
commit
5553908173
53
docs/ja/reference/function/flowRight.md
Normal file
53
docs/ja/reference/function/flowRight.md
Normal file
@ -0,0 +1,53 @@
|
||||
# flowRight
|
||||
|
||||
右から左に順番に与えられた関数を実行する新しい関数を作成します。前の関数の戻り値が次の関数への引数として渡されます。
|
||||
|
||||
戻り関数の`this`コンテキストも、パラメーターとして提供された関数に渡されます。
|
||||
|
||||
このメソッドは`flow`のようですが、右から左に与えられた関数を呼び出す関数を作成する点が異なります。
|
||||
|
||||
## インターフェース
|
||||
|
||||
```typescript
|
||||
function flowRight<R>(f: () => R): () => R;
|
||||
function flowRight<A extends any[], R>(f1: (...args: A) => R): (...args: A) => R;
|
||||
function flowRight<A extends any[], R1, R2>(f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R2;
|
||||
function flowRight<A extends any[], R1, R2, R3>(
|
||||
f3: (a: R2) => R3,
|
||||
f2: (a: R1) => R2,
|
||||
f1: (...args: A) => R1
|
||||
): (...args: A) => R3;
|
||||
function flowRight<A extends any[], R1, R2, R3, R4>(
|
||||
f4: (a: R3) => R4,
|
||||
f3: (a: R2) => R3,
|
||||
f2: (a: R1) => R2,
|
||||
f1: (...args: A) => R1
|
||||
): (...args: A) => R4;
|
||||
function flowRight<A extends any[], R1, R2, R3, R4, R5>(
|
||||
f5: (a: R4) => R5,
|
||||
f4: (a: R3) => R4,
|
||||
f3: (a: R2) => R3,
|
||||
f2: (a: R1) => R2,
|
||||
f1: (...args: A) => R1
|
||||
): (...args: A) => R5;
|
||||
function flowRight(...funcs: Array<(...args: any[]) => any>): (...args: any[]) => any;
|
||||
function flowRight(...funcs: Array<(...args: any[]) => any>): (...args: any[]) => any;
|
||||
```
|
||||
|
||||
### パラメータ
|
||||
|
||||
- `funcs` (`(...args: any[]) => any`): 呼び出す関数。
|
||||
|
||||
### 戻り値
|
||||
|
||||
(`(...args: any[]) => any`): 新しい合成関数。
|
||||
|
||||
## 例
|
||||
|
||||
```typescript
|
||||
const add = (x: number, y: number) => x + y;
|
||||
const square = (n: number) => n * n;
|
||||
|
||||
const combined = flowRight(square, add);
|
||||
console.log(combined(1, 2)); // 9
|
||||
```
|
53
docs/ko/reference/function/flowRight.md
Normal file
53
docs/ko/reference/function/flowRight.md
Normal file
@ -0,0 +1,53 @@
|
||||
# flowRight
|
||||
|
||||
주어진 함수들을 오른쪽에서 왼쪽으로 순서대로 실행하는 새로운 함수를 생성해요. 이전 함수의 결괏값은 다음 함수의 파라미터로 주어져요.
|
||||
|
||||
반환된 함수에게 주어진 `this`는 파라미터로 주어진 함수들에게도 전달돼요.
|
||||
|
||||
이 메서드는 `flow`와 비슷하지만, 주어진 함수들을 오른쪽에서 왼쪽으로 호출하는 함수를 생성해요.
|
||||
|
||||
## 인터페이스
|
||||
|
||||
```typescript
|
||||
function flowRight<R>(f: () => R): () => R;
|
||||
function flowRight<A extends any[], R>(f1: (...args: A) => R): (...args: A) => R;
|
||||
function flowRight<A extends any[], R1, R2>(f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R2;
|
||||
function flowRight<A extends any[], R1, R2, R3>(
|
||||
f3: (a: R2) => R3,
|
||||
f2: (a: R1) => R2,
|
||||
f1: (...args: A) => R1
|
||||
): (...args: A) => R3;
|
||||
function flowRight<A extends any[], R1, R2, R3, R4>(
|
||||
f4: (a: R3) => R4,
|
||||
f3: (a: R2) => R3,
|
||||
f2: (a: R1) => R2,
|
||||
f1: (...args: A) => R1
|
||||
): (...args: A) => R4;
|
||||
function flowRight<A extends any[], R1, R2, R3, R4, R5>(
|
||||
f5: (a: R4) => R5,
|
||||
f4: (a: R3) => R4,
|
||||
f3: (a: R2) => R3,
|
||||
f2: (a: R1) => R2,
|
||||
f1: (...args: A) => R1
|
||||
): (...args: A) => R5;
|
||||
function flowRight(...funcs: Array<(...args: any[]) => any>): (...args: any[]) => any;
|
||||
function flowRight(...funcs: Array<(...args: any[]) => any>): (...args: any[]) => any;
|
||||
```
|
||||
|
||||
### 파라미터
|
||||
|
||||
- `funcs` (`(...args: any[]) => any`): 호출할 함수들.
|
||||
|
||||
### 반환 값
|
||||
|
||||
(`(...args: any[]) => any`): 주어진 함수들을 오른쪽에서 왼쪽으로 순서대로 실행하는 새로운 함수.
|
||||
|
||||
## 예시
|
||||
|
||||
```typescript
|
||||
const add = (x: number, y: number) => x + y;
|
||||
const square = (n: number) => n * n;
|
||||
|
||||
const combined = flowRight(square, add);
|
||||
console.log(combined(1, 2)); // 9
|
||||
```
|
@ -1,6 +1,8 @@
|
||||
# flowRight
|
||||
|
||||
Creates a function that returns the result of invoking the given functions with the `this` binding of the created function, where each successive invocation is supplied the return value of the previous.
|
||||
Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.
|
||||
|
||||
The `this` context of the returned function is also passed to the functions provided as parameters.
|
||||
|
||||
This method is like [flow](./flow.md), except that it creates a function that invokes the given functions from right to left.
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
# flowRight
|
||||
|
||||
创建一个函数,该函数返回调用给定函数的结果,并将创建函数的 `this` 绑定传递给这些函数,每次调用时将上一次调用的返回值作为参数传递给下一次调用。
|
||||
创建一个新函数,该函数按从右到左的顺序执行给定的函数。前一个函数的返回值作为参数传递给下一个函数。
|
||||
|
||||
返回函数的 `this` 上下文也会传递给作为参数提供的函数。
|
||||
|
||||
此方法类似于 [flow](./flow.md),但它创建的函数从右到左调用给定的函数。
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
/**
|
||||
* Creates a function that returns the result of invoking the given functions with the `this` binding of the created function, where each successive invocation is supplied the return value of the previous.
|
||||
* Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.
|
||||
*
|
||||
* The `this` context of the returned function is also passed to the functions provided as parameters.
|
||||
*
|
||||
* @param {() => R} f The function to invoke.
|
||||
* @returns {() => R} Returns the new composite function.
|
||||
@ -14,7 +16,9 @@
|
||||
*/
|
||||
export function flow<R>(f: () => R): () => R;
|
||||
/**
|
||||
* Creates a function that returns the result of invoking the given functions with the `this` binding of the created function, where each successive invocation is supplied the return value of the previous.
|
||||
* Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.
|
||||
*
|
||||
* The `this` context of the returned function is also passed to the functions provided as parameters.
|
||||
*
|
||||
* @param {(...args: A) => R} f1 The function to invoke.
|
||||
* @returns {(...args: A) => R} Returns the new composite function.
|
||||
@ -29,7 +33,9 @@ export function flow<R>(f: () => R): () => R;
|
||||
*/
|
||||
export function flow<A extends any[], R>(f1: (...args: A) => R): (...args: A) => R;
|
||||
/**
|
||||
* Creates a function that returns the result of invoking the given functions with the `this` binding of the created function, where each successive invocation is supplied the return value of the previous.
|
||||
* Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.
|
||||
*
|
||||
* The `this` context of the returned function is also passed to the functions provided as parameters.
|
||||
*
|
||||
* @param {(...args: A) => R1} f1 The function to invoke.
|
||||
* @param {(a: R1) => R2} f2 The function to invoke.
|
||||
@ -44,7 +50,9 @@ export function flow<A extends any[], R>(f1: (...args: A) => R): (...args: A) =>
|
||||
*/
|
||||
export function flow<A extends any[], R1, R2>(f1: (...args: A) => R1, f2: (a: R1) => R2): (...args: A) => R2;
|
||||
/**
|
||||
* Creates a function that returns the result of invoking the given functions with the `this` binding of the created function, where each successive invocation is supplied the return value of the previous.
|
||||
* Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.
|
||||
*
|
||||
* The `this` context of the returned function is also passed to the functions provided as parameters.
|
||||
*
|
||||
* @param {(...args: A) => R1} f1 The function to invoke.
|
||||
* @param {(a: R1) => R2} f2 The function to invoke.
|
||||
@ -65,7 +73,9 @@ export function flow<A extends any[], R1, R2, R3>(
|
||||
f3: (a: R2) => R3
|
||||
): (...args: A) => R3;
|
||||
/**
|
||||
* Creates a function that returns the result of invoking the given functions with the `this` binding of the created function, where each successive invocation is supplied the return value of the previous.
|
||||
* Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.
|
||||
*
|
||||
* The `this` context of the returned function is also passed to the functions provided as parameters.
|
||||
*
|
||||
* @param {(...args: A) => R1} f1 The function to invoke.
|
||||
* @param {(a: R1) => R2} f2 The function to invoke.
|
||||
@ -89,7 +99,9 @@ export function flow<A extends any[], R1, R2, R3, R4>(
|
||||
f4: (a: R3) => R4
|
||||
): (...args: A) => R4;
|
||||
/**
|
||||
* Creates a function that returns the result of invoking the given functions with the `this` binding of the created function, where each successive invocation is supplied the return value of the previous.
|
||||
* Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.
|
||||
*
|
||||
* The `this` context of the returned function is also passed to the functions provided as parameters.
|
||||
*
|
||||
* @param {(...args: A) => R1} f1 The function to invoke.
|
||||
* @param {(a: R1) => R2} f2 The function to invoke.
|
||||
@ -116,7 +128,9 @@ export function flow<A extends any[], R1, R2, R3, R4, R5>(
|
||||
f5: (a: R4) => R5
|
||||
): (...args: A) => R5;
|
||||
/**
|
||||
* Creates a function that returns the result of invoking the given functions with the `this` binding of the created function, where each successive invocation is supplied the return value of the previous.
|
||||
* Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.
|
||||
*
|
||||
* The `this` context of the returned function is also passed to the functions provided as parameters.
|
||||
*
|
||||
* @param {Array<(...args: any[]) => any>} funcs The functions to invoke.
|
||||
* @returns {(...args: any[]) => any} Returns the new composite function.
|
||||
@ -130,7 +144,9 @@ export function flow<A extends any[], R1, R2, R3, R4, R5>(
|
||||
*/
|
||||
export function flow(...funcs: Array<(...args: any[]) => any>): (...args: any[]) => any;
|
||||
/**
|
||||
* Creates a function that returns the result of invoking the given functions with the `this` binding of the created function, where each successive invocation is supplied the return value of the previous.
|
||||
* Creates a new function that executes the given functions in sequence. The return value of the previous function is passed as an argument to the next function.
|
||||
*
|
||||
* The `this` context of the returned function is also passed to the functions provided as parameters.
|
||||
*
|
||||
* @param {Array<(...args: any[]) => any>} funcs The functions to invoke.
|
||||
* @returns {(...args: any[]) => any} Returns the new composite function.
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { flow } from './flow.ts';
|
||||
|
||||
/**
|
||||
* Creates a function that returns the result of invoking the given functions with the `this` binding of the created function, where each successive invocation is supplied the return value of the previous.
|
||||
* Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.
|
||||
*
|
||||
* The `this` context of the returned function is also passed to the functions provided as parameters.
|
||||
*
|
||||
* This method is like `flow` except that it creates a function that invokes the given functions from right to left.
|
||||
*
|
||||
@ -17,7 +19,9 @@ import { flow } from './flow.ts';
|
||||
*/
|
||||
export function flowRight<R>(f: () => R): () => R;
|
||||
/**
|
||||
* Creates a function that returns the result of invoking the given functions with the `this` binding of the created function, where each successive invocation is supplied the return value of the previous.
|
||||
* Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.
|
||||
*
|
||||
* The `this` context of the returned function is also passed to the functions provided as parameters.
|
||||
*
|
||||
* This method is like `flow` except that it creates a function that invokes the given functions from right to left.
|
||||
*
|
||||
@ -33,7 +37,9 @@ export function flowRight<R>(f: () => R): () => R;
|
||||
*/
|
||||
export function flowRight<A extends any[], R>(f1: (...args: A) => R): (...args: A) => R;
|
||||
/**
|
||||
* Creates a function that returns the result of invoking the given functions with the `this` binding of the created function, where each successive invocation is supplied the return value of the previous.
|
||||
* Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.
|
||||
*
|
||||
* The `this` context of the returned function is also passed to the functions provided as parameters.
|
||||
*
|
||||
* This method is like `flow` except that it creates a function that invokes the given functions from right to left.
|
||||
*
|
||||
@ -50,7 +56,9 @@ export function flowRight<A extends any[], R>(f1: (...args: A) => R): (...args:
|
||||
*/
|
||||
export function flowRight<A extends any[], R1, R2>(f2: (a: R1) => R2, f1: (...args: A) => R1): (...args: A) => R2;
|
||||
/**
|
||||
* Creates a function that returns the result of invoking the given functions with the `this` binding of the created function, where each successive invocation is supplied the return value of the previous.
|
||||
* Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.
|
||||
*
|
||||
* The `this` context of the returned function is also passed to the functions provided as parameters.
|
||||
*
|
||||
* This method is like `flow` except that it creates a function that invokes the given functions from right to left.
|
||||
*
|
||||
@ -73,7 +81,9 @@ export function flowRight<A extends any[], R1, R2, R3>(
|
||||
f1: (...args: A) => R1
|
||||
): (...args: A) => R3;
|
||||
/**
|
||||
* Creates a function that returns the result of invoking the given functions with the `this` binding of the created function, where each successive invocation is supplied the return value of the previous.
|
||||
* Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.
|
||||
*
|
||||
* The `this` context of the returned function is also passed to the functions provided as parameters.
|
||||
*
|
||||
* This method is like `flow` except that it creates a function that invokes the given functions from right to left.
|
||||
*
|
||||
@ -99,7 +109,9 @@ export function flowRight<A extends any[], R1, R2, R3, R4>(
|
||||
f1: (...args: A) => R1
|
||||
): (...args: A) => R4;
|
||||
/**
|
||||
* Creates a function that returns the result of invoking the given functions with the `this` binding of the created function, where each successive invocation is supplied the return value of the previous.
|
||||
* Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.
|
||||
*
|
||||
* The `this` context of the returned function is also passed to the functions provided as parameters.
|
||||
*
|
||||
* This method is like `flow` except that it creates a function that invokes the given functions from right to left.
|
||||
*
|
||||
@ -128,7 +140,9 @@ export function flowRight<A extends any[], R1, R2, R3, R4, R5>(
|
||||
f1: (...args: A) => R1
|
||||
): (...args: A) => R5;
|
||||
/**
|
||||
* Creates a function that returns the result of invoking the given functions with the `this` binding of the created function, where each successive invocation is supplied the return value of the previous.
|
||||
* Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.
|
||||
*
|
||||
* The `this` context of the returned function is also passed to the functions provided as parameters.
|
||||
*
|
||||
* This method is like `flow` except that it creates a function that invokes the given functions from right to left.
|
||||
*
|
||||
@ -144,7 +158,9 @@ export function flowRight<A extends any[], R1, R2, R3, R4, R5>(
|
||||
*/
|
||||
export function flowRight(...funcs: Array<(...args: any[]) => any>): (...args: any[]) => any;
|
||||
/**
|
||||
* Creates a function that returns the result of invoking the given functions with the `this` binding of the created function, where each successive invocation is supplied the return value of the previous.
|
||||
* Creates a new function that executes the given functions in sequence from right to left. The return value of the previous function is passed as an argument to the next function.
|
||||
*
|
||||
* The `this` context of the returned function is also passed to the functions provided as parameters.
|
||||
*
|
||||
* This method is like `flow` except that it creates a function that invokes the given functions from right to left.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user