Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

addtoset

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

addtoset - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

8

lib/index.js

@@ -14,11 +14,11 @@ 'use strict'

}
if(~source.indexOf(element)){
let cloned = source.slice();
if(~cloned.indexOf(element)){
return;
} else {
source.push(element);
cloned.push(element);
}
return source;
return cloned;
}
module.exports = addToSet;
{
"name": "addtoset",
"version": "0.0.1",
"version": "0.0.2",
"description": "Utility array function to add value to array if doesn't exist",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -0,2 +1,28 @@

© ,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
```bash
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.
``` javascript
const addToSet = require('addtoset');
let arr = [1,2,3,4,5];
addToSet.push(arr, 6); // [1,2,3,4,5,6]
addToSet.push(arr, 1); // [1,2,3,4,5]
// Error if parameter is not array
let str = "msg";
addToSet.push(str,1); // Error: Source must be array
```
Thank you. Happy Coding
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc