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