1.0.0 • Published 9 years ago

@mohayonao/remove-if-exists v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

remove-if-exists

Build Status NPM Version License

remove if exists

Installation

npm install @mohayonao/remove-if-exists

API

  • removeIfExists(array: any[], target: any): boolean
    • remove target if exists in array
    • return true if removed

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