@goa/goa
Version:
The Goa Source Code For Compilation Into @Goa/Koa That Includes Modules, Tests, Types And Dependencies.
13 lines • 344 B
JavaScript
/**
* Return white-listed properties of an object.
* @param {Object} obj
* @param {(!Array<string>|string)} keys
*/
export default function(obj = {}, keys = []){
if ('string' == typeof keys) keys = keys.split(/ +/)
return keys.reduce((ret, key) => {
if (null == obj[key]) return ret
ret[key] = obj[key]
return ret
}, {})
}