object-description-filter
v2.0.0
Published
perform a nested filter on an object based on description of desired object
Downloads
205
Readme
object-description-filter
Pass in an object, and a nested description of the desired return object. Return will be filtered version of passed in object based on description. Will ignore keys in the description if they don't exist in the base object.
use
npm i --save object-description-filter
var objectDescriptionFilter = require('object-description-filter');
var obj = {
nice: "dope",
cool: "wow",
luther: {
cool: {
dope: {
wow: "nice",
nice: "not"
}
}
}
};
var description = {
nice: true,
luther: {
cool: {
dope: {
wow: true,
super: true
}
}
}
};
var filtered = objectDescriptionFilter(obj, description);
/* returns
{
"nice": "dope",
"luther": {
"cool": {
"dope": {
"wow": "nice"
}
}
}
}
/*