Socket
Socket
Sign inDemoInstall

extra-set

Package Overview
Dependencies
0
Maintainers
1
Versions
161
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    extra-set

A pack of functions for working with Sets.


Version published
Weekly downloads
107
decreased by-27.21%
Maintainers
1
Install size
53.7 kB
Created
Weekly downloads
 

Readme

Source

A pack of functions for working with Sets.
📦 Node.js, 🌐 Web, 📜 Files, 📰 Docs, 📘 Wiki.

A Set is a collection of unique values. This package includes common set functions related to querying about sets, generating them, comparing one with another, finding their size, adding and removing elements, obtaining its properties, getting a part of it, getting a subset elements in it, finding an element in it, performing functional operations, manipulating it in various ways, combining together sets or its elements, of performing set operations upon it.

All functions except from*() take set as 1st parameter. Methods like concat() are pure and do not modify the set itself, while methods like concat$() do modify (update) the set itself.

This package is available in Node.js and Web formats. The web format is exposed as extra_set standalone variable and can be loaded from jsDelivr CDN.

Stability: Experimental.


const set = require('extra-set');
// import * as set from "extra-set";
// import * as set from "https://unpkg.com/extra-set/index.mjs"; (Deno)

var x = new Set([1, 2, 3, 4, 5]);
var y = new Set([2, 4]);
set.difference(x, y);
// → Set(3) { 1, 3, 5 }

var x = new Set([1, 2, 3]);
var y = new Set([3, 4]);
set.isDisjoint(x, y);
// → false

var x = new Set([1, 2, 3, 4]);
var y = new Set([3, 4, 5, 6]);
set.symmetricDifference(x, y);
// → Set(4) { 1, 2, 5, 6 }

var x = new Set([1, 2, 3]);
[...set.subsets(x)];
// → [
// →   Set(0) {},
// →   Set(1) { 1 },
// →   Set(1) { 2 },
// →   Set(2) { 1, 2 },
// →   Set(1) { 3 },
// →   Set(2) { 1, 3 },
// →   Set(2) { 2, 3 },
// →   Set(3) { 1, 2, 3 }
// → ]


Index

PropertyDescription
isCheck if value is a set.
valuesList all values.
entriesList all value-value pairs.
fromConvert an iterable to set.
from$Convert an iterable to set.
compareCompare two sets.
isEqualCheck if two sets are equal.
sizeFind the size of a set.
isEmptyCheck if a set is empty.
addAdd a value to set.
add$Add a value to set.
removeDelete a value from set.
remove$Delete a value from set.
countCount values which satisfy a test.
countAsCount occurrences of values.
minFind smallest value.
maxFind largest value.
rangeFind smallest and largest entries.
headGet first value from set (default order).
tailGet a set without its first value (default order).
takeKeep first n values only (default order).
take$Keep first n values only (default order).
dropRemove first n values (default order).
drop$Remove first n values (default order).
subsetsList all possible subsets.
randomValuePick an arbitrary value.
randomEntryPick an arbitrary entry.
randomSubsetPick an arbitrary subset.
hasSubsetChecks if set has a subset.
hasCheck if set has a value.
findFind first value passing a test (default order).
findAllFind all values passing a test.
forEachCall a function for each value.
someCheck if any value satisfies a test.
everyCheck if all values satisfy a test.
mapTransform values of a set.
map$Transform values of a set.
reduceReduce values of set to a single value.
filterKeep values which pass a test.
filter$Keep values which pass a test.
rejectDiscard values which pass a test.
reject$Discard values which pass a test.
flatFlatten nested set to given depth.
flatMapFlatten nested set, based on map function.
partitionSegregate values by test result.
partitionAsSegregates values by similarity.
chunkBreak set into chunks of given size.
concatAppend values from sets.
concat$Append values from sets.
joinJoin values together into a string.
isDisjointCheck if sets have no value in common.
unionObtain values present in any set.
union$Obtain values present in any set.
intersectionObtain values present in both sets.
intersection$Obtain values present in both sets.
differenceObtain values not present in another set.
difference$Obtain values not present in another set.
symmetricDifferenceObtain values not present in both sets.
symmetricDifference$Obtain values not present in both sets.
cartesianProductList cartesian product of sets.


ORG DOI Coverage Status Test Coverage Maintainability

Keywords

FAQs

Last updated on 19 Oct 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc