list-to-object
v1.0.0
Published
Converts lists into objects
Downloads
2
Readme
list-to-object
Converts lists into objects
Install
$ npm install --save list-to-object
Example
var toObj = require('list-to-object');
console.log(toObj([['America', 'Washington'], ['India', 'Mumbai'], ['Canada', 'Ottawa']]));
// -> { America: 'Washington', India: 'Mumbai', Canada: 'Ottawa' }
console.log(toObj(['America', 'India', 'Canada'], ['Washington', 'Mumbai', 'Ottawa']));
// -> { America: 'Washington', India: 'Mumbai', Canada: 'Ottawa' }
require('list-to-object')(list, [values])
Arguments:
If you pass only one argument i.e list then,
list
: list be the single array of[key, value]
pairs
If you pass two arguments i.e two parallel arrays of the same length one of keys, and other of the corresponding values.
list
: list of keysvalues
: list of values
Returns: Returns the object of key value pairs
License
© 2016 Vikram Jadhav. MIT License