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

Utility array function to add value to array if doesn't exist

  • 0.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

© ,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

Keywords

FAQs

Package last updated on 04 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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