用工小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
2.3 KiB

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