UNPKG
only
Version:
latest (0.0.2)
0.0.2
0.0.1
return whitelisted properties of an object
visionmedia/node-only
only
/
index.js
11 lines
(9 loc)
•
247 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
module
.
exports
=
function
(
obj, keys
){ obj = obj || {};
if
(
'string'
==
typeof
keys) keys = keys.
split
(
/ +/
);
return
keys.
reduce
(
function
(
ret, key
){
if
(
null
== obj[key])
return
ret; ret[key] = obj[key];
return
ret; }, {}); };