Mangler.filter()
Robert Biro edited this page Oct 12, 2016
·
2 revisions
Removes all array items or object properties that do not pass the test.
Mangler.filter(object, test)
Parameter | Type | Default | Description |
---|---|---|---|
object | Array Object Mangler |
The object to remove items from. | |
test | Test | {} |
The test expression to check against. |
Returns the processed object.
Removes all items from the object that do not pass the test
. For more information on test expressions, see Mangler.test().
This function changes the original object by removing its items or properties. To avoid it, you can either call Mangler.clone() to clone the object first, or use Mangler.find() which returns matching items in a new array.
a = [1, 2, 3, 4];
Mangler.filter(a, { $gt: 2 }); // a = [3, 4]
Mangler.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