1.0.0 • Published 9 years ago

@mohayonao/append-if-not-exists v1.0.0

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

append-if-not-exists

Build Status NPM Version License

append if not exists

Installation

npm install @mohayonao/append-if-not-exists

API

  • appendIfNotExists(array: any[], target: any): boolean
    • append target if not exists in array
    • return true if appended

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