From 0507a5030843379d790e17f574a9def9200f781b Mon Sep 17 00:00:00 2001 From: Antoliny0919 Date: Tue, 28 Jul 2026 01:10:52 +0900 Subject: [PATCH] fix(compat/pullAll): return array as is when values is nullish --- src/compat/array/pullAll.spec.ts | 6 ++++++ src/compat/array/pullAll.ts | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/compat/array/pullAll.spec.ts b/src/compat/array/pullAll.spec.ts index 4dc618cad1..a682c055c5 100644 --- a/src/compat/array/pullAll.spec.ts +++ b/src/compat/array/pullAll.spec.ts @@ -53,4 +53,10 @@ describe('pullAll', () => { expect(result).toBe(array); expect(array).toEqual([1, 2, 3]); }); + + it('should return the array as is when `values` is `null` or `undefined`', () => { + const array = [1, 2, 3]; + expect(pullAll(array, null as any)).toBe(array); + expect(pullAll(array, undefined)).toBe(array); + }); }); diff --git a/src/compat/array/pullAll.ts b/src/compat/array/pullAll.ts index efc1651a48..b4cb5b8fef 100644 --- a/src/compat/array/pullAll.ts +++ b/src/compat/array/pullAll.ts @@ -1,4 +1,5 @@ import { pull as pullToolkit } from '../../array/pull.ts'; +import { isNil } from '../../predicate/isNil.ts'; import type { MutableList } from '../_internal/MutableList.d.ts'; import type { RejectReadonly } from '../_internal/RejectReadonly.d.ts'; @@ -57,5 +58,9 @@ export function pullAll>(array: RejectReadonly, va * console.log(numbers); // [1, 3, 5] */ export function pullAll(arr: T[], valuesToRemove: ArrayLike = []): T[] { + if (isNil(valuesToRemove)) { + return arr; + } + return pullToolkit(arr, Array.from(valuesToRemove)); }