Class

ISet

ISet(elementsopt)

Constructor

# new ISet(elementsopt)

Create a new set with elements in the given array. The type of the set is gleaned from the type of the first element in the elements array, or the first element added to the set. The type may be "string" or "number", and all elements will be returned as elements of that type.

Parameters:
Name Type Attributes Description
elements Array.<(string|number)> <optional>

initial elements to add to the set

View Source ISet.js, line 31

Methods

# add(element) → {boolean}

Adds the specified element or array of elements to this set if it is or they are not already present.

Parameters:
Name Type Description
element * | Array.<*>

element or array of elements to add

View Source ISet.js, line 66

true if this set did not already contain the specified element[s]

boolean

# asArray() → {Array.<*>}

Return the set as a javascript array.

View Source ISet.js, line 124

the set represented as a javascript array

Array.<*>

# clear()

Removes all of the elements from this set.

View Source ISet.js, line 83

# contains(element) → {boolean}

Returns true if this set contains the specified element.

Parameters:
Name Type Description
element *

the element to test

View Source ISet.js, line 92

boolean

# fromJS() → {ISet|undefined}

Convert from a js representation to an internal one.

View Source ISet.js, line 160

the current object, or undefined if the conversion did not work

ISet | undefined

# isEmpty() → {boolean}

Returns true if this set contains no elements.

View Source ISet.js, line 102

boolean

# remove(element) → {boolean}

Removes the specified element from this set if it is present.

Parameters:
Name Type Description
element *

the element to remove

View Source ISet.js, line 111

true if the set contained the specified element

boolean

# toJS() → {*}

Convert to a javascript representation of this object. In this case, it is a normal JS array.

View Source ISet.js, line 152

the JS representation of this object

*

# toJson() → {string}

Represents the current set as json.

View Source ISet.js, line 143

the current set represented as json

string