1.0.2 • Published 6 years ago
@joelwallis/only v1.0.2
@joelwallis/only
Return whitelisted properties of an object.
Installation
$ npm install @joelwallis/only
API
An array or space-delimited string may be given:
var obj = {
name: 'tobi',
last: 'holowaychuk',
email: 'tobi@learnboost.com',
_id: '12345'
}
var user = only(obj, 'name last email')
You can also use array form:
var user = only(obj, ['name', 'last', 'email'])
yields:
{
name: 'tobi',
last: 'holowaychuk',
email: 'tobi@learnboost.com'
}