1 | # object.entries <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 ES2017 spec-compliant `Object.entries` shim. Invoke its "shim" method to shim `Object.entries` 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 [spec](https://tc39.github.io/ecma262/#sec-object.entries).
|
---|
15 |
|
---|
16 | Most common usage:
|
---|
17 | ```js
|
---|
18 | var assert = require('assert');
|
---|
19 | var entries = require('object.entries');
|
---|
20 |
|
---|
21 | var obj = { a: 1, b: 2, c: 3 };
|
---|
22 | var expected = [['a', 1], ['b', 2], ['c', 3]];
|
---|
23 |
|
---|
24 | if (typeof Symbol === 'function' && typeof Symbol() === 'symbol') {
|
---|
25 | // for environments with Symbol support
|
---|
26 | var sym = Symbol();
|
---|
27 | obj[sym] = 4;
|
---|
28 | obj.d = sym;
|
---|
29 | expected.push(['d', sym]);
|
---|
30 | }
|
---|
31 |
|
---|
32 | assert.deepEqual(entries(obj), expected);
|
---|
33 |
|
---|
34 | if (!Object.entries) {
|
---|
35 | entries.shim();
|
---|
36 | }
|
---|
37 |
|
---|
38 | assert.deepEqual(Object.entries(obj), expected);
|
---|
39 | ```
|
---|
40 |
|
---|
41 | ## Tests
|
---|
42 | Simply clone the repo, `npm install`, and run `npm test`
|
---|
43 |
|
---|
44 | [package-url]: https://npmjs.com/package/object.entries
|
---|
45 | [npm-version-svg]: https://versionbadg.es/es-shims/Object.entries.svg
|
---|
46 | [deps-svg]: https://david-dm.org/es-shims/Object.entries.svg
|
---|
47 | [deps-url]: https://david-dm.org/es-shims/Object.entries
|
---|
48 | [dev-deps-svg]: https://david-dm.org/es-shims/Object.entries/dev-status.svg
|
---|
49 | [dev-deps-url]: https://david-dm.org/es-shims/Object.entries#info=devDependencies
|
---|
50 | [npm-badge-png]: https://nodei.co/npm/object.entries.png?downloads=true&stars=true
|
---|
51 | [license-image]: https://img.shields.io/npm/l/object.entries.svg
|
---|
52 | [license-url]: LICENSE
|
---|
53 | [downloads-image]: https://img.shields.io/npm/dm/object.entries.svg
|
---|
54 | [downloads-url]: https://npm-stat.com/charts.html?package=object.entries
|
---|
55 | [codecov-image]: https://codecov.io/gh/es-shims/Object.entries/branch/main/graphs/badge.svg
|
---|
56 | [codecov-url]: https://app.codecov.io/gh/es-shims/Object.entries/
|
---|
57 | [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/Object.entries
|
---|
58 | [actions-url]: https://github.com/es-shims/Object.entries/actions
|
---|