Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

filter-object

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filter-object - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

8

index.js
'use strict';
var typeOf = require('kind-of');
var filterKeys = require('filter-keys');
var filterValues = require('filter-values');
var sortObject = require('sort-object');

@@ -12,6 +14,10 @@ var extend = require('extend-shallow');

if (patterns == nul) return o;
if (patterns == null) return o;
if (typeOf(patterns) === 'function') {
return filterValues(o, patterns, options);
}
var keys = filterKeys(o, patterns, options);
return sortObject(o, extend({keys: keys}, options));
};

12

package.json
{
"name": "filter-object",
"description": "Return a copy of an object, filtered to have only keys that match the given glob patterns.",
"version": "1.0.1",
"version": "1.1.0",
"homepage": "https://github.com/jonschlinkert/filter-object",

@@ -26,10 +26,12 @@ "author": {

"scripts": {
"test": "mocha -R spec",
"lint": "jshint **.js",
"docs": "update && license && verb && deps",
"all": "npm run test && npm run lint && npm run docs"
"test": "mocha -R spec"
},
"devDependencies": {
"helper-reflinks": "^0.2.0"
},
"dependencies": {
"extend-shallow": "^0.2.0",
"filter-keys": "^1.0.0",
"filter-values": "^0.1.0",
"kind-of": "^1.0.0",
"sort-object": "^0.3.2"

@@ -36,0 +38,0 @@ },

@@ -14,2 +14,4 @@ # filter-object [![NPM version](https://badge.fury.io/js/filter-object.svg)](http://badge.fury.io/js/filter-object)

### Filter with glob patterns
```js

@@ -40,3 +42,3 @@ var filter = require('filter-object');

Pass options to [sort-object]
Pass options to [sort-object] and/or [filter-keys]

@@ -50,2 +52,23 @@ ```js

### Filter with a callback function
```js
filter({a: 'a', b: 'b', c: 'c'}, function(value, key, obj) {
return key !== 'b';
});
//=> {a: 'a', c: 'c'}
filter({a: 'a', b: 'b', c: 'c'}, function(value, key, obj) {
return key === 'b';
});
//=> {b: 'b'}
filter({a: 'a', b: 'b', c: 'c'}, function(value, key, obj) {
return value === 'b';
});
//=> {b: 'b'}
```
## Run tests

@@ -65,8 +88,8 @@

**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright (c) 2015 Jon Schlinkert
Copyright (c) 2014-2015 Jon Schlinkert
Released under the MIT license

@@ -78,2 +101,22 @@

[sort-object]: https://github.com/helpers/sort-object
[array-slice]: https://github.com/jonschlinkert/array-slice
[extend-shallow]: https://github.com/jonschlinkert/extend-shallow
[arr-diff]: https://github.com/jonschlinkert/arr-diff
[array-unique]: https://github.com/jonschlinkert/array-unique
[arr-union]: https://github.com/jonschlinkert/arr-union
[alphabet]: https://github.com/jonschlinkert/alphabet
[is-number]: https://github.com/jonschlinkert/is-number
[fill-range]: https://github.com/jonschlinkert/fill-range
[expand-range]: https://github.com/jonschlinkert/expand-range
[braces]: https://github.com/jonschlinkert/braces
[filename-regex]: https://github.com/regexps/filename-regex
[unixify]: https://github.com/jonschlinkert/unixify
[micromatch]: https://github.com/jonschlinkert/micromatch
[filter-keys]: https://github.com/jonschlinkert/filter-keys
[filter-values]: https://github.com/jonschlinkert/filter-values
[kind-of]: https://github.com/jonschlinkert/kind-of
[sort-asc]: https://github.com/jonschlinkert/sort-asc
[sort-desc]: https://github.com/jonschlinkert/sort-desc
[sort-object]: https://github.com/helpers/sort-object
<!-- deps: helper-reflinks -->
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc