@mohayonao/remove-if-exists
v1.0.0
Published
remove if exists
Downloads
1
Readme
remove-if-exists
remove if exists
Installation
npm install @mohayonao/remove-if-exists
API
removeIfExists(array: any[], target: any): boolean
- remove
target
if exists inarray
- return true if removed
- remove
Example
import removeIfExists from "@mohayonao/remove-if-exists";
let array = [ 1, 2, 3, 4, 5 ];
console.log(removeIfExists(array, 3)); // true
console.log(array); // [ 1, 2, 4, 5 ]
console.log(removeIfExists(array, 6)); // false
console.log(array); // [ 1, 2, 4, 5 ]
License
MIT