bd67f2a665019ab0f9f293333e72c5d54fcc69c67a5029f5f31e10e2de93775718180abd07ea13cd2ff6d15c83b31d398c48a452d8adccb042a351c6f771aa 1.7 KB

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