FilterCursor

baja. FilterCursor

new FilterCursor(context, orderedMap)

Description:
  • A filtered cursor used for iteration.

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

Source:
See:
Parameters:
Name Type Description
context Object

the context to bind to this in cursor operations.

orderedMap baja.OrderedMap

the ordered map to iterate over

Extends

Methods

each(func)

Description:
  • 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.

Source:
Overrides:
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.

filter(filter) → {baja.FilterCursor}

Description:
  • Add a filter function to the Cursor.

Source:
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()

Description:
  • 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.

Source:
Returns:

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

get()

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

Source:
Overrides:
Returns:

the cursor value (null if none available).

getSize() → {Number}

Description:
  • Return the size of the cursor (regardless of iterative state).

Source:
Returns:
Type
Number

isEmpty() → {Boolean}

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

Source:
Returns:
Type
Boolean

last()

Description:
  • 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.

Source:
Returns:

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

next() → {Boolean}

Description:
  • Advance cursor and return true if successful.

Source:
Overrides:
Returns:
Type
Boolean

toArray() → {Array}

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

Source:
Returns:
Type
Array

toMap() → {Object}

Description:
  • 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).

Source:
Returns:
Type
Object