-
Notifications
You must be signed in to change notification settings - Fork 0
Mangler.findOne()
Robert Biro edited this page Oct 12, 2016
·
4 revisions
Returns the first item of an iterable that passes the test.
Mangler.findOne(collection[, test])| Parameter | Type | Default | Description |
|---|---|---|---|
| collection | Iterable | The collection of values to search. | |
| test | Test | {} |
The test expression to check against. |
Returns the first item that passes the test.
If called without a test parameter, it returns the first item of the collection.
The collection iterable could be an object, array or mangler object by default. Please note that even though a JavaScript object is iterable, it is not guaranteed that its properties will be evaluated in any particular order.
For more information on test expressions, see Mangler.test().
a = [1, 2, 3, 4];
Mangler.findOne(a); // Returns 1
Mangler.findOne(a, { $gt: 2 }); // Returns 3Mangler.js - JavaScript object processing library
Copyright (C) 2014-2016
Project: http://codebin.co.uk/projects/mangler-js/
GitHub: https://github.com/DarthJDG/Mangler.js
- Home
- About the documentation
- Getting started
- Searching and querying
- Transforming data
- Advanced