1.0.0 • Published 6 years ago

array-to-object-template v1.0.0

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

array-to-object-template

This library is for a specific use case. It goes something like this.

You hand this function an object like this.

[ 'date',
  { student: [ 'name', 'cert_number' ] },
  { instructor: [ 'name', 'cert_number', 'cert_expiration', { foo: ['a','b'] } ] },
  { aircraft: [ 'make', 'model' ] } ]

And it returns a template based on that object, assuming everything should be a key... like this.

{
  date: null,
  student: {
    name: null,
    cert_number: null
  },
  instructor: {
    name: null,
    cert_number: null,
    cert_expiration_date: null,
    foo: {
      a: null,
      b: null
    }
  },
  aircraft: {
    make: null,
    model: null
  }
}