API Docs for: 7.2
Show:

MQA.Collection Class

Module: MQA

General purpose collection library.

Extends Array and Objects instances to have List and Map like methods to make iteration, retrieval, and deletion easier.

Note that Array.prototype and Object.prototype are left alone, the map and list constructors just mutate instances.

Methods

convertKey

(
  • obj
)
String private

Translates an arbitrary object to a key suitable for storage in a map. This allows us to just iterate over the keys and easily skip the properties that aren't user set keys.

If the obj is a string or number, then the returned key will be the string representation of the object prepended with "@$". Otherwise, it will be the objectId() prepended with "@#"

Parameters:

Returns <String>

the unique key for the object

each

(
  • callback
)

Invokes the specified callback for each item in the list. The callback is invoked with arguments (item, index).

Parameters:

insert

(
  • index
  • item
)

Insert the given item at the given index.

Parameters:

isKey

(
  • key
)
Boolean private

Returns true if the string is a valid key for the collection map.

Parameters:

  • key String

    the string to test

Returns <Boolean>

true if the string is a valid key

removeAll

(
  • match
  • fromIndex
)

Remove all items matching the "match" argument, optionally starting fromIndex if specified. If match is a function, then it is invoked as a two-argument predicate(item, index). If true, a given item is removed. If not a function, then it is evaluated with == against each item, removing any matches.

Parameters:

removeAt

(
  • index
)

Remove the item at index and return it.

Parameters: