Class: FilterCursor

baja. FilterCursor


new FilterCursor(context, orderedMap)

A filtered cursor used for iteration.

This Cursor is a generic Cursor used for iteration in a baja.OrderedMap.

Parameters:
Name Type Description
context Object

the context to bind to this in cursor operations.

orderedMap baja.OrderedMap

the ordered map to iterate over

See:

Extends

Methods


each(func)

Iterate through the Cursor and call a function on every item.

When the function is called, this refers to the context that
was passed in when the Cursor was created.

Parameters:
Name Type Description
func function

function called on every iteration with the 'value' being used as an argument.
If this is a Slot Cursor the 'value' will be a Slot.

Overrides:

filter(filter)

Add a filter function to the Cursor.

Parameters:
Name Type Description
filter function

used to filter the results of the Cursor.
When invoked, the first argument will be the item to filter (i.e. a Slot).
This function must return a true value for the item to be kept.

Returns:

itself.

Type
baja.FilterCursor

first()

Return the first item in the cursor (regardless of iterative state).

If this is being used as a Slot Cursor, the Slot will be returned.

Returns:

first item found in the Cursor (or null if nothing found).


get()

Return the current item. If this is a
SlotCursor, this will return a
Slot.

Overrides:
Returns:

the cursor value (null if none available).


getSize()

Return the size of the cursor (regardless of iterative state).

Returns:
Type
Number

isEmpty()

Return true if the Cursor is completely empty (regardless of iterative state).

Returns:
Type
Boolean

last()

Return the last item in the cursor (regardless of iterative state).

If this is being used as a Slot Cursor, the Slot will be returned.

Returns:

last item found in the Cursor (or null if nothing found).


next()

Advance cursor and return true if successful.

Overrides:
Returns:
Type
Boolean

toArray()

Return an array of the cursor results (regardless of iterative state).
If this is a Slot Cursor, this will be an array of Slots.

Returns:
Type
Array

toMap()

Return an Object Map of keys with their corresponding values.
If this is a Slot Cursor, this will be a Map of Slot names with their
corresponding Slots (regardless of iterative state).

Returns:
Type
Object