docs: Add missing docs and style docs

This commit is contained in:
Sojin Park 2024-09-28 22:22:34 +09:00
parent c0efc65360
commit 819d64ecfa
27 changed files with 144 additions and 40 deletions

View File

@ -26,8 +26,8 @@ function defer<F extends (...args: any[]) => any>(func: F, ...args: Parameters<F
## 例
```typescript
defer((text) => {
defer(text => {
console.log(text);
}, 'deferred');
// => Logs 'deferred' after the current call stack has cleared.
```
```

View File

@ -31,4 +31,4 @@ toNumber(Infinity); // => 1.7976931348623157e+308
toNumber('3.2'); // => 3.2
toNumber(Symbol.iterator); // => 0
toNumber(NaN); // => 0
```
```

View File

@ -31,4 +31,4 @@ toInteger(Infinity); // => 1.7976931348623157e+308
toInteger('3.2'); // => 3
toInteger(Symbol.iterator); // => 0
toInteger(NaN); // => 0
```
```

View File

@ -33,4 +33,4 @@ toNumber(Infinity); // => Infinity
toNumber('3.2'); // => 3.2
toNumber(Symbol.iterator); // => NaN
toNumber(NaN); // => NaN
```
```

View File

@ -0,0 +1,50 @@
# flow
与えられた関数を順番に実行する新しい関数を作成します。前の関数の戻り値は次の関数への引数として渡されます。
返された関数の `this` コンテキストも、パラメータとして提供された関数に渡されます。
## インターフェース
```typescript
function flow<R>(f: () => R): () => R;
function flow<A extends any[], R>(f1: (...args: A) => R): (...args: A) => R;
function flow<A extends any[], R1, R2>(f1: (...args: A) => R1, f2: (a: R1) => R2): (...args: A) => R2;
function flow<A extends any[], R1, R2, R3>(
f1: (...args: A) => R1,
f2: (a: R1) => R2,
f3: (a: R2) => R3
): (...args: A) => R3;
function flow<A extends any[], R1, R2, R3, R4>(
f1: (...args: A) => R1,
f2: (a: R1) => R2,
f3: (a: R2) => R3,
f4: (a: R3) => R4
): (...args: A) => R4;
function flow<A extends any[], R1, R2, R3, R4, R5>(
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
```

View File

@ -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😅' を返します
```

View File

@ -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'
```
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'
```

View File

@ -26,8 +26,8 @@ function defer<F extends (...args: any[]) => any>(func: F, ...args: Parameters<F
## 예시
```typescript
defer((text) => {
defer(text => {
console.log(text);
}, 'deferred');
// => Logs 'deferred' after the current call stack has cleared.
```
```

View File

@ -31,4 +31,4 @@ toNumber(Infinity); // => 1.7976931348623157e+308
toNumber('3.2'); // => 3.2
toNumber(Symbol.iterator); // => 0
toNumber(NaN); // => 0
```
```

View File

@ -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
```
```

View File

@ -34,4 +34,4 @@ toNumber(Infinity); // => Infinity
toNumber('3.2'); // => 3.2
toNumber(Symbol.iterator); // => NaN
toNumber(NaN); // => NaN
```
```

View File

@ -0,0 +1,50 @@
# flow
주어진 함수들을 연속해서 실행하는 새로운 함수를 만들어요. 이전 함수의 결괏값은 다음 함수의 인자로 주어져요.
반환된 함수에게 주어진 `this`는 파라미터로 주어진 함수들에게도 전달돼요.
## 인터페이스
```typescript
function flow<R>(f: () => R): () => R;
function flow<A extends any[], R>(f1: (...args: A) => R): (...args: A) => R;
function flow<A extends any[], R1, R2>(f1: (...args: A) => R1, f2: (a: R1) => R2): (...args: A) => R2;
function flow<A extends any[], R1, R2, R3>(
f1: (...args: A) => R1,
f2: (a: R1) => R2,
f3: (a: R2) => R3
): (...args: A) => R3;
function flow<A extends any[], R1, R2, R3, R4>(
f1: (...args: A) => R1,
f2: (a: R1) => R2,
f3: (a: R2) => R3,
f4: (a: R3) => R4
): (...args: A) => R4;
function flow<A extends any[], R1, R2, R3, R4, R5>(
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
```

View File

@ -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😅'
```

View File

@ -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'
```
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'
```

View File

@ -31,4 +31,4 @@ toNumber(Infinity); // => 1.7976931348623157e+308
toNumber('3.2'); // => 3.2
toNumber(Symbol.iterator); // => 0
toNumber(NaN); // => 0
```
```

View File

@ -34,4 +34,4 @@ toInteger(Infinity); // => 1.7976931348623157e+308
toInteger('3.2'); // => 3
toInteger(Symbol.iterator); // => 0
toInteger(NaN); // => 0
```
```

View File

@ -33,4 +33,4 @@ toNumber(Infinity); // => Infinity
toNumber('3.2'); // => 3.2
toNumber(Symbol.iterator); // => NaN
toNumber(NaN); // => NaN
```
```

View File

@ -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

View File

@ -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😅'
```

View File

@ -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'
```
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'
```

View File

@ -31,4 +31,4 @@ toNumber(Infinity); // => 1.7976931348623157e+308
toNumber('3.2'); // => 3.2
toNumber(Symbol.iterator); // => 0
toNumber(NaN); // => 0
```
```

View File

@ -34,4 +34,4 @@ toInteger(Infinity); // => 1.7976931348623157e+308
toInteger('3.2'); // => 3
toInteger(Symbol.iterator); // => 0
toInteger(NaN); // => 0
```
```

View File

@ -33,4 +33,4 @@ toNumber(Infinity); // => Infinity
toNumber('3.2'); // => 3.2
toNumber(Symbol.iterator); // => NaN
toNumber(NaN); // => NaN
```
```

View File

@ -1,6 +1,8 @@
# flow
创建一个函数,该函数返回调用给定函数的结果,并将创建函数的 `this` 绑定传递给这些函数,每次调用时将上一次调用的返回值作为参数传递给下一次调用。
创建一个新的函数,该函数按顺序执行给定的函数。上一个函数的返回值作为参数传递给下一个函数。
返回的函数的 `this` 上下文也会传递给作为参数提供的函数。
## 签名

View File

@ -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😅'
```

View File

@ -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.
*

View File

@ -31,5 +31,5 @@ describe('pick', () => {
const result = pick(obj, ['a']);
expect(Reflect.ownKeys(result)).toEqual([]);
})
});
});