object-from-pairs
v0.0.2
Published
Create an object from an array of pairs
Downloads
2
Maintainers
Readme
object from pairs
Create an object from an array of pairs
Can be used as a partial ponyfill or prollyfil for tc39 / proposal-object-from-entries
Author: @brodybits (Christopher J. Brody)
License: CC0 OR UNLICENSE OR ISC OR Apache-2.0 OR CC-BY-SA-3.0 OR CC-BY-SA-4.0
Sample
const objectFromPairs = require('object-from-pairs')
console.log(objectFromPairs([
[ 'first' + 'Key', 'first value' ],
[ 'second' + '-' + 'key', 'second value' ],
]))
outputs the following:
{ firstKey: 'first value', 'second-key': 'second value' }
(see quick-demo.js)
TODO
- deeper testing
- proper API documentation
- use eslint-config-standard@12 when available (https://github.com/standard/eslint-config-standard/issues/123)
- follow standard more closely in quick-demo.js and sample
- pre-es6 support
- test on browser
- test on AppVeyor & Travis CI
- SauceLabs?
- commit
package-lock.json
(??)
FUTURE TBD
- merge with the now deprecated https://npm.im/object-from-entries package?
See also
- https://npm.im/object-from-entries (deprecated ponyfill)
- https://npm.im/object.fromentries (polyfill for ES Object.fromEntries proposal)
- https://humanwhocodes.com/blog/2010/03/02/maintainable-javascript-dont-modify-objects-you-down-own/ - nice justification for ponyfill over polyfills
- https://lodash.com/docs/4.17.10#fromPairs
- https://github.com/lodash/lodash/issues/2718
- https://github.com/lodash/lodash/issues/1261
- https://stackoverflow.com/questions/20059995/how-to-create-an-object-from-an-array-of-key-value-pairs
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries
- https://hackernoon.com/es8-was-released-and-here-are-its-main-new-features-ee9c394adf66