# filter-array

> Iterates over the elements in an array, returning an array with only the elements for which the callback returns truthy.

Latest version **0.2.0** (published 2015-05-02) · MIT license · 0 weekly downloads

> **Native alternative:** Array.prototype.filter — Use native JavaScript (Node 0.10.0+) (https://developer.mozilla.orgGlobal_Objects/Array/filter)

## Install

```sh
npm install filter-array
pnpm add filter-array
yarn add filter-array
bun add filter-array
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2015-05-02 |
| First published | 2014-12-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Jon Schlinkert |
| Maintainers | jonschlinkert |
| Keywords | array, match, elements, filter, iterate |

## Links

- npm: https://www.npmjs.com/package/filter-array
- Repository: https://github.com/jonschlinkert/filter-array
- Issues: https://github.com/jonschlinkert/filter-array/issues
- npm.io page: https://npm.io/package/filter-array

## Dependencies (3)

- [kind-of](https://npm.io/package/kind-of.md) ^1.1.0
- [arr-filter](https://npm.io/package/arr-filter.md) ^1.1.0
- [micromatch](https://npm.io/package/micromatch.md) ^2.1.0

## Recent versions

- 0.2.0 (latest) — 2015-05-02
- 0.1.0 — 2014-12-12

## README

# filter-array [![NPM version](https://badge.fury.io/js/filter-array.svg)](http://badge.fury.io/js/filter-array)

> Iterates over the elements in an array, returning an array with only the elements for which the callback returns truthy.

## Install with [npm](npmjs.org)

```bash
npm i filter-array --save
```

## Usage

### [filterArray](index.js#L36)

Filter array against given glob patterns, regex or given function.

**Params**

* `arr` **{Array}**: array to filter
* `filters` **{Array|String|Function|RegExp}**
* `opts` **{Object}**: options to pass to [micromatch](https://github.com/jonschlinkert/micromatch)
* `returns` **{Array}**

**Example**

```js
var filter = require('filter-array');

filter(['a', 'b', 'c', 'b', 'c', 'e'], function(ele) {
  return ele === 'a' || ele === 'b';
});

//=> ['a', 'b', 'b']
```

For more examples see the [tests](./test.js)

## Related

* [arr-filter](https://github.com/jonschlinkert/arr-filter): Faster alternative to javascript's native filter method.
* [filter-object](https://github.com/jonschlinkert/filter-object): Return a copy of an object, filtered to have only keys that match the given… [more](https://github.com/jonschlinkert/filter-object)
* [micromatch](https://github.com/jonschlinkert/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. Just… [more](https://github.com/jonschlinkert/micromatch)

## Run Tests

Install dev dependencies:

```bash
npm i -d && npm test
```

## Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/filter-array/issues)

## Author

**Jon Schlinkert**

+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)

## License

Copyright (c) 2014-2015 Jon Schlinkert
Released under the MIT license.

***

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on May 01, 2015._

<!-- reflinks generated by verb-reflinks plugin -->

---
_Source: https://npm.io/package/filter-array · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
