pullAll()
pullAll<
T>(array,values):T[]
Creates an array excluding all specified values.
DEPRECATED
Use difference from Arkhe instead.
Reason:
Pithos design philosophy always favors immutability.
note
Mutates the array in place.
Type Parametersโ
T: Tโ
The type of elements in the array.
Parametersโ
array: T[]โ
The array to modify.
values: T[]โ
The values to exclude.
Returns: T[]โ
The mutated array.
See Alsoโ
Sinceโ
2.0.0
Also known asโ
difference (Remeda, Effect) ยท pullAll (Lodash, es-toolkit) ยท โ (Radashi, Ramda, Modern Dash, Antfu)
Exampleโ
const numbers = [1, 2, 3, 4, 2];
pullAll(numbers, [2, 3]);
console.log(numbers); // [1, 4]
How it works?โ
Removes all specified values from array in place (mutates).
Mutation Flowโ
Common Inputsโ
| Array | Values | Result |
|---|---|---|
[1, 2, 3, 4, 2] | [2, 3] | [1, 4] |
['a', 'b', 'c'] | ['b'] | ['a', 'c'] |
Deprecated: Use
difference()from Arkhe for immutable operations.
Use Casesโ
Remove multiple values ๐โ
Remove all occurrences of specified values from array.
const items = [1, 2, 3, 2, 4, 2];
const toRemove = [2, 3];
const result = items.filter(x => !toRemove.includes(x));
// [1, 4]
Clean array dataโ
Filter out unwanted values from dataset.
const tags = ['js', 'deprecated', 'ts', 'legacy'];
const blacklist = ['deprecated', 'legacy'];
const clean = tags.filter(t => !blacklist.includes(t));
// ['js', 'ts']
Deprecated: Use