# 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 |
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 |
true if this set did not already contain the specified element[s]
boolean
# asArray() → {Array.<*>}
Return the set as a javascript array.
the set represented as a javascript array
Array.<*>
# contains(element) → {boolean}
Returns true if this set contains the specified element.
Parameters:
Name | Type | Description |
---|---|---|
element |
*
|
the element to test |
boolean
# fromJS() → {ISet|undefined}
Convert from a js representation to an internal one.
the current object, or undefined if the conversion did not work
ISet
|
undefined
# remove(element) → {boolean}
Removes the specified element from this set if it is present.
Parameters:
Name | Type | Description |
---|---|---|
element |
*
|
the element to remove |
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.
the JS representation of this object
*
# toJson() → {string}
Represents the current set as json.
the current set represented as json
string