reflect.getprototypeof (1.0.10)

Published 2026-02-24 14:04:10 +00:00 by atheaadmin

Installation

registry=
npm install reflect.getprototypeof@1.0.10
"reflect.getprototypeof": "1.0.10"

About this package

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

Dependencies

Dependencies

ID Version
call-bind ^1.0.8
define-properties ^1.2.1
es-abstract ^1.23.9
es-errors ^1.3.0
es-object-atoms ^1.0.0
get-intrinsic ^1.2.7
get-proto ^1.0.1
which-builtin-type ^1.2.1

Development Dependencies

ID Version
@es-shims/api ^2.5.1
@ljharb/eslint-config ^21.1.1
auto-changelog ^2.5.0
encoding ^0.1.13
eslint =8.8.0
evalmd ^0.0.19
functions-have-names ^1.2.3
in-publish ^2.0.1
npmignore ^0.3.1
nyc ^10.3.2
safe-publish-latest ^2.0.0
tape ^5.9.0

Keywords

Reflect.getPrototypeOf Object.getPrototypeOf proto __proto__ [[Prototype]] getPrototypeOf ES5 shim polyfill es-shim API browser
Details
npm
2026-02-24 14:04:10 +00:00
0
Jordan Harband
MIT
latest
7.4 KiB
Assets (1)
Versions (1) View all
1.0.10 2026-02-24