Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
This is a javascript implementation of a set data structure.
A set data structure is an implementation of the mathematical concept of a finite set. A set is a collection of unique values (no duplicates) that have no particular order. A set is more concerned whether or not values are contained in the set than the order in which they are added.
This implementation of a set inlcudes the common set operations of union, intersection, difference, and subset.
For specific examples and documentation, see the below sections
Install with npm :
npm install set-ds --save
Basic usage example below. Note: it does not cover all the available methods, rather just highlights the main functionality to get up and running with this data structure. For a description of all the methods, see the API section.
var SetDS = require('set-ds');
var setA = new SetDS();
setA.isEmpty();
// --> true
setA.add(1);
setA.add(2);
setA.add(3);
setA.add(4);
setA.add(5);
setA.values();
// --> [1, 2, 3, 4, 5]
setA.has(4);
// --> true
// or instantiate with an array or args
var setB = new SetDS([7, 6, 5, 8, 4]);
setB.isEmpty();
// --> false
setB.values();
// --> [4, 5, 6, 7, 8]
var setC = setA.union(setB);
setC.values();
// --> [1, 2, 3, 4, 5, 6, 7, 8]
var setD = setA.intersection(setB);
setD.values();
// --> [4, 5]
var setE = setA.difference(setB);
setE.values();
// --> [1, 2, 3]
setA.subset(new SetDS(1, 7, 3, 4, 6, 5, 2));
// --> true
setA.clear();
setA.isEmpty();
// --> true
Available methods for a Set instance:
Determines if the set is empty
Returns the size, or number of items in the set
Clears all the items from the set
Adds an item to the set. If the set already contains the item, it is not added.
Removes an item from the set.
Determines of the set contains, or has, the value
Returns an array containing all the items in the set
Returns a Set that is the union of this set and the 'otherSet'. The returned set will contain all the elements from both sets, and by definition, will not contain any duplicates.
Returns a Set that ts the intersection of this set and the 'otherSet', The returned set will have only those items that both sets have in common.
Returns a Set that ts the different of this and the 'otherSet', The returned set will have those items that are contained in this set, but NOT contained in the 'otherSet'.
Returns whether or not this set is a subset of the 'otherSet'. If all items of this set are contained in the otherSet, this function returns true; false otherwise.
MIT © Jason Jones
FAQs
Set data structure
We found that set-ds demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.