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

set

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

set

An implementation of Sets in JavaScript

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Set.js

I created this because I noticed that there were no actual set object implementations in JavaScript and also to learn a bit more about creating node modules.

Usage

Create an array of items and then pass it to Set.
var Set = require('./set')
var set = new Set([0,1,1])
And then when we get it
set.get() // [0,1]

API

There are various Set functions available

Static functions

Set#unique given an array, return an array with all duplicates removed.

Instance functions

Set#contains return whether a given property is available.
Set#empty return whether the set in empty.
Set#size return the size of the Set.
Set#get return the set as an Array.

Set#add add an item to the Set.
Set#remove remove an item from the set.
Set#clear remove all items from the set.

Set#union return a new set that is the union of the set with another one.
Set#intersect return a new set that is the intersection of the set with another one.
Set#difference return a new set that is the difference of the set with another one.

Set#find return an array with all items that match the predicate.

FAQs

Package last updated on 12 Apr 2011

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