3.2.0 ā€¢ Published 3 months ago

extra-set v3.2.0

Weekly downloads
13
License
MIT
Repository
github
Last release
3 months ago

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.

npm.io ORG DOI Coverage Status Test Coverage Maintainability

3.2.0

3 months ago

3.1.7

1 year ago

3.1.6

2 years ago

3.0.12

2 years ago

3.0.13

2 years ago

3.0.10

2 years ago

3.0.11

2 years ago

3.0.16

2 years ago

3.0.17

2 years ago

3.0.14

2 years ago

3.0.15

2 years ago

3.1.3

2 years ago

3.1.2

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.1.5

2 years ago

3.1.4

2 years ago

3.0.45

2 years ago

3.0.46

2 years ago

3.0.43

2 years ago

3.0.44

2 years ago

3.0.41

2 years ago

3.0.42

2 years ago

3.0.40

2 years ago

3.0.4

2 years ago

3.0.3

2 years ago

3.0.2

2 years ago

3.0.1

2 years ago

3.0.8

2 years ago

3.0.7

2 years ago

3.0.6

2 years ago

3.0.5

2 years ago

3.0.0

2 years ago

3.0.23

2 years ago

3.0.24

2 years ago

3.0.21

2 years ago

3.0.22

2 years ago

3.0.27

2 years ago

3.0.28

2 years ago

3.0.25

2 years ago

3.0.26

2 years ago

3.0.20

2 years ago

3.0.18

2 years ago

3.0.19

2 years ago

3.0.9

2 years ago

3.0.34

2 years ago

3.0.35

2 years ago

3.0.32

2 years ago

3.0.33

2 years ago

3.0.38

2 years ago

3.0.39

2 years ago

3.0.36

2 years ago

3.0.37

2 years ago

3.0.30

2 years ago

3.0.31

2 years ago

3.0.29

2 years ago

2.2.11

4 years ago

2.2.10

4 years ago

2.2.9

4 years ago

2.2.8

4 years ago

2.2.7

4 years ago

2.2.5

4 years ago

2.2.4

4 years ago

2.2.3

4 years ago

2.2.2

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.63

4 years ago

2.1.61

4 years ago

2.1.62

4 years ago

2.1.60

5 years ago

2.1.59

5 years ago

2.1.58

5 years ago

2.1.56

5 years ago

2.1.57

5 years ago

2.1.55

5 years ago

2.1.54

5 years ago

2.1.52

5 years ago

2.1.53

5 years ago

2.1.50

5 years ago

2.1.51

5 years ago

2.1.49

5 years ago

2.1.47

5 years ago

2.1.48

5 years ago

2.1.46

5 years ago

2.1.45

5 years ago

2.1.44

5 years ago

2.1.43

5 years ago

2.1.41

5 years ago

2.1.42

5 years ago

2.1.40

5 years ago

2.1.38

5 years ago

2.1.39

5 years ago

2.1.37

5 years ago

2.1.36

5 years ago

2.1.34

5 years ago

2.1.35

5 years ago

2.1.32

5 years ago

2.1.33

5 years ago

2.1.31

5 years ago

2.1.30

5 years ago

2.1.28

5 years ago

2.1.29

5 years ago

2.1.27

5 years ago

2.1.26

5 years ago

2.1.25

5 years ago

2.1.24

5 years ago

2.1.23

5 years ago

2.1.22

5 years ago

2.1.21

5 years ago

2.1.19

5 years ago

2.1.20

5 years ago

2.1.18

5 years ago

2.1.17

5 years ago

2.1.16

5 years ago

2.1.15

5 years ago

2.1.14

5 years ago

2.1.13

5 years ago

2.1.12

5 years ago

2.1.11

5 years ago

2.1.10

5 years ago

2.1.9

5 years ago

2.1.6

5 years ago

2.1.5

5 years ago

2.1.8

5 years ago

2.1.7

5 years ago

2.1.4

5 years ago

2.1.3

5 years ago

2.1.2

5 years ago

2.0.15

5 years ago

2.1.1

5 years ago

2.0.16

5 years ago

2.1.0

5 years ago

2.0.17

5 years ago

2.0.18

5 years ago

2.0.14

5 years ago

2.0.13

5 years ago

2.0.11

5 years ago

2.0.12

5 years ago

2.0.10

5 years ago

2.0.7

5 years ago

2.0.9

5 years ago

2.0.8

5 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.0

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.0.1

6 years ago