47 lines
1.7 KiB
Markdown
47 lines
1.7 KiB
Markdown
[](https://www.npmjs.org/package/reduce-extract)
|
|
[](https://www.npmjs.org/package/reduce-extract)
|
|
[](https://travis-ci.org/75lb/reduce-extract)
|
|
[](https://david-dm.org/75lb/reduce-extract)
|
|
[](https://github.com/feross/standard)
|
|
|
|
<a name="module_reduce-extract"></a>
|
|
## reduce-extract
|
|
|
|
|
|
<a name="exp_module_reduce-extract--extract"></a>
|
|
### extract(query) ⏏
|
|
Removes items from `array` which satisfy the query. Modifies the input array, returns the extracted.
|
|
|
|
**Kind**: Exported function
|
|
|
|
| Param | Type | Description |
|
|
| ----- | ------- | ------------------------------------------------------------ |
|
|
| query | `Array` | the input array, modified directly |
|
|
| | `any` | if an item in the input array passes this test it is removed |
|
|
|
|
|
|
**Example**
|
|
```js
|
|
> DJs = [
|
|
{ name: "Trevor", sacked: true },
|
|
{ name: "Mike", sacked: true },
|
|
{ name: "Chris", sacked: false },
|
|
{ name: "Alan", sacked: false }
|
|
]
|
|
|
|
> a.extract(DJs, { sacked: true })
|
|
[ { name: 'Trevor', sacked: true },
|
|
{ name: 'Mike', sacked: true } ]
|
|
|
|
> DJs
|
|
[ { name: 'Chris', sacked: false },
|
|
{ name: 'Alan', sacked: false } ]
|
|
```
|
|
|
|
|
|
|
|
|
|
* * *
|
|
|
|
© 2016 Lloyd Brookes <75pound@gmail.com>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).
|