Socket
Socket
Sign inDemoInstall

filter-obj

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-obj - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

5

index.js
'use strict';
module.exports = function (obj, fn) {
module.exports = function (obj, predicate) {
var ret = {};
var keys = Object.keys(obj);
var isArr = Array.isArray(predicate);

@@ -10,3 +11,3 @@ for (var i = 0; i < keys.length; i++) {

if (fn(key, val, obj)) {
if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) {
ret[key] = val;

@@ -13,0 +14,0 @@ }

2

package.json
{
"name": "filter-obj",
"version": "1.0.0",
"version": "1.1.0",
"description": "Filter object keys and values into a new object",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -27,2 +27,5 @@ # filter-obj [![Build Status](https://travis-ci.org/sindresorhus/filter-obj.svg?branch=master)](https://travis-ci.org/sindresorhus/filter-obj)

//=> {foo: true}
var newObject2 = filterObj(obj, ['bar']);
//=> {bar: true}
```

@@ -29,0 +32,0 @@

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