filter-obj
Advanced tools
Comparing version 1.0.0 to 1.1.0
'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 @@ } |
{ | ||
"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 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2947
14
42