mirror-rhinstaller-node-cache/reflect.getprototypeof
2026-06-15 08:05:17 +00:00
..
test 59aa210f76a766832e4013c3105697047c38ba1ef2a752c58a10e46a4664c272 package.json 2026-06-15 08:05:17 +00:00
.eslintrc 59aa210f76a766832e4013c3105697047c38ba1ef2a752c58a10e46a4664c272 package.json 2026-06-15 08:05:17 +00:00
.nycrc 59aa210f76a766832e4013c3105697047c38ba1ef2a752c58a10e46a4664c272 package.json 2026-06-15 08:05:17 +00:00
auto.js 59aa210f76a766832e4013c3105697047c38ba1ef2a752c58a10e46a4664c272 package.json 2026-06-15 08:05:17 +00:00
CHANGELOG.md 59aa210f76a766832e4013c3105697047c38ba1ef2a752c58a10e46a4664c272 package.json 2026-06-15 08:05:17 +00:00
implementation.js 59aa210f76a766832e4013c3105697047c38ba1ef2a752c58a10e46a4664c272 package.json 2026-06-15 08:05:17 +00:00
index.js 59aa210f76a766832e4013c3105697047c38ba1ef2a752c58a10e46a4664c272 package.json 2026-06-15 08:05:17 +00:00
LICENSE 59aa210f76a766832e4013c3105697047c38ba1ef2a752c58a10e46a4664c272 package.json 2026-06-15 08:05:17 +00:00
package.json 59aa210f76a766832e4013c3105697047c38ba1ef2a752c58a10e46a4664c272 package.json 2026-06-15 08:05:17 +00:00
polyfill.js 59aa210f76a766832e4013c3105697047c38ba1ef2a752c58a10e46a4664c272 package.json 2026-06-15 08:05:17 +00:00
README.md 59aa210f76a766832e4013c3105697047c38ba1ef2a752c58a10e46a4664c272 package.json 2026-06-15 08:05:17 +00:00
shim.js 59aa210f76a766832e4013c3105697047c38ba1ef2a752c58a10e46a4664c272 package.json 2026-06-15 08:05:17 +00:00

reflect.getprototypeof Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

An ES2015 mostly-spec-compliant Reflect.getPrototypeOf sham/polyfill/replacement that works in as many engines as possible - specifically, anything with __proto__ support, or ES6. Built-in types will also work correctly in older engines.

This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the spec.

Example

var getPrototypeOf = require('reflect.getprototypeof');
var assert = require('assert');

assert.throws(() => getPrototypeOf(true));
assert.throws(() => getPrototypeOf(42));
assert.throws(() => getPrototypeOf(''));
assert.equal(getPrototypeOf(/a/g), RegExp.prototype);
assert.equal(getPrototypeOf(new Date()), Date.prototype);
assert.equal(getPrototypeOf(function () {}), Function.prototype);
assert.equal(getPrototypeOf([]), Array.prototype);
assert.equal(getPrototypeOf({}), Object.prototype);
var getPrototypeOf = require('reflect.getprototypeof');
var assert = require('assert');
/* when Reflect or Reflect.getPrototypeOf is not present */
if (typeof Reflect === 'object') { delete Reflect.getPrototypeOf; }
delete globalThis.Reflect;
var shimmed = getPrototypeOf.shim();
assert.equal(shimmed, getPrototypeOf.getPolyfill());

assert.throws(() => Reflect.getPrototypeOf(true));
assert.throws(() => Reflect.getPrototypeOf(42));
assert.throws(() => Reflect.getPrototypeOf(''));
assert.equal(Reflect.getPrototypeOf(/a/g), RegExp.prototype);
assert.equal(Reflect.getPrototypeOf(new Date()), Date.prototype);
assert.equal(Reflect.getPrototypeOf(function () {}), Function.prototype);
assert.equal(Reflect.getPrototypeOf([]), Array.prototype);
assert.equal(Reflect.getPrototypeOf({}), Object.prototype);
var getPrototypeOf = require('reflect.getprototypeof');
var assert = require('assert');
/* when Reflect.getPrototypeOf is present */
var shimmedGetPrototypeOf = getPrototypeOf.shim();
assert.equal(shimmedGetPrototypeOf, Reflect.getPrototypeOf);
assert.equal(Reflect.getPrototypeOf([]), Array.prototype);

Tests

Simply clone the repo, npm install, and run npm test