diff --git a/benchmarks/performance/pull.bench.ts b/benchmarks/performance/pull.bench.ts index 07542e184..91d9311e6 100644 --- a/benchmarks/performance/pull.bench.ts +++ b/benchmarks/performance/pull.bench.ts @@ -10,7 +10,7 @@ describe('pull array size 100', () => { const even = [...Array(50)].map((_, i) => i * 2); bench('es-toolkit/pull', () => { - pullToolkit([...array], even); + pullToolkit([...array], ...even); }); bench('lodash/pull', () => { @@ -23,7 +23,7 @@ describe('pull array size 1000', () => { const even = [...Array(500)].map((_, i) => i * 2); bench('es-toolkit/pull', () => { - pullToolkit([...array], [...even]); + pullToolkit([...array], ...even); }); bench('lodash/pull', () => { @@ -36,7 +36,7 @@ describe('pull array size 10000', () => { const even = [...Array(5000)].map((_, i) => i * 2); bench('es-toolkit/pull', () => { - pullToolkit([...array], [...even]); + pullToolkit([...array], ...even); }); bench('lodash/pull', () => { diff --git a/docs/ja/reference/array/pull.md b/docs/ja/reference/array/pull.md index 04bc29d24..9021cbcf4 100644 --- a/docs/ja/reference/array/pull.md +++ b/docs/ja/reference/array/pull.md @@ -8,13 +8,13 @@ ## インターフェース ```typescript -function pull(arr: T[], valuesToRemove: unknown[]): T[]; +function pull(arr: T[], valuesToRemove: readonly U[]): T[]; ``` ### パラメータ - `arr` (`T[]`): 変更する配列。 -- `valuesToRemove` (`unknown[]`): 配列から削除する値。 +- `valuesToRemove` (`U[]`): 配列から削除する値。 ### 戻り値 diff --git a/docs/ko/reference/array/pull.md b/docs/ko/reference/array/pull.md index 275047f29..025c10141 100644 --- a/docs/ko/reference/array/pull.md +++ b/docs/ko/reference/array/pull.md @@ -8,13 +8,13 @@ ## 인터페이스 ```typescript -function pull(arr: T[], valuesToRemove: unknown[]): T[]; +function pull(arr: T[], valuesToRemove: readonly U[]): T[]; ``` ### 파라미터 - `arr` (`T[]`): 수정할 배열. -- `valuesToRemove` (`unknown[]`): 배열에서 제거할 값들. +- `valuesToRemove` (`U[]`): 배열에서 제거할 값들. ### 반환 값 diff --git a/docs/reference/array/pull.md b/docs/reference/array/pull.md index bd11c96d6..93db3961d 100644 --- a/docs/reference/array/pull.md +++ b/docs/reference/array/pull.md @@ -8,13 +8,13 @@ If you want to remove values without modifying the original array, use [differen ## Signature ```typescript -function pull(arr: T[], valuesToRemove: unknown[]): T[]; +function pull(arr: T[], valuesToRemove: readonly U[]): T[]; ``` ### Parameters - `arr` (`T[]`): The array to modify. -- `valuesToRemove` (`unknown[]`): The values to remove from the array. +- `valuesToRemove` (`U[]`): The values to remove from the array. ### Returns diff --git a/docs/zh_hans/reference/array/pull.md b/docs/zh_hans/reference/array/pull.md index 42363267a..fe913813a 100644 --- a/docs/zh_hans/reference/array/pull.md +++ b/docs/zh_hans/reference/array/pull.md @@ -8,13 +8,13 @@ ## 签名 ```typescript -function pull(arr: T[], valuesToRemove: unknown[]): T[]; +function pull(arr: T[], valuesToRemove: readonly U[]): T[]; ``` ### 参数 - `arr` (`T[]`): 要修改的数组。 -- `valuesToRemove` (`unknown[]`): 要从数组中移除的值。 +- `valuesToRemove` (`U[]`): 要从数组中移除的值。 ### 返回值 diff --git a/src/array/pull.ts b/src/array/pull.ts index c12b10a80..146e7897b 100644 --- a/src/array/pull.ts +++ b/src/array/pull.ts @@ -4,9 +4,10 @@ * This function changes `arr` in place. * If you want to remove values without modifying the original array, use `difference`. * - * @template T, U + * @template T - The type of elements in the array. + * @template U - The type of values to remove from the array. * @param {T[]} arr - The array to modify. - * @param {unknown[]} valuesToRemove - The values to remove from the array. + * @param {U[]} valuesToRemove - The values to remove from the array. * @returns {T[]} The modified array with the specified values removed. * * @example @@ -14,12 +15,12 @@ * pull(numbers, [2, 4]); * console.log(numbers); // [1, 3, 5] */ -export function pull(arr: T[], valuesToRemove: readonly unknown[]): T[] { +export function pull(arr: T[], valuesToRemove: readonly U[]): T[] { const valuesSet = new Set(valuesToRemove); let resultIndex = 0; for (let i = 0; i < arr.length; i++) { - if (valuesSet.has(arr[i])) { + if (valuesSet.has(arr[i] as U)) { continue; } diff --git a/src/compat/array/pull.ts b/src/compat/array/pull.ts index 45f981612..5587f01c6 100644 --- a/src/compat/array/pull.ts +++ b/src/compat/array/pull.ts @@ -5,7 +5,7 @@ import { pull as pullToolkit } from '../../array/pull.ts'; * * **Note:** Unlike `_.without`, this method mutates `array`. * - * @template T + * @template T - The type of elements in the array. * @param {T[]} array - The array to modify. * @param {...T[]} values - The values to remove. * @returns {T[]} Returns `array`. @@ -24,7 +24,7 @@ export function pull(array: T[], ...values: T[]): T[]; * * **Note:** Unlike `_.without`, this method mutates `array`. * - * @template L + * @template L - The type of elements in the array-like object. * @param {L} array - The array to modify. * @param {...L[0][]} values - The values to remove. * @returns {L} Returns `array`. @@ -44,9 +44,9 @@ export function pull>(array: L extends readonly any[] ? * This function changes `arr` in place. * If you want to remove values without modifying the original array, use `difference`. * - * @template T, U + * @template T - The type of elements in the array. * @param {T[]} arr - The array to modify. - * @param {...unknown[]} valuesToRemove - The values to remove from the array. + * @param {T[]} valuesToRemove - The values to remove from the array. * @returns {T[]} The modified array with the specified values removed. * * @example @@ -54,6 +54,6 @@ export function pull>(array: L extends readonly any[] ? * pull(numbers, [2, 4]); * console.log(numbers); // [1, 3, 5] */ -export function pull(arr: T[], ...valuesToRemove: readonly unknown[]): T[] { +export function pull(arr: T[], ...valuesToRemove: readonly T[]): T[] { return pullToolkit(arr, valuesToRemove); }