set_utils

A set of utilities for performing set operations on arrays (as if they were sets). All the methods will also take sets.

Description:
  • A set of utilities for performing set operations on arrays (as if they were sets). All the methods will also take sets.

Source:

Methods

(static) difference(A, B) → {Array|Set}

Description:
  • Returns an array with elements in one of the two sets, but not both.

Source:
Parameters:
Name Type Description
A Array | Set

the first array (a set is OK but this method won't do anything)

B Array | Set

the second array (a set is OK but this method won't do anything)

Returns:

an array or set with unique values only (matching the type of the argument).

Type
Array | Set

(static) intersection(A, B) → {Array|Set}

Description:
  • Returns an array with elements in both of the arrays or sets.

Source:
Parameters:
Name Type Description
A Array | Set

the first array or set

B Array | Set

the second array or set

Returns:

an array or set with unique values only (matching the type of the argument).

Type
Array | Set

(static) unique(input) → {Array|Set}

Description:
  • Returns an array with only the unique values in the source array.

Source:
Parameters:
Name Type Description
input Array | Set

an array (a set is OK but this method won't do anything)

Returns:

an array or set with unique values only (matching the type of the argument).

Type
Array | Set

(static) without(input, …element) → {Array|Set}

Description:
  • Returns an array with only the unique values in the source array.

Source:
Example
without(["A", "B", "C"], "B", "C");
=> ["A"]
Parameters:
Name Type Attributes Description
input Array | Set

the array or set to modify

element * <repeatable>

an element to remove from the set or array

Returns:

an array or set without the values specified

Type
Array | Set