Skip to content

Latest commit

 

History

History
30 lines (21 loc) · 879 Bytes

removeBy.md

File metadata and controls

30 lines (21 loc) · 879 Bytes

removeBy (source code)

  • Curried: true
  • Failsafe status: alternative available

The removeBy function removes all items in the array that match the provided pattern.

Arguments:

  • pattern: The pattern using which the objects will be matched.
  • entityArray: The array of objects in which the objects with the given pattern will be removed.

Usage:

const array = [
  { id: 1, name: "Sam", address: { street: "First street", pin: 101283 } },
  { id: 2, name: "Oliver", address: { street: "Second street", pin: 998472 } },
];

removeBy({ name: "Sam" }, array); // removes Sam
removeBy({ id: 2, address: { pin: 654321 } }, array); // removes Oliver
removeBy({ id: 3 }, array); // does nothing

See also