๐Ÿ“ฆ ljharb / get-proto

Robustly get the [[Prototype]] of an object. Uses the best available method.

โ˜… 3 stars โ‘‚ 2 forks ๐Ÿ‘ 3 watching โš–๏ธ MIT License
๐Ÿ“ฅ Clone https://github.com/ljharb/get-proto.git
HTTPS git clone https://github.com/ljharb/get-proto.git
SSH git clone git@github.com:ljharb/get-proto.git
CLI gh repo clone ljharb/get-proto
Jordan Harband Jordan Harband [readme] replace runkit CI badge with shields.io check-runs badge 07a391d 7 days ago ๐Ÿ“ History
๐Ÿ“‚ main View all commits โ†’
๐Ÿ“ .github
๐Ÿ“ test
๐Ÿ“„ .eslintrc
๐Ÿ“„ .gitignore
๐Ÿ“„ .npmrc
๐Ÿ“„ .nycrc
๐Ÿ“„ CHANGELOG.md
๐Ÿ“„ index.d.ts
๐Ÿ“„ index.js
๐Ÿ“„ LICENSE
๐Ÿ“„ package.json
๐Ÿ“„ README.md
๐Ÿ“„ tsconfig.json
๐Ÿ“„ README.md

get-proto Version Badge

github actions coverage License Downloads

npm badge

Robustly get the [[Prototype]] of an object. Uses the best available method.

Getting started

npm install --save get-proto

Usage/Examples

const assert = require('assert');
const getProto = require('get-proto');

const a = { a: 1, b: 2, [Symbol.toStringTag]: 'foo' };
const b = { c: 3, __proto__: a };

assert.equal(getProto(b), a);
assert.equal(getProto(a), Object.prototype);
assert.equal(getProto({ __proto__: null }), null);

Tests

Clone the repo, npm install, and run npm test