Skip to content
This repository was archived by the owner on May 20, 2021. It is now read-only.

Collection.API

Lee Tagg edited this page Aug 23, 2015 · 1 revision

Class: Collection

Collection

new Collection()

A bare minimum set of utilities for working with collections

Source:

Methods

each(collection, callback)

Iterate over each element in a collection.

Parameters:
Name Type Description
collection object | array

The collection to iterate over can be either an array or an object

callback callback(index, element)

is executed for each element in the collection

Source:
Tutorials:
  • Tutorial: collection.each

filter(collection, callback, empty) → {object|array}

Return a new collection being a filtered subset of elements from a collection

Parameters:
Name Type Argument Default Description
collection object | array

The collection to iterate over can be either an array or an object

callback callback(element)

Predicate callback is executed for each element in the collection and must return true if the element will be included in the filter

empty Object | Array <optional>
empty array

You can provide an empty array or object to be populated by the filter procedure. By default the returned collection is an array however you can populate properties on an object by specifying an object as the empty.

Source:
Tutorials:
  • Tutorial: collection.filter
Returns:

collection

Type
object | array

find(collection, callback) → {*|null}

Find the first item satisfied by predicate callback in the provided collection

Parameters:
Name Type Description
collection object | array

The collection to iterate over can be either an array or an object

callback callback(element)

Predicate callback is executed for each element in the collection and must return true if the element will be included in the filter

Source:
Tutorials:
  • Tutorial: collection.find
Returns:

returns the found element or null if no element wa found

Type
* | null

Generated with wicked.