Last change
on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
850 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | # Polyfill for `Object.setPrototypeOf`
|
---|
| 2 |
|
---|
| 3 | [![NPM Version](https://img.shields.io/npm/v/setprototypeof.svg)](https://npmjs.org/package/setprototypeof)
|
---|
| 4 | [![NPM Downloads](https://img.shields.io/npm/dm/setprototypeof.svg)](https://npmjs.org/package/setprototypeof)
|
---|
| 5 | [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/standard/standard)
|
---|
| 6 |
|
---|
| 7 | A simple cross platform implementation to set the prototype of an instianted object. Supports all modern browsers and at least back to IE8.
|
---|
| 8 |
|
---|
| 9 | ## Usage:
|
---|
| 10 |
|
---|
| 11 | ```
|
---|
| 12 | $ npm install --save setprototypeof
|
---|
| 13 | ```
|
---|
| 14 |
|
---|
| 15 | ```javascript
|
---|
| 16 | var setPrototypeOf = require('setprototypeof')
|
---|
| 17 |
|
---|
| 18 | var obj = {}
|
---|
| 19 | setPrototypeOf(obj, {
|
---|
| 20 | foo: function () {
|
---|
| 21 | return 'bar'
|
---|
| 22 | }
|
---|
| 23 | })
|
---|
| 24 | obj.foo() // bar
|
---|
| 25 | ```
|
---|
| 26 |
|
---|
| 27 | TypeScript is also supported:
|
---|
| 28 |
|
---|
| 29 | ```typescript
|
---|
| 30 | import setPrototypeOf = require('setprototypeof')
|
---|
| 31 | ```
|
---|
Note:
See
TracBrowser
for help on using the repository browser.