diff --git a/docs/ja/reference/function/after.md b/docs/ja/reference/function/after.md index 8d907c1b..5089ecd0 100644 --- a/docs/ja/reference/function/after.md +++ b/docs/ja/reference/function/after.md @@ -8,7 +8,10 @@ ## インターフェース ```typescript -function after any>(n: number, func: F): F; +function after any>( + n: number, + func: F +): (...args: Parameters) => ReturnType | undefined; ``` ### パラメータ @@ -18,7 +21,7 @@ function after any>(n: number, func: F): F; ### 戻り値 -(`F`): 新しい関数を返します。この関数は以下の機能を持ちます: +(`(...args: Parameters) => ReturnType | undefined`): 新しい関数を返します。この関数は以下の機能を持ちます: - 呼び出された回数を追跡します。 - `n`回目の呼び出しから`func`を呼び出します。 diff --git a/docs/ko/reference/function/after.md b/docs/ko/reference/function/after.md index 7aa8001d..6a0504c8 100644 --- a/docs/ko/reference/function/after.md +++ b/docs/ko/reference/function/after.md @@ -8,7 +8,10 @@ ## 인터페이스 ```typescript -function after any>(n: number, func: F): F; +function after any>( + n: number, + func: F +): (...args: Parameters) => ReturnType | undefined; ``` ### 파라미터 @@ -18,7 +21,7 @@ function after any>(n: number, func: F): F; ### 반환 값 -(`F`): 새로운 함수를 반환해요. 이 함수는 다음과 같은 기능을 가져요. +(`(...args: Parameters) => ReturnType | undefined`): 새로운 함수를 반환해요. 이 함수는 다음과 같은 기능을 가져요. - 호출된 횟수를 추적해요. - `n`번째 호출부터 `func`을 호출해요. diff --git a/docs/reference/function/after.md b/docs/reference/function/after.md index 638c0eb5..4bb34d5d 100644 --- a/docs/reference/function/after.md +++ b/docs/reference/function/after.md @@ -8,7 +8,10 @@ The is particularly useful for scenarios involving events or asynchronous operat ## Signature ```typescript -function after any>(n: number, func: F): F; +function after any>( + n: number, + func: F +): (...args: Parameters) => ReturnType | undefined; ``` ### Parameters @@ -18,7 +21,7 @@ function after any>(n: number, func: F): F; ### Returns -(`F`): A new function that: +(`(...args: Parameters) => ReturnType | undefined`): A new function that: - Tracks the number of calls. - Invokes `func` starting from the `n`-th call. diff --git a/docs/zh_hans/reference/function/after.md b/docs/zh_hans/reference/function/after.md index 17f27583..90fd2fb1 100644 --- a/docs/zh_hans/reference/function/after.md +++ b/docs/zh_hans/reference/function/after.md @@ -8,7 +8,10 @@ ## 签名 ```typescript -function after any>(n: number, func: F): F; +function after any>( + n: number, + func: F +): (...args: Parameters) => ReturnType | undefined; ``` ### 参数 @@ -18,7 +21,7 @@ function after any>(n: number, func: F): F; ### 返回值 -(`F`): 一个新函数,它: +(`(...args: Parameters) => ReturnType | undefined`): 一个新函数,它: - 跟踪调用次数。 - 从第 `n` 次调用开始调用 `func`。 diff --git a/src/compat/_internal/isKey.ts b/src/compat/_internal/isKey.ts index 439a3414..3de621d6 100644 --- a/src/compat/_internal/isKey.ts +++ b/src/compat/_internal/isKey.ts @@ -18,7 +18,7 @@ const regexIsPlainProp = /^\w*$/; * isKey('a.b', { a: { b: 2 } }); * // => false */ -export function isKey(value?: unknown, object?: unknown): boolean { +export function isKey(value?: unknown, object?: unknown): value is PropertyKey { if (Array.isArray(value)) { return false; } diff --git a/src/compat/array/orderBy.ts b/src/compat/array/orderBy.ts index 09f0b0ae..14918f78 100644 --- a/src/compat/array/orderBy.ts +++ b/src/compat/array/orderBy.ts @@ -107,7 +107,7 @@ export function orderBy( } // If criterion is not key, it has possibility to be a deep path. So we have to prepare both cases. - return { key: criterion, path: toPath(criterion as string) } as const; + return { key: criterion, path: toPath(criterion) }; }); // Array.prototype.sort() always shifts the `undefined` values to the end of the array. So we have to prevent it by using a wrapper object. diff --git a/src/function/after.ts b/src/function/after.ts index ce362645..3e9ee9be 100644 --- a/src/function/after.ts +++ b/src/function/after.ts @@ -8,7 +8,7 @@ * @template F - The type of the function to be invoked. * @param {number} n - The number of calls required for `func` to execute. * @param {F} func - The function to be invoked. - * @returns {F} - A new function that: + * @returns {(...args: Parameters) => ReturnType | undefined} - A new function that: * - Tracks the number of calls. * - Invokes `func` starting from the `n`-th call. * - Returns `undefined` if fewer than `n` calls have been made. @@ -27,16 +27,19 @@ * afterFn() */ -export function after any>(n: number, func: F): F { +export function after any>( + n: number, + func: F +): (...args: Parameters) => ReturnType | undefined { if (!Number.isInteger(n) || n < 0) { throw new Error(`n must be a non-negative integer.`); } let counter = 0; - return ((...args: Parameters) => { + return (...args: Parameters) => { if (++counter >= n) { return func(...args); } return undefined; - }) as F; + }; } diff --git a/src/promise/withTimeout.ts b/src/promise/withTimeout.ts index eb920a11..0e5dfec5 100644 --- a/src/promise/withTimeout.ts +++ b/src/promise/withTimeout.ts @@ -26,5 +26,5 @@ import { timeout } from './timeout.ts'; * } */ export async function withTimeout(run: () => Promise, ms: number): Promise { - return Promise.race([run(), timeout(ms) as T]); + return Promise.race([run(), timeout(ms)]); }