Skip to content

ryanburnette/array-to-object-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Convert an array to an object template.

Resources

License

Stars

Watchers

Forks

Packages

No packages published