0.1.2 • Published 8 years ago
build-object v0.1.2
Build Object
Create an object from an iterable of key/value-pairs.
Installation
npm install --save build-objectUsage
const buildObject = require('build-object')
const me = buildObject([
['firstName', 'Linus'],
['lastName', 'Unnebäck']
])
console.log(me)
// => { firstName: 'Linus', lastName: 'Unnebäck' }API
buildObject(items) => object
Build an object from items.
items should be an iterable (e.g. an array) where each item is a key/value pair.
If the same key is specified twice, the latter will take precedence.
A TypeError will be thrown in the following conditions:
itemsis not an iterable- any element in
itemsis not an object - any key is not a string