New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

filter-values

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filter-values - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

27

index.js

@@ -5,3 +5,3 @@ /*!

* Copyright (c) 2015, Jon Schlinkert.
* Licensed under the MIT license.
* Licensed under the MIT License.
*/

@@ -11,7 +11,17 @@

var iterator = require('make-iterator');
var mm = require('micromatch');
module.exports = function filterValues(obj, cb, thisArg) {
cb = iterator(cb, thisArg);
/**
* Filter an object values using glob patterns
* or with a `callback` function returns true.
*
* @param {Object} `obj`
* @param {Function|Array|String} `filter`
* @param {Object} `thisArg`
* @return {Object}
*/
module.exports = function filterValues(obj, filter, thisArg) {
var cb = matcher(filter, thisArg);
var res = {};
forOwn(obj, function (val, key, o) {

@@ -24,1 +34,10 @@ if (cb(val, key, o)) {

};
function matcher(filter, thisArg) {
if (Array.isArray(filter) || typeof filter === 'string') {
return function (val) {
return !!mm(val, filter).length;
};
}
return iterator(filter, thisArg)
}

39

package.json
{
"name": "filter-values",
"description": "Filter an object to have only the `own` properties for which a `callback` function returns true. ",
"version": "0.1.0",
"description": "Filter an object values using glob patterns or with a `callback` function returns true. ",
"version": "0.2.0",
"homepage": "https://github.com/jonschlinkert/filter-values",

@@ -19,4 +19,7 @@ "author": {

"type": "MIT",
"url": "https://github.com/jonschlinkert/filter-values/blob/master/LICENSE-MIT"
"url": "https://github.com/jonschlinkert/filter-values/blob/master/LICENSE"
},
"files": [
"index.js"
],
"main": "index.js",

@@ -27,3 +30,3 @@ "engines": {

"scripts": {
"test": "mocha -R spec"
"test": "mocha"
},

@@ -34,7 +37,25 @@ "devDependencies": {

},
"keywords": [],
"dependencies": {
"for-own": "^0.1.2",
"make-iterator": "^0.1.1"
}
"keywords": [
"filter",
"find",
"glob",
"globbing",
"globs",
"key",
"keys",
"match",
"matcher",
"minimatch",
"obj",
"object",
"pattern",
"patterns",
"properties",
"property",
"props",
"regex",
"sort",
"test",
"wildcard"
]
}

@@ -1,4 +0,4 @@

# filter-values [![NPM version](https://badge.fury.io/js/filter-values.svg)](http://badge.fury.io/js/filter-values)
# filter-values [![NPM version](https://badge.fury.io/js/filter-values.svg)](http://badge.fury.io/js/filter-values) [![Build Status](https://travis-ci.org/jonschlinkert/filter-values.svg)](https://travis-ci.org/jonschlinkert/filter-values)
> Filter an object to have only the `own` properties for which a `callback` function returns true.
> Filter an object values using glob patterns or with a `callback` function returns true.

@@ -31,10 +31,22 @@ ## Install with [npm](npmjs.org)

//=> {b: 'b'}
filter({a: 'a', b: 'bbd', c: 'bca2'}, ['b*', '!bc*'])
//=> {b: 'bbd'}
filter({a: 'a', b: 'bbd', c: 'bca2'}, '!b*')
//=> {a: 'a'}
```
## Run tests
## Related
* [filter-object](https://github.com/jonschlinkert/filter-object): Return a copy of an object, filtered to have only keys that match the given glob patterns.
* [filter-values](https://github.com/jonschlinkert/filter-values): Filter an object to have only the `own` properties for which a `callback` function returns true.
* [micromatch](https://github.com/jonschlinkert/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. Just use `micromatch.isMatch()` instead of `minimatch()`, or use `micromatch()` instead of `multimatch()`.
* [rename-keys](https://github.com/jonschlinkert/rename-keys): Modify the names of the own enumerable properties (keys) of an object.
* [sort-object](https://github.com/doowb/sort-object): Sort the keys in an object.
## Running tests
Install dev dependencies:
```bash
node i -d && mocha
npm i -d && npm test
```

@@ -48,3 +60,3 @@

**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)

@@ -59,2 +71,2 @@ + [twitter/jonschlinkert](http://twitter.com/jonschlinkert)

_This file was generated by [verb](https://github.com/assemble/verb) on January 19, 2015._
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 31, 2015._
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