# filter-object

> Filter an object by its keys or values. Returns a copy of an object filtered to have only keys or values that match the given glob patterns.

Latest version **3.0.0** (published 2017-06-19) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2017-06-19 |
| First published | 2014-10-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 24 |
| Author | Jon Schlinkert |
| Maintainers | jonschlinkert |
| Keywords | arr, array, expand, filter, find, function, glob, globbing, globs, key, keys, match, matcher, minimatch, obj, object, order, pattern, patterns, sort, wildcard |

## Links

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

## Dependencies (3)

- [isobject](https://npm.io/package/isobject.md) ^3.0.0
- [glob-object](https://npm.io/package/glob-object.md) ^1.0.0
- [filter-values](https://npm.io/package/filter-values.md) ^0.4.1

## Recent versions

- 3.0.0 (latest) — 2017-06-19
- 2.1.0 — 2015-09-08
- 2.0.0 — 2015-08-01
- 1.1.2 — 2015-03-31
- 1.1.1 — 2015-03-31
- 1.1.0 — 2015-01-20
- 1.0.1 — 2015-01-19
- 1.0.0 — 2014-12-30
- 0.2.0 — 2014-11-24
- 0.1.3 — 2014-10-24
- 0.1.1 — 2014-10-24

## README

# filter-object [![NPM version](https://img.shields.io/npm/v/filter-object.svg?style=flat)](https://www.npmjs.com/package/filter-object) [![NPM monthly downloads](https://img.shields.io/npm/dm/filter-object.svg?style=flat)](https://npmjs.org/package/filter-object) [![NPM total downloads](https://img.shields.io/npm/dt/filter-object.svg?style=flat)](https://npmjs.org/package/filter-object) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/filter-object.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/filter-object)

> Filter an object by its keys or values. Returns a copy of an object filtered to have only keys or values that match the given glob patterns.

## Install

Install with [npm](https://www.npmjs.com/):

```sh
$ npm install --save filter-object
```

## Usage

### Filter with glob patterns

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

console.log(filter({a: 'a', b: 'b', c: 'c'}, '*'));
//=> {a: 'a', b: 'b', c: 'c'}

console.log(filter({a: 'a', b: 'b', c: 'c'}, 'b'));
//=> {b: 'b'}

console.log(filter({foo: 'a', bar: 'b', baz: 'c'}, 'b*'));
//=> {bar: 'b', baz: 'c'}

console.log(filter({a: 'a', b: 'b', c: 'c'}, '{b,c}'));
//=> {b: 'b', c: 'c'}

console.log(filter({a: 'a', b: 'b', c: 'c'}, ['a', 'b']));
//=> {a: 'a', b: 'b'}
```

**Negation patterns**

```js
console.log(filter({foo: 'a', bar: 'b', baz: 'c'}, ['!b*']));
//=> { foo: 'a' }

console.log(filter({a: {b: {foo: 'a', bar: 'b', baz: 'c'}}}, ['!a.b.b*']));
//=> {a: {b: {foo: 'a'}}}
```

### options

Options are passed to [glob-object](https://github.com/jonschlinkert/glob-object) and/or [filter-values](https://github.com/jonschlinkert/filter-values)

```js
filter({foo: 'a', bar: 'b', baz: 'c'}, ['*', '!b*'], options);
```

See [glob-object](https://github.com/jonschlinkert/glob-object) and/or [filter-values](https://github.com/jonschlinkert/filter-values) for the full range of options and available features.

## About

### Related projects

* [filter-keys](https://www.npmjs.com/package/filter-keys): Filter the keys of an object using glob patterns. | [homepage](https://github.com/jonschlinkert/filter-keys "Filter the keys of an object using glob patterns.")
* [filter-values](https://www.npmjs.com/package/filter-values): Filter an object values using glob patterns or with a `callback` function returns true.  | [homepage](https://github.com/jonschlinkert/filter-values "Filter an object values using glob patterns or with a `callback` function returns true. ")
* [micromatch](https://www.npmjs.com/package/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. | [homepage](https://github.com/micromatch/micromatch "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.")
* [rename-keys](https://www.npmjs.com/package/rename-keys): Modify the names of the own enumerable properties (keys) of an object. | [homepage](https://github.com/jonschlinkert/rename-keys "Modify the names of the own enumerable properties (keys) of an object.")
* [sort-object](https://www.npmjs.com/package/sort-object): Sort the keys in an object. | [homepage](https://github.com/doowb/sort-object "Sort the keys in an object.")

### Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).

### Building docs

_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_

To generate the readme, run the following command:

```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```

### Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

```sh
$ npm install && npm test
```

### Author

**Jon Schlinkert**

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

### License

Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).

***

_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on June 19, 2017._

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