hodash.remove-one
v1.0.1
Published
Remove first matching element from array.
Downloads
5
Maintainers
Readme
Remove first matching element from an array.
Will stop iterating when first match is encountered, and return new array without the matched element.
$ npm install hodash.removeOne
const _removeOne = require('hodash.remove-one');
Remove by matching result of function:
const data = [{name: 'Phil'}, {name: 'Andrea'}, {name: 'Sam'}];
// Remove element with name = Sam
const withoutSam = _removeOne(data, ({name}) => name === 'Sam');
Remove by strict equality check:
const letters = ['a', 'b', 'c', 'd', 'e'];
// Remove 'd'
const withoutE = _removeOne(letters, 'd');