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