Extends
- Map
Methods
filter(search) → {Collection}
- Source:
filters the collection, returning a collection of values where items passed in to search function returned a truthy value.
Example
const bugTables = myApp.types.filter(type => type.name.toLowerCase().includes("bug"));
Parameters:
| Name | Type | Description |
|---|---|---|
search |
function | A serch function returning true or false |
Returns:
A Collection of matches
- Type
- Collection
find(propOrFn, valueopt) → {*}
- Source:
Searches for a single item where its specified property's value is identical to the given value
(`item[prop] === value`), or the given function returns a truthy value. In the latter case, this is identical to
Array.find().
Examples
collection.find('username', 'Bob');
collection.find(val => val.username === 'Bob');
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
propOrFn |
string | function | The property to test against, or the function to test with | |
value |
* |
<optional> |
The expected value - only applicable and required if using a property for the first argument |
Returns:
- Type
- *
map(fn) → {Collection}
- Source:
The equivilent of Array.map(), where index is the ID of the item
Example
const collectionOfFields = goalType.fields.map(field => field.name);
Parameters:
| Name | Type | Description |
|---|---|---|
fn |
function | A function taking up to three arguments; current item, item ID, current collection |
Returns:
A new collection
- Type
- Collection