0.0.4 • Published 8 years ago

addtoset v0.0.4

Weekly downloads
4
License
ISC
Repository
github
Last release
8 years ago

© ,Kailash Yogeshwar, Licensed under MIT-License

addToSet

A library to add an element to array set if doesn't already exist else return the source array.

Install

npm install addtoset -S

Features

Adds element to array if it doesn't already exist in array and return the new array version with modified value if any.

const addToSet = require('addtoset');
const set      = new addToSet();

let arr = [1,2,3,4,5];

arr = set.push(arr, 6); // [1,2,3,4,5,6]
arr = set.push(arr, 1); // [1,2,3,4,5]

// Error if parameter is not array
let str = "msg";

set.push(str,1); // Error: Source must be array 

Thank you. Happy Coding

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago