Neverending Package Mountain

    spo-gpo

    1.0.0 • Public • Published

    Polyfill for Object.setPrototypeOf and Object.getPrototypeOf

    Usage

    $ npm install spo-gpo
    

    As a ponyfill:

    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:

    require('spo-gpo/polyfill');
     
    const proto = {
      foo: function() {
        return 'bar';
      }
    };
     
    const obj = Object.setPrototypeOf({}, proto);
     
    obj.foo(); // 'bar'
    Object.getPrototypeOf(obj); // proto

    Related projects

    Install

    npm i spo-gpo

    DownloadsWeekly Downloads

    1,033

    Version

    1.0.0

    License

    ISC

    Unpacked Size

    4.01 kB

    Total Files

    6

    Last publish

    Collaborators

    • dgeibi