new CollectorBase()
A collector
- Source:
Members
-
length :integer
-
Get the size of the collection
Type:
- integer
- Source:
Methods
-
add(key, item)
-
Adds an item to the collection
Parameters:
Name Type Description key* The key to use for the item being added.
item* The item to add to the collection. The item is not iterated so that you could add bundled items to the collecion
- Source:
-
all(qu) → {boolean}
-
Returns true if all items match the query. Aliases as
everyParameters:
Name Type Description quobject The query to execute
- Source:
Returns:
- Type
- boolean
-
any(qu) → {boolean}
-
Returns true if any of the items match the query. Aliases as
allParameters:
Name Type Description quobject The query to execute
- Source:
Returns:
- Type
- boolean
-
countBy(query, iterator, thisobj) → {object}
-
Creates an object composed of keys returned from running each element of the collection through the given callback. The corresponding value of each key is the number of times the key was returned by the callback.
Parameters:
Name Type Argument Description queryobject <optional>
A query to evaluate. If you pass in a query, only the items that match the query are iterated over.
iteratorfunction thisobjobject <optional>
The value of
this- Source:
Returns:
- Type
- object
-
each(query, iterator, thisobj)
-
Iterate over each item in the collection, or a subset that matches a query. This supports two signatures:
.each(query, function)and.each(function). If you pass in a query, only the items that match the query are iterated over.Parameters:
Name Type Argument Description queryobject <optional>
A query to evaluate
iteratorfunction Function to execute against each item in the collection
thisobjobject <optional>
The value of
this- Source:
-
every(qu) → {boolean}
-
Returns true if all items match the query. Aliases as
allParameters:
Name Type Description quobject The query to execute
- Source:
Returns:
- Type
- boolean
-
find(qu) → {array}
-
Find all records that match a query
Parameters:
Name Type Description quobject The query to execute.
- Source:
Returns:
The results
- Type
- array
-
findKeys(qu) → {array}
-
Find all records that match a query and returns the keys for those items. This is similar to module:ink/probe.find but instead of returning records, returns the keys. If
objis an object it will return the hash key. If 'obj' is an array, it will return the indexParameters:
Name Type Description quobject The query to execute.
- Source:
Returns:
- Type
- array
-
findOne(qu) → {object}
-
Returns the first record that matches the query. Aliased as
seek.Parameters:
Name Type Description quobject The query to execute.
- Source:
Returns:
- Type
- object
-
findOneKey(qu) → {object}
-
Returns the first record that matches the query and returns its key or index depending on whether
objis an object or array respectively. Aliased asseekKey.Parameters:
Name Type Description quobject The query to execute.
- Source:
Returns:
- Type
- object
-
groupBy(query, iterator, thisobj) → {object}
-
Creates an object composed of keys returned from running each element of the collection through the callback. The corresponding value of each key is an array of elements passed to callback that returned the key. The callback is invoked with three arguments: (value, index|key, collection).
Parameters:
Name Type Argument Description queryobject <optional>
A query to evaluate . If you pass in a query, only the items that match the query are iterated over.
iteratorfunction thisobjobject <optional>
The value of
this- Source:
Returns:
- Type
- object
-
map(query, iterator, thisobj) → {array}
-
Maps the contents to an array by iterating over it and transforming it. You supply the iterator. Supports two signatures:
.map(query, function)and.map(function). If you pass in a query, only the items that match the query are iterated over.Parameters:
Name Type Argument Description queryobject <optional>
A query to evaluate
iteratorfunction The function that will be executed in each item in the collection
thisobjobject <optional>
The value of
this- Source:
Returns:
- Type
- array
-
max(query, iterator, thisobj) → {number}
-
Retrieves the maximum value of an array. If callback is passed, it will be executed for each value in the array to generate the criterion by which the value is ranked.
Parameters:
Name Type Argument Description queryobject <optional>
A query to evaluate . If you pass in a query, only the items that match the query are iterated over.
iteratorfunction thisobjobject <optional>
The value of
this- Source:
Returns:
- Type
- number
-
min(query, iterator, thisobj) → {number}
-
Retrieves the minimum value of an array. If callback is passed, it will be executed for each value in the array to generate the criterion by which the value is ranked.
Parameters:
Name Type Argument Description queryobject <optional>
A query to evaluate . If you pass in a query, only the items that match the query are iterated over.
iteratorfunction thisobjobject <optional>
The value of
this- Source:
Returns:
- Type
- number
-
pluck(query, property) → {*}
-
Reduce the collection to a single value. Supports two signatures:
.pluck(query, function)and.pluck(function)Parameters:
Name Type Argument Description queryobject <optional>
The query to evaluate. If you pass in a query, only the items that match the query are iterated over.
propertystring The property that will be 'plucked' from the contents of the collection
- Source:
Returns:
- Type
- *
-
reduce(query, iterator, accumulator, thisobj) → {*}
-
Reduces a collection to a value which is the accumulated result of running each element in the collection through the callback, where each successive callback execution consumes the return value of the previous execution. If accumulator is not passed, the first element of the collection will be used as the initial accumulator value. are iterated over.
Parameters:
Name Type Argument Description queryobject <optional>
A query to evaluate
iteratorfunction The function that will be executed in each item in the collection
accumulator* <optional>
Initial value of the accumulator.
thisobjobject <optional>
The value of
this- Source:
Returns:
- Type
- *
-
remove(qu) → {object|array}
-
Remove all items in the object/array that match the query
Parameters:
Name Type Description quobject The query to execute. See module:ink/probe.queryOperators for the operators you can use.
- Source:
Returns:
The array or object as appropriate without the records.
- Type
- object | array
-
shuffle() → {array}
-
Creates an array of shuffled array values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle.
- Source:
Returns:
- Type
- array
-
some(qu) → {boolean}
-
Returns true if any of the items match the query. Aliases as
anyParameters:
Name Type Description quobject The query to execute
- Source:
Returns:
- Type
- boolean
-
sortBy(query, iterator, thisobj) → {array}
-
Returns a sorted copy of the collection.
Parameters:
Name Type Argument Description queryobject <optional>
The query to evaluate. If you pass in a query, only the items that match the query are iterated over.
iteratorfunction thisobjobject <optional>
The value of
this- Source:
Returns:
- Type
- array
-
toArray() → {array}
-
Returns the collection as an array. If it is already an array, it just returns that.
- Source:
Returns:
- Type
- array
-
toJSON() → {object}
-
Supports conversion to a JSON string or for passing over the wire
- Source:
Returns:
- Type
- object
-
unique(qu) → {array}
-
Returns the set of unique records that match a query
Parameters:
Name Type Description quobject The query to execute.
- Source:
Returns:
- Type
- array
-
update(qu, setDocument)
-
Updates all records in obj that match the query. See module:ink/probe.updateOperators for the operators that are supported.
Parameters:
Name Type Description quobject The query which will be used to identify the records to updated
setDocumentobject The update operator. See module:ink/probe.updateOperators
- Source: