diff --git a/docs/ja/reference/compat/function/defer.md b/docs/ja/reference/compat/function/defer.md index 2a1de8f9..4284fc8b 100644 --- a/docs/ja/reference/compat/function/defer.md +++ b/docs/ja/reference/compat/function/defer.md @@ -26,8 +26,8 @@ function defer any>(func: F, ...args: Parameters { +defer(text => { console.log(text); }, 'deferred'); // => Logs 'deferred' after the current call stack has cleared. -``` \ No newline at end of file +``` diff --git a/docs/ja/reference/compat/util/toFinite.md b/docs/ja/reference/compat/util/toFinite.md index bb7fb109..9a984749 100644 --- a/docs/ja/reference/compat/util/toFinite.md +++ b/docs/ja/reference/compat/util/toFinite.md @@ -31,4 +31,4 @@ toNumber(Infinity); // => 1.7976931348623157e+308 toNumber('3.2'); // => 3.2 toNumber(Symbol.iterator); // => 0 toNumber(NaN); // => 0 -``` \ No newline at end of file +``` diff --git a/docs/ja/reference/compat/util/toInteger.md b/docs/ja/reference/compat/util/toInteger.md index 2998e71c..94fc1343 100644 --- a/docs/ja/reference/compat/util/toInteger.md +++ b/docs/ja/reference/compat/util/toInteger.md @@ -31,4 +31,4 @@ toInteger(Infinity); // => 1.7976931348623157e+308 toInteger('3.2'); // => 3 toInteger(Symbol.iterator); // => 0 toInteger(NaN); // => 0 -``` \ No newline at end of file +``` diff --git a/docs/ja/reference/compat/util/toNumber.md b/docs/ja/reference/compat/util/toNumber.md index 692a6a83..8988ca01 100644 --- a/docs/ja/reference/compat/util/toNumber.md +++ b/docs/ja/reference/compat/util/toNumber.md @@ -33,4 +33,4 @@ toNumber(Infinity); // => Infinity toNumber('3.2'); // => 3.2 toNumber(Symbol.iterator); // => NaN toNumber(NaN); // => NaN -``` \ No newline at end of file +``` diff --git a/docs/ja/reference/function/flow.md b/docs/ja/reference/function/flow.md new file mode 100644 index 00000000..e1321d13 --- /dev/null +++ b/docs/ja/reference/function/flow.md @@ -0,0 +1,50 @@ +# flow + +与えられた関数を順番に実行する新しい関数を作成します。前の関数の戻り値は次の関数への引数として渡されます。 + +返された関数の `this` コンテキストも、パラメータとして提供された関数に渡されます。 + +## インターフェース + +```typescript +function flow(f: () => R): () => R; +function flow(f1: (...args: A) => R): (...args: A) => R; +function flow(f1: (...args: A) => R1, f2: (a: R1) => R2): (...args: A) => R2; +function flow( + f1: (...args: A) => R1, + f2: (a: R1) => R2, + f3: (a: R2) => R3 +): (...args: A) => R3; +function flow( + f1: (...args: A) => R1, + f2: (a: R1) => R2, + f3: (a: R2) => R3, + f4: (a: R3) => R4 +): (...args: A) => R4; +function flow( + f1: (...args: A) => R1, + f2: (a: R1) => R2, + f3: (a: R2) => R3, + f4: (a: R3) => R4, + f5: (a: R4) => R5 +): (...args: A) => R5; +function flow(...funcs: Array<(...args: any[]) => any>): (...args: any[]) => any; +``` + +### パラメータ + +- `funcs` (`Array<(...args: any[]) => any>`): 呼び出す関数。 + +### 戻り値 + +(`(...args: any[]) => any`): 新しい合成関数。 + +## 例 + +```typescript +const add = (x: number, y: number) => x + y; +const square = (n: number) => n * n; + +const combined = flow(add, square); +console.log(combined(1, 2)); // 9 +``` diff --git a/docs/ja/reference/string/camelCase.md b/docs/ja/reference/string/camelCase.md index 23ea5e4a..9579ccbe 100644 --- a/docs/ja/reference/string/camelCase.md +++ b/docs/ja/reference/string/camelCase.md @@ -27,5 +27,5 @@ camelCase('camelCase'); // 'camelCase' を返します camelCase('some whitespace'); // 'someWhitespace' を返します camelCase('hyphen-text'); // 'hyphenText' を返します camelCase('HTTPRequest'); // 'httpRequest' を返します -camelCase('Keep unicode 😅') // 'keepUnicode😅' を返します +camelCase('Keep unicode 😅'); // 'keepUnicode😅' を返します ``` diff --git a/docs/ja/reference/string/constantCase.md b/docs/ja/reference/string/constantCase.md index f778cdc4..4c9d743b 100644 --- a/docs/ja/reference/string/constantCase.md +++ b/docs/ja/reference/string/constantCase.md @@ -21,8 +21,8 @@ function constantCase(str: string): string; ## 例 ```typescript -const convertedStr1 = constantCase('camelCase') // returns 'CAMEL_CASE' -const convertedStr2 = constantCase('some whitespace') // returns 'SOME_WHITESPACE' -const convertedStr3 = constantCase('hyphen-text') // returns 'HYPHEN_TEXT' -const convertedStr4 = constantCase('HTTPRequest') // returns 'HTTP_REQUEST' -``` \ No newline at end of file +const convertedStr1 = constantCase('camelCase'); // returns 'CAMEL_CASE' +const convertedStr2 = constantCase('some whitespace'); // returns 'SOME_WHITESPACE' +const convertedStr3 = constantCase('hyphen-text'); // returns 'HYPHEN_TEXT' +const convertedStr4 = constantCase('HTTPRequest'); // returns 'HTTP_REQUEST' +``` diff --git a/docs/ko/reference/compat/function/defer.md b/docs/ko/reference/compat/function/defer.md index af42c2e2..dcde7d14 100644 --- a/docs/ko/reference/compat/function/defer.md +++ b/docs/ko/reference/compat/function/defer.md @@ -26,8 +26,8 @@ function defer any>(func: F, ...args: Parameters { +defer(text => { console.log(text); }, 'deferred'); // => Logs 'deferred' after the current call stack has cleared. -``` \ No newline at end of file +``` diff --git a/docs/ko/reference/compat/util/toFinite.md b/docs/ko/reference/compat/util/toFinite.md index a476954f..0e05fac5 100644 --- a/docs/ko/reference/compat/util/toFinite.md +++ b/docs/ko/reference/compat/util/toFinite.md @@ -31,4 +31,4 @@ toNumber(Infinity); // => 1.7976931348623157e+308 toNumber('3.2'); // => 3.2 toNumber(Symbol.iterator); // => 0 toNumber(NaN); // => 0 -``` \ No newline at end of file +``` diff --git a/docs/ko/reference/compat/util/toInteger.md b/docs/ko/reference/compat/util/toInteger.md index 233bac39..3420f9d0 100644 --- a/docs/ko/reference/compat/util/toInteger.md +++ b/docs/ko/reference/compat/util/toInteger.md @@ -6,7 +6,7 @@ `es-toolkit/compat`에서 이 함수를 가져오면, [lodash와 완전히 똑같이 동작](../../../compatibility.md)해요. ::: - `value`를 정수로 변환해요. 무한한 값인 경우, 유한한 값으로 변환돼요. 소숫점 아래 숫자는 버려요. +`value`를 정수로 변환해요. 무한한 값인 경우, 유한한 값으로 변환돼요. 소숫점 아래 숫자는 버려요. ## 인터페이스 @@ -31,4 +31,4 @@ toInteger(Infinity); // => 1.7976931348623157e+308 toInteger('3.2'); // => 3 toInteger(Symbol.iterator); // => 0 toInteger(NaN); // => 0 -``` \ No newline at end of file +``` diff --git a/docs/ko/reference/compat/util/toNumber.md b/docs/ko/reference/compat/util/toNumber.md index 9ec90f45..fedede63 100644 --- a/docs/ko/reference/compat/util/toNumber.md +++ b/docs/ko/reference/compat/util/toNumber.md @@ -34,4 +34,4 @@ toNumber(Infinity); // => Infinity toNumber('3.2'); // => 3.2 toNumber(Symbol.iterator); // => NaN toNumber(NaN); // => NaN -``` \ No newline at end of file +``` diff --git a/docs/ko/reference/function/flow.md b/docs/ko/reference/function/flow.md new file mode 100644 index 00000000..4610fda9 --- /dev/null +++ b/docs/ko/reference/function/flow.md @@ -0,0 +1,50 @@ +# flow + +주어진 함수들을 연속해서 실행하는 새로운 함수를 만들어요. 이전 함수의 결괏값은 다음 함수의 인자로 주어져요. + +반환된 함수에게 주어진 `this`는 파라미터로 주어진 함수들에게도 전달돼요. + +## 인터페이스 + +```typescript +function flow(f: () => R): () => R; +function flow(f1: (...args: A) => R): (...args: A) => R; +function flow(f1: (...args: A) => R1, f2: (a: R1) => R2): (...args: A) => R2; +function flow( + f1: (...args: A) => R1, + f2: (a: R1) => R2, + f3: (a: R2) => R3 +): (...args: A) => R3; +function flow( + f1: (...args: A) => R1, + f2: (a: R1) => R2, + f3: (a: R2) => R3, + f4: (a: R3) => R4 +): (...args: A) => R4; +function flow( + f1: (...args: A) => R1, + f2: (a: R1) => R2, + f3: (a: R2) => R3, + f4: (a: R3) => R4, + f5: (a: R4) => R5 +): (...args: A) => R5; +function flow(...funcs: Array<(...args: any[]) => any>): (...args: any[]) => any; +``` + +### 파라미터 + +- `funcs` (`Array<(...args: any[]) => any>`): 호출할 함수들. + +### 반환 값 + +(`(...args: any[]) => any`): 주어진 함수들을 연속해서 실행하는 새로운 함수. + +## 예시 + +```typescript +const add = (x: number, y: number) => x + y; +const square = (n: number) => n * n; + +const combined = flow(add, square); +console.log(combined(1, 2)); // 9 +``` diff --git a/docs/ko/reference/string/camelCase.md b/docs/ko/reference/string/camelCase.md index 8f668906..47d3162d 100644 --- a/docs/ko/reference/string/camelCase.md +++ b/docs/ko/reference/string/camelCase.md @@ -27,5 +27,5 @@ camelCase('camelCase'); // returns 'camelCase' camelCase('some whitespace'); // returns 'someWhitespace' camelCase('hyphen-text'); // returns 'hyphenText' camelCase('HTTPRequest'); // returns 'httpRequest' -camelCase('Keep unicode 😅') // returns 'keepUnicode😅' +camelCase('Keep unicode 😅'); // returns 'keepUnicode😅' ``` diff --git a/docs/ko/reference/string/constantCase.md b/docs/ko/reference/string/constantCase.md index 982e1744..3d149c2f 100644 --- a/docs/ko/reference/string/constantCase.md +++ b/docs/ko/reference/string/constantCase.md @@ -21,8 +21,8 @@ function constantCase(str: string): string; ## 예시 ```typescript -const convertedStr1 = constantCase('camelCase') // returns 'CAMEL_CASE' -const convertedStr2 = constantCase('some whitespace') // returns 'SOME_WHITESPACE' -const convertedStr3 = constantCase('hyphen-text') // returns 'HYPHEN_TEXT' -const convertedStr4 = constantCase('HTTPRequest') // returns 'HTTP_REQUEST' -``` \ No newline at end of file +const convertedStr1 = constantCase('camelCase'); // returns 'CAMEL_CASE' +const convertedStr2 = constantCase('some whitespace'); // returns 'SOME_WHITESPACE' +const convertedStr3 = constantCase('hyphen-text'); // returns 'HYPHEN_TEXT' +const convertedStr4 = constantCase('HTTPRequest'); // returns 'HTTP_REQUEST' +``` diff --git a/docs/reference/compat/util/toFinite.md b/docs/reference/compat/util/toFinite.md index 25c58764..ce4ec086 100644 --- a/docs/reference/compat/util/toFinite.md +++ b/docs/reference/compat/util/toFinite.md @@ -31,4 +31,4 @@ toNumber(Infinity); // => 1.7976931348623157e+308 toNumber('3.2'); // => 3.2 toNumber(Symbol.iterator); // => 0 toNumber(NaN); // => 0 -``` \ No newline at end of file +``` diff --git a/docs/reference/compat/util/toInteger.md b/docs/reference/compat/util/toInteger.md index fe8dc31e..4e59a4ba 100644 --- a/docs/reference/compat/util/toInteger.md +++ b/docs/reference/compat/util/toInteger.md @@ -34,4 +34,4 @@ toInteger(Infinity); // => 1.7976931348623157e+308 toInteger('3.2'); // => 3 toInteger(Symbol.iterator); // => 0 toInteger(NaN); // => 0 -``` \ No newline at end of file +``` diff --git a/docs/reference/compat/util/toNumber.md b/docs/reference/compat/util/toNumber.md index 8708ecf9..6def565a 100644 --- a/docs/reference/compat/util/toNumber.md +++ b/docs/reference/compat/util/toNumber.md @@ -33,4 +33,4 @@ toNumber(Infinity); // => Infinity toNumber('3.2'); // => 3.2 toNumber(Symbol.iterator); // => NaN toNumber(NaN); // => NaN -``` \ No newline at end of file +``` diff --git a/docs/reference/function/flow.md b/docs/reference/function/flow.md index d5d15f80..3faab448 100644 --- a/docs/reference/function/flow.md +++ b/docs/reference/function/flow.md @@ -1,6 +1,8 @@ # flow -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. ## Signature diff --git a/docs/reference/string/camelCase.md b/docs/reference/string/camelCase.md index 6527b039..8273dd75 100644 --- a/docs/reference/string/camelCase.md +++ b/docs/reference/string/camelCase.md @@ -27,5 +27,5 @@ camelCase('camelCase'); // returns 'camelCase' camelCase('some whitespace'); // returns 'someWhitespace' camelCase('hyphen-text'); // returns 'hyphenText' camelCase('HTTPRequest'); // returns 'httpRequest' -camelCase('Keep unicode 😅') // returns 'keepUnicode😅' +camelCase('Keep unicode 😅'); // returns 'keepUnicode😅' ``` diff --git a/docs/reference/string/constantCase.md b/docs/reference/string/constantCase.md index 13016dd7..eb09a2fa 100644 --- a/docs/reference/string/constantCase.md +++ b/docs/reference/string/constantCase.md @@ -21,8 +21,8 @@ function constantCase(str: string): string; ## Examples ```typescript -const convertedStr1 = constantCase('camelCase') // returns 'CAMEL_CASE' -const convertedStr2 = constantCase('some whitespace') // returns 'SOME_WHITESPACE' -const convertedStr3 = constantCase('hyphen-text') // returns 'HYPHEN_TEXT' -const convertedStr4 = constantCase('HTTPRequest') // returns 'HTTP_REQUEST' -``` \ No newline at end of file +const convertedStr1 = constantCase('camelCase'); // returns 'CAMEL_CASE' +const convertedStr2 = constantCase('some whitespace'); // returns 'SOME_WHITESPACE' +const convertedStr3 = constantCase('hyphen-text'); // returns 'HYPHEN_TEXT' +const convertedStr4 = constantCase('HTTPRequest'); // returns 'HTTP_REQUEST' +``` diff --git a/docs/zh_hans/reference/compat/util/toFinite.md b/docs/zh_hans/reference/compat/util/toFinite.md index 7fd46b03..0a1b9ef9 100644 --- a/docs/zh_hans/reference/compat/util/toFinite.md +++ b/docs/zh_hans/reference/compat/util/toFinite.md @@ -31,4 +31,4 @@ toNumber(Infinity); // => 1.7976931348623157e+308 toNumber('3.2'); // => 3.2 toNumber(Symbol.iterator); // => 0 toNumber(NaN); // => 0 -``` \ No newline at end of file +``` diff --git a/docs/zh_hans/reference/compat/util/toInteger.md b/docs/zh_hans/reference/compat/util/toInteger.md index 168170b1..b78ce7e8 100644 --- a/docs/zh_hans/reference/compat/util/toInteger.md +++ b/docs/zh_hans/reference/compat/util/toInteger.md @@ -34,4 +34,4 @@ toInteger(Infinity); // => 1.7976931348623157e+308 toInteger('3.2'); // => 3 toInteger(Symbol.iterator); // => 0 toInteger(NaN); // => 0 -``` \ No newline at end of file +``` diff --git a/docs/zh_hans/reference/compat/util/toNumber.md b/docs/zh_hans/reference/compat/util/toNumber.md index 0ea4a7d0..9e24f8dd 100644 --- a/docs/zh_hans/reference/compat/util/toNumber.md +++ b/docs/zh_hans/reference/compat/util/toNumber.md @@ -33,4 +33,4 @@ toNumber(Infinity); // => Infinity toNumber('3.2'); // => 3.2 toNumber(Symbol.iterator); // => NaN toNumber(NaN); // => NaN -``` \ No newline at end of file +``` diff --git a/docs/zh_hans/reference/function/flow.md b/docs/zh_hans/reference/function/flow.md index 0d970de7..b393d68d 100644 --- a/docs/zh_hans/reference/function/flow.md +++ b/docs/zh_hans/reference/function/flow.md @@ -1,6 +1,8 @@ # flow -创建一个函数,该函数返回调用给定函数的结果,并将创建函数的 `this` 绑定传递给这些函数,每次调用时将上一次调用的返回值作为参数传递给下一次调用。 +创建一个新的函数,该函数按顺序执行给定的函数。上一个函数的返回值作为参数传递给下一个函数。 + +返回的函数的 `this` 上下文也会传递给作为参数提供的函数。 ## 签名 diff --git a/docs/zh_hans/reference/string/camelCase.md b/docs/zh_hans/reference/string/camelCase.md index 5f819001..313f7b49 100644 --- a/docs/zh_hans/reference/string/camelCase.md +++ b/docs/zh_hans/reference/string/camelCase.md @@ -27,5 +27,5 @@ camelCase('camelCase'); // 返回 'camelCase' camelCase('some whitespace'); // 返回 'someWhitespace' camelCase('hyphen-text'); // 返回 'hyphenText' camelCase('HTTPRequest'); // 返回 'httpRequest' -camelCase('Keep unicode 😅') // 返回 'keepUnicode😅' +camelCase('Keep unicode 😅'); // 返回 'keepUnicode😅' ``` diff --git a/src/compat/util/toInteger.ts b/src/compat/util/toInteger.ts index 7e382010..f943ea47 100644 --- a/src/compat/util/toInteger.ts +++ b/src/compat/util/toInteger.ts @@ -2,7 +2,7 @@ import { toFinite } from './toFinite'; /** * Converts `value` to an integer. - * + * * This function first converts `value` to a finite number. If the result has any decimal places, * they are removed by rounding down to the nearest whole number. * diff --git a/src/object/pick.spec.ts b/src/object/pick.spec.ts index 7bb5061d..8efb5d5c 100644 --- a/src/object/pick.spec.ts +++ b/src/object/pick.spec.ts @@ -31,5 +31,5 @@ describe('pick', () => { const result = pick(obj, ['a']); expect(Reflect.ownKeys(result)).toEqual([]); - }) + }); });