pullAllWith

array

This method is like pullAll except that it accepts comparator which is invoked to compare elements of array to values.

Signature

pullAllWith<T>(array: T[], values: T[], comparator: (a: T, b: T) => boolean): T[]

Parameters

NameTypeDescription
arrayT[]The array to modify
valuesT[]The values to remove
comparator(a: T, b: T) => booleanThe comparator invoked per element

Returns

T[] - Returns array

Examples

With comparator

import { pullAllWith } from 'dashlite'

const array = [{ x: 1, y: 2 }, { x: 3, y: 4 }, { x: 5, y: 6 }]
pullAllWith(array, [{ x: 3, y: 4 }], (a, b) => a.x === b.x && a.y === b.y)
console.log(array)

Output:

[{ x: 1, y: 2 }, { x: 5, y: 6 }]

Notes

  • This method mutates array

Available since version 1.0.0