[d565449] | 1 | # object.fromentries <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
---|
| 2 |
|
---|
| 3 | [![github actions][actions-image]][actions-url]
|
---|
| 4 | [![coverage][codecov-image]][codecov-url]
|
---|
| 5 | [![dependency status][deps-svg]][deps-url]
|
---|
| 6 | [![dev dependency status][dev-deps-svg]][dev-deps-url]
|
---|
| 7 | [![License][license-image]][license-url]
|
---|
| 8 | [![Downloads][downloads-image]][downloads-url]
|
---|
| 9 |
|
---|
| 10 | [![npm badge][npm-badge-png]][package-url]
|
---|
| 11 |
|
---|
| 12 | An ES spec-proposal-compliant `Object.fromEntries` shim. Invoke its "shim" method to shim `Object.fromEntries` if it is unavailable or noncompliant.
|
---|
| 13 |
|
---|
| 14 | This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES3-supported environment and complies with the [proposed spec](https://tc39.github.io/proposal-object-from-entries/).
|
---|
| 15 |
|
---|
| 16 | Most common usage:
|
---|
| 17 | ```js
|
---|
| 18 | var assert = require('assert');
|
---|
| 19 | var fromEntries = require('object.fromentries');
|
---|
| 20 |
|
---|
| 21 | var obj = { a: 1, b: 2, c: 3 };
|
---|
| 22 | var actual = fromEntries(Object.entries(obj));
|
---|
| 23 |
|
---|
| 24 | assert.deepEqual(obj, actual);
|
---|
| 25 |
|
---|
| 26 | if (!Object.fromEntries) {
|
---|
| 27 | fromEntries.shim();
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | assert.deepEqual(Object.fromEntries(Object.entries(obj)), obj);
|
---|
| 31 | ```
|
---|
| 32 |
|
---|
| 33 | ## Tests
|
---|
| 34 | Simply clone the repo, `npm install`, and run `npm test`
|
---|
| 35 |
|
---|
| 36 | [package-url]: https://npmjs.com/package/object.fromentries
|
---|
| 37 | [npm-version-svg]: https://versionbadg.es/es-shims/Object.fromEntries.svg
|
---|
| 38 | [deps-svg]: https://david-dm.org/es-shims/Object.fromEntries.svg
|
---|
| 39 | [deps-url]: https://david-dm.org/es-shims/Object.fromEntries
|
---|
| 40 | [dev-deps-svg]: https://david-dm.org/es-shims/Object.fromEntries/dev-status.svg
|
---|
| 41 | [dev-deps-url]: https://david-dm.org/es-shims/Object.fromEntries#info=devDependencies
|
---|
| 42 | [npm-badge-png]: https://nodei.co/npm/object.fromentries.png?downloads=true&stars=true
|
---|
| 43 | [license-image]: https://img.shields.io/npm/l/object.fromentries.svg
|
---|
| 44 | [license-url]: LICENSE
|
---|
| 45 | [downloads-image]: https://img.shields.io/npm/dm/object.fromentries.svg
|
---|
| 46 | [downloads-url]: https://npm-stat.com/charts.html?package=object.fromentries
|
---|
| 47 | [codecov-image]: https://codecov.io/gh/es-shims/Object.fromEntries/branch/main/graphs/badge.svg
|
---|
| 48 | [codecov-url]: https://app.codecov.io/gh/es-shims/Object.fromEntries/
|
---|
| 49 | [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/Object.fromEntries
|
---|
| 50 | [actions-url]: https://github.com/es-shims/Object.fromEntries/actions
|
---|