Tim van der Lippe | fdbd42e | 2020-04-07 14:14:36 | [diff] [blame] | 1 | # object.values <sup>[![Version Badge][npm-version-svg]][package-url]</sup> |
| 2 | |
Tim van der Lippe | 2c89197 | 2021-07-29 15:22:50 | [diff] [blame] | 3 | [![github actions][actions-image]][actions-url] |
| 4 | [![coverage][codecov-image]][codecov-url] |
Tim van der Lippe | fdbd42e | 2020-04-07 14:14:36 | [diff] [blame] | 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 | |
Tim van der Lippe | fdbd42e | 2020-04-07 14:14:36 | [diff] [blame] | 12 | An ES2017 spec-compliant `Object.values` shim. Invoke its "shim" method to shim `Object.values` 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.values). |
| 15 | |
| 16 | Most common usage: |
| 17 | ```js |
| 18 | var assert = require('assert'); |
| 19 | var values = require('object.values'); |
| 20 | |
| 21 | var obj = { a: 1, b: 2, c: 3 }; |
| 22 | var expected = [1, 2, 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(sym); |
| 30 | } |
| 31 | |
| 32 | assert.deepEqual(values(obj), expected); |
| 33 | |
| 34 | if (!Object.values) { |
| 35 | values.shim(); |
| 36 | } |
| 37 | |
| 38 | assert.deepEqual(Object.values(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.values |
Tim van der Lippe | 2c89197 | 2021-07-29 15:22:50 | [diff] [blame] | 45 | [npm-version-svg]: https://versionbadg.es/es-shims/Object.values.svg |
Tim van der Lippe | fdbd42e | 2020-04-07 14:14:36 | [diff] [blame] | 46 | [deps-svg]: https://david-dm.org/es-shims/Object.values.svg |
| 47 | [deps-url]: https://david-dm.org/es-shims/Object.values |
| 48 | [dev-deps-svg]: https://david-dm.org/es-shims/Object.values/dev-status.svg |
| 49 | [dev-deps-url]: https://david-dm.org/es-shims/Object.values#info=devDependencies |
Tim van der Lippe | fdbd42e | 2020-04-07 14:14:36 | [diff] [blame] | 50 | [npm-badge-png]: https://nodei.co/npm/object.values.png?downloads=true&stars=true |
Tim van der Lippe | 2c89197 | 2021-07-29 15:22:50 | [diff] [blame] | 51 | [license-image]: https://img.shields.io/npm/l/object.values.svg |
Tim van der Lippe | fdbd42e | 2020-04-07 14:14:36 | [diff] [blame] | 52 | [license-url]: LICENSE |
Tim van der Lippe | 2c89197 | 2021-07-29 15:22:50 | [diff] [blame] | 53 | [downloads-image]: https://img.shields.io/npm/dm/object.values.svg |
| 54 | [downloads-url]: https://npm-stat.com/charts.html?package=object.values |
| 55 | [codecov-image]: https://codecov.io/gh/es-shims/Object.values/branch/main/graphs/badge.svg |
| 56 | [codecov-url]: https://app.codecov.io/gh/es-shims/Object.values/ |
| 57 | [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/Object.values |
| 58 | [actions-url]: https://github.com/es-shims/Object.values/actions |