1.0.0 • Published 9 years ago
@mohayonao/append-if-not-exists v1.0.0
append-if-not-exists
append if not exists
Installation
npm install @mohayonao/append-if-not-exists
API
appendIfNotExists(array: any[], target: any): boolean
- append
target
if not exists inarray
- return true if appended
- append
Example
import appendIfNotExists from "@mohayonao/append-if-not-exists";
let array = [ 1, 2, 3, 4, 5 ];
console.log(appendIfNotExists(array, 6)); // true
console.log(array); // [ 1, 2, 3, 4, 5, 6 ]
console.log(appendIfNotExists(array, 3)); // false
console.log(array); // [ 1, 2, 3, 4, 5, 6 ]
License
MIT
1.0.0
9 years ago