Selection

Selection

Generic selection class

Constructor

new Selection()

Members

(static) EMPTY :Selection

Empty selection

forEach :function

Alias for each

Methods

and(…elements) → {Selection}

Adds elements to this selection. Any resulting duplicates are removed.

Parameters:
Name Type Attributes Description
elements Element | Array.<Element> | Selection <repeatable>

The element(s) to add

andSelf() → {Selection}

Adds the previous selection to the current selection. Resulting duplicates are removed.

clone() → {Selection}

Clones the selection and its history

contains(element) → {boolean}

Returns true if the selection contains a specific element

Parameters:
Name Type Description
element

each(fun) → {Selection}

Applies a function on each element until false is returned

Parameters:
Name Type Description
fun function

The function to apply

end() → {Selection}

Discards the last operation done on the selection

filter(predicate) → {Selection}

Applies a filter on the elements of this selection

Parameters:
Name Type Description
predicate

The filter used for filtering

first() → {Element}

Returns the first object of the selection

get(indexopt) → {Array}

Returns the element on the specified position or the whole selection as an array if position is not given

Parameters:
Name Type Attributes Description
index number <optional>

Index of the desired element; can handle negative indices (Ex: -1 is the last element)

intersects(…elements) → {Selection}

Returns the common elements between this selection and the given parameter(s)

Parameters:
Name Type Attributes Description
elements Element | Array.<Element> | Selection <repeatable>

map(fun) → {Selection}

Applies a function on the elements of this selection producing a new collection

Parameters:
Name Type Description
fun

The function to apply to each element

reduce(fun, initialValue) → {Selection}

Reduces the entire selection to a single element by applying a function on every element and an accumulated value

Parameters:
Name Type Description
fun

The function used to reduce the selection

initialValue

The value used for the first call of fun

size() → {number}

Returns the size of this selection

toArray() → {Array}

Returns the selection as an array

without(…elements) → {Selection}

Removes elements from the current selection

Parameters:
Name Type Attributes Description
elements Element | Array.<Element> | Selection <repeatable>

Elements to remove from the selection