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.

59 lines
2.2 KiB

4 years ago
  1. # object.values <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
  2. [![Build Status][travis-svg]][travis-url]
  3. [![dependency status][deps-svg]][deps-url]
  4. [![dev dependency status][dev-deps-svg]][dev-deps-url]
  5. [![License][license-image]][license-url]
  6. [![Downloads][downloads-image]][downloads-url]
  7. [![npm badge][npm-badge-png]][package-url]
  8. [![browser support][testling-svg]][testling-url]
  9. An ES2017 spec-compliant `Object.values` shim. Invoke its "shim" method to shim `Object.values` 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.values).
  11. Most common usage:
  12. ```js
  13. var assert = require('assert');
  14. var values = require('object.values');
  15. var obj = { a: 1, b: 2, c: 3 };
  16. var expected = [1, 2, 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(sym);
  23. }
  24. assert.deepEqual(values(obj), expected);
  25. if (!Object.values) {
  26. values.shim();
  27. }
  28. assert.deepEqual(Object.values(obj), expected);
  29. ```
  30. ## Tests
  31. Simply clone the repo, `npm install`, and run `npm test`
  32. [package-url]: https://npmjs.com/package/object.values
  33. [npm-version-svg]: http://versionbadg.es/es-shims/Object.values.svg
  34. [travis-svg]: https://travis-ci.org/es-shims/Object.values.svg
  35. [travis-url]: https://travis-ci.org/es-shims/Object.values
  36. [deps-svg]: https://david-dm.org/es-shims/Object.values.svg
  37. [deps-url]: https://david-dm.org/es-shims/Object.values
  38. [dev-deps-svg]: https://david-dm.org/es-shims/Object.values/dev-status.svg
  39. [dev-deps-url]: https://david-dm.org/es-shims/Object.values#info=devDependencies
  40. [testling-svg]: https://ci.testling.com/es-shims/Object.values.png
  41. [testling-url]: https://ci.testling.com/es-shims/Object.values
  42. [npm-badge-png]: https://nodei.co/npm/object.values.png?downloads=true&stars=true
  43. [license-image]: http://img.shields.io/npm/l/object.values.svg
  44. [license-url]: LICENSE
  45. [downloads-image]: http://img.shields.io/npm/dm/object.values.svg
  46. [downloads-url]: http://npm-stat.com/charts.html?package=object.values