1.0.2 • Published 6 years ago

@joelwallis/only v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

@joelwallis/only

Build Status

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'
}

License

MIT