Skip to content

Latest commit

 

History

History
282 lines (212 loc) · 8.76 KB

api.md

File metadata and controls

282 lines (212 loc) · 8.76 KB

Functions

difference(...set)Set

Subtracts the second through nth set from the first set passed

every(set, filter)boolean

Returns true if every set element returns a truthy value when passed to the provided filter function, and false otherwise

filter(set, filter)boolean

Returns a new set with all values that cause the filter function to return a truthy value

find(set, finder)*

Returns the first set element causing the provided function to return truthy when passed

first(set)*

Returns the first element of a set

intersection(...set)Set

Returns the intersection of values in all sets passed

isSubset(set1, set2)Boolean

Returns true if the first set is a subset of the second, and false otherwise

isSuperset(set1, set2)Boolean

Returns true if the first set is a superset of the second, and false otherwise

join(set, [separator])

Joins the set elements using the provided separator, or a comma if no separator is provided

last(set)*

Returns the last element of a set

map(set, mapper)Set

Returns a new set created by calling a provided function with every element in the set.

reduce(set, reducer, [initialValue])*

Reduces a set to a single value based on the provided reduction function and optional initial value.

some(set, filter)boolean

Returns true if some set element returns a truthy value when passed to the provided filter function, and false otherwise

toArray(set)Array

Turns a set into an array

union(...set)Set

Returns a set containing the union of all sets passed

Typedefs

iteratorCallback : function
reduceCallback : function

difference(...set) ⇒ Set

Subtracts the second through nth set from the first set passed

Kind: global function
Returns: Set - first set without elements that appear in subsequent sets

Param Type
...set Set

every(set, filter) ⇒ boolean

Returns true if every set element returns a truthy value when passed to the provided filter function, and false otherwise

Kind: global function
Returns: boolean - whether every value matches the filter

Param Type Description
set Set
filter iteratorCallback function which is passed the current value and the entire set

filter(set, filter) ⇒ boolean

Returns a new set with all values that cause the filter function to return a truthy value

Kind: global function
Returns: boolean - filtered set

Param Type Description
set Set
filter iteratorCallback function which is passed the current value and the entire set

find(set, finder) ⇒ *

Returns the first set element causing the provided function to return truthy when passed

Kind: global function
Returns: * - the first value found, or undefined of nothing was found

Param Type Description
set Set
finder iteratorCallback function which is passed the current value and the entire set

first(set) ⇒ *

Returns the first element of a set

Kind: global function
Returns: * - the set's first element

Param Type
set Set

intersection(...set) ⇒ Set

Returns the intersection of values in all sets passed

Kind: global function
Returns: Set - intersection of all provided sets

Param Type
...set Set

isSubset(set1, set2) ⇒ Boolean

Returns true if the first set is a subset of the second, and false otherwise

Kind: global function
Returns: Boolean - true if set1 is a subset of set2, false otherwise

Param Type
set1 Set
set2 Set

isSuperset(set1, set2) ⇒ Boolean

Returns true if the first set is a superset of the second, and false otherwise

Kind: global function
Returns: Boolean - true if set1 is a superset of set2, false otherwise

Param Type
set1 Set
set2 Set

join(set, [separator])

Joins the set elements using the provided separator, or a comma if no separator is provided

Kind: global function

Param Type Default Description
set Set
[separator] * ',' separator, which is passed to Array.prototype.join

last(set) ⇒ *

Returns the last element of a set

Kind: global function
Returns: * - the set's last element

Param Type
set Set

map(set, mapper) ⇒ Set

Returns a new set created by calling a provided function with every element in the set.

Kind: global function
Returns: Set - mapped set

Param Type Description
set Set starting set
mapper iteratorCallback map function, which is passed the current value and the entire set

reduce(set, reducer, [initialValue]) ⇒ *

Reduces a set to a single value based on the provided reduction function and optional initial value.

Kind: global function
Returns: * - reduced value

Param Type Description
set Set starting set
reducer reduceCallback reduction function, which is passed the reduced value, current value, and entire set, in that order
[initialValue] * first value used for the reduced value passed to reducer - the first value from the set will be used if not provided

some(set, filter) ⇒ boolean

Returns true if some set element returns a truthy value when passed to the provided filter function, and false otherwise

Kind: global function
Returns: boolean - whether any values match the filter

Param Type Description
set Set
filter iteratorCallback function which is passed the current value and the entire set

toArray(set) ⇒ Array

Turns a set into an array

Kind: global function

Param Type
set Set

union(...set) ⇒ Set

Returns a set containing the union of all sets passed

Kind: global function
Returns: Set - union of all sets provided

Param Type
...set Set

iteratorCallback : function

Kind: global typedef

Param Type Description
value * set value
set Set set being iterated over

reduceCallback : function

Kind: global typedef

Param Type Description
reducedValue * intermediate reduced value
value * set value
set Set set being iterated over