README.md
1 # get-proto <sup>[![Version Badge][npm-version-svg]][package-url]</sup> 2 3 [![github actions][actions-image]][actions-url] 4 [![coverage][codecov-image]][codecov-url] 5 [![License][license-image]][license-url] 6 [![Downloads][downloads-image]][downloads-url] 7 8 [![npm badge][npm-badge-png]][package-url] 9 10 Robustly get the [[Prototype]] of an object. Uses the best available method. 11 12 ## Getting started 13 14 ```sh 15 npm install --save get-proto 16 ``` 17 18 ## Usage/Examples 19 20 ```js 21 const assert = require('assert'); 22 const getProto = require('get-proto'); 23 24 const a = { a: 1, b: 2, [Symbol.toStringTag]: 'foo' }; 25 const b = { c: 3, __proto__: a }; 26 27 assert.equal(getProto(b), a); 28 assert.equal(getProto(a), Object.prototype); 29 assert.equal(getProto({ __proto__: null }), null); 30 ``` 31 32 ## Tests 33 34 Clone the repo, `npm install`, and run `npm test` 35 36 [package-url]: https://npmjs.org/package/get-proto 37 [npm-version-svg]: https://versionbadg.es/ljharb/get-proto.svg 38 [deps-svg]: https://david-dm.org/ljharb/get-proto.svg 39 [deps-url]: https://david-dm.org/ljharb/get-proto 40 [dev-deps-svg]: https://david-dm.org/ljharb/get-proto/dev-status.svg 41 [dev-deps-url]: https://david-dm.org/ljharb/get-proto#info=devDependencies 42 [npm-badge-png]: https://nodei.co/npm/get-proto.png?downloads=true&stars=true 43 [license-image]: https://img.shields.io/npm/l/get-proto.svg 44 [license-url]: LICENSE 45 [downloads-image]: https://img.shields.io/npm/dm/get-proto.svg 46 [downloads-url]: https://npm-stat.com/charts.html?package=get-proto 47 [codecov-image]: https://codecov.io/gh/ljharb/get-proto/branch/main/graphs/badge.svg 48 [codecov-url]: https://app.codecov.io/gh/ljharb/get-proto/ 49 [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/get-proto 50 [actions-url]: https://github.com/ljharb/get-proto/actions