Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

object.getprototypeof

es-shims490kMIT1.0.7

An ES5 mostly-spec-compliant Object.getPrototypeOf sham/polyfill/replacement that works in as many engines as possible

Object.getPrototypeOf, proto, __proto__, [[Prototype]], getPrototypeOf, ES5, shim, polyfill, es-shim API, browser

readme

object.getprototypeof Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

An ES5 mostly-spec-compliant Object.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('object.getprototypeof');
var assert = require('assert');

assert.equal(getPrototypeOf(true), Boolean.prototype);
assert.equal(getPrototypeOf(42), Number.prototype);
assert.equal(getPrototypeOf(''), String.prototype);
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('object.getprototypeof');
var assert = require('assert');
/* when Object.getPrototypeOf is not present */
delete Object.getPrototypeOf;
var shimmed = getPrototypeOf.shim();
assert.equal(shimmed, getPrototypeOf.getPolyfill());

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

Tests

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

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

v1.0.7 - 2025-01-02

Commits

  • [actions] split out node 10-20, and 20+ 66e0766
  • [Tests] remove unused ESM tests 038e9c6
  • [Refactor] use get-proto directly 675ecee
  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config, auto-changelog, tape d606eaa
  • [Deps] update call-bind, reflect.getprototypeof 004d807
  • [Tests] replace aud with npm audit 67b494b
  • [Dev Deps] add missing dev dep 1993c8d
  • [Dev Deps] add missing peer dep bfe72fa

v1.0.6 - 2024-03-16

Commits

  • [meta] remove useless ESM 3d76802
  • [Refactor] replace es-abstract with es-object-atoms; update call-bind, define-properties, reflect.getprototypeof 7824d81
  • [Dev Deps] update aud, npmignore, tape d87f382

v1.0.5 - 2023-09-07

Commits

  • [Deps] update define-properties, es-abstract, reflect.getprototype.of fbb89b9
  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config, aud, tape 806bcbe

v1.0.4 - 2022-11-06

Commits

  • [actions] reuse common workflows e95bf1e
  • [meta] use npmignore to autogenerate an npmignore file 55214a5
  • [Dev Deps] update eslint, @ljharb/eslint-config, @es-shims/api, safe-publish-latest, tape 3c93053
  • [actions] update codecov uploader 0a985b5
  • [actions] update rebase action to use reusable workflow c527083
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, tape 9b46f2c
  • [Deps] update define-properties, es-abstract e2d43b8

v1.0.3 - 2021-10-03

Commits

  • [Deps] update es-abstract, reflect.getprototypeof cb12850
  • [actions] update workflows f73781d
  • [Dev Deps] update @es-shims/api d8a3cb1

v1.0.2 - 2021-09-08

Commits

  • [Refactor] remove unnecessary ESM files 1344709
  • [actions] use node/install instead of node/run; use codecov action 6cf0ea2
  • [meta] npx auto-changelog db72bad
  • [Dev Deps] update eslint, @ljharb/eslint-config, @es-shims/api, tape a57eae1
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, tape cfbb551
  • [readme] add actions and codecov badges a8664a2
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog 72efb2b
  • [actions] update workflows cdb2fe6
  • [Dev Deps] update aud, eslint 9c702ef
  • [meta] use prepublishOnly script for npm 7+ 4fe0f9a
  • [Deps] update es-abstract 8b5a4e8
  • [Deps] update es-abstract 49ac651
  • [Deps] update es-abstract 6025f20

v1.0.1 - 2021-01-12

Commits

  • [Refactor] implementation: use reflect.getprototypeof 087718f
  • [Dev Deps] update eslint, tape b37e609
  • [Deps] update call-bind 3f64439

v1.0.0 - 2021-01-12

Commits

  • [Tests] migrate tests to Github Actions 93b30a1
  • Implementation e9a6930
  • [meta] do not publish github action workflow files d0bb143
  • Tests e0d72e0
  • [meta] update .gitignore 422f05c
  • [meta] rename package from getprototypeof to object.getprototypeof 201d939
  • readme f48eac0
  • [meta] update package.json 020d703
  • <3 4751ac2
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, tape 240d6e9
  • [meta] add auto-changelog de87a4d
  • Initial commit 3297015
  • Update README.md 52d680b
  • [Tests] run nyc on all tests 4e21d00
  • [Refactor] use call-bind, get-intrinsic instead of es-abstract where appropriate; update es-abstract e1e0d7e
  • [Fix] polyfill: handle engines where Object.getPrototypeOf throws on object-coercible primitives 99ef2c2
  • [actions] add automatic rebasing / merge commit blocking fe9c32f
  • [Fix] add missing auto "exports" entrypoint 1fa0738
  • [actions] add "Allow Edits" workflow 1f2f637
  • [Tests] add npm run lint 46e838f
  • [Tests] use shared travis-ci configs c02a549
  • [readme] remove travis badge bd834c2
  • [meta] update license 6a86d4d
  • Only apps should have lockfiles 705b426
  • [actions] switch Automatic Rebase workflow to pull_request_target event 5debc6b
  • [meta] add funding field 77bb1ce
  • [Tests] run es-shim-api postlint c3173fd
  • [Deps] update which-builtin-type 21a840b
  • [meta] add safe-publish-latest 4691320
  • Update README.md f2a5d3d