npm install filter-properties --save
The whitelist
is an Array
of strings.
var whitelist = [ "username" ]
The object
is the input data.
var object = { username: "acro", gender: "male" }
Applying the filter
function onto these two inputs will return a filtered object.
var filter = require("filter-properties")
var filtered = filter(whitelist, object)
// { username: "acro" }
This library has no dependencies.
MIT