Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dgeibi/spo-gpo
https://github.com/dgeibi/spo-gpo
Last synced: 1 day ago
JSON representation
- Host: GitHub
- URL: https://github.com/dgeibi/spo-gpo
- Owner: dgeibi
- License: isc
- Created: 2018-05-27T04:06:03.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-05-27T04:12:53.000Z (over 6 years ago)
- Last Synced: 2024-12-09T17:58:11.542Z (18 days ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Polyfill for `Object.setPrototypeOf` and `Object.getPrototypeOf`
## Usage
```
$ npm install spo-gpo
```As a ponyfill:
```js
const assert = require('assert');
const { setPrototypeOf, getPrototypeOf } = require('spo-gpo');const obj = {};
const proto = {
foo: function() {
return 'bar';
}
};assert(getPrototypeOf(obj) === Object.prototype);
setPrototypeOf(obj, proto);
assert(obj.foo() === 'bar');
assert(getPrototypeOf(obj) === proto);
```Globally, as a polyfill:
```js
require('spo-gpo/polyfill');const proto = {
foo: function() {
return 'bar';
}
};const obj = Object.setPrototypeOf({}, proto);
obj.foo(); // 'bar'
Object.getPrototypeOf(obj); // proto
```## Related projects
* [wesleytodd/setprototypeof](https://github.com/wesleytodd/setprototypeof)
* [paulmillr/es6-shim](https://github.com/paulmillr/es6-shim)
* [zloirock/core-js](https://github.com/zloirock/core-js)