getprototypeof
Advanced tools
Comparing version 1.0.0 to 2.0.0
32
index.js
@@ -1,13 +0,21 @@ | ||
/* eslint-env node, browser */ | ||
/* eslint no-proto: 0 */ | ||
module.exports = function (object) { | ||
"use strict"; | ||
var proto = object.__proto__; | ||
if (proto || proto === null) { | ||
return proto; | ||
} else if (object.constructor) { | ||
return object.constructor.prototype; | ||
} else { | ||
return Object.prototype; | ||
} | ||
'use strict'; | ||
var callBind = require('call-bind'); | ||
var define = require('define-properties'); | ||
var implementation = require('./implementation'); | ||
var getPolyfill = require('./polyfill'); | ||
var polyfill = callBind(getPolyfill(), Object); | ||
var shim = require('./shim'); | ||
var bound = function getPrototypeOf(value) { | ||
return polyfill(value); | ||
}; | ||
define(bound, { | ||
getPolyfill: getPolyfill, | ||
implementation: implementation, | ||
shim: shim | ||
}); | ||
module.exports = bound; |
131
package.json
{ | ||
"name": "getprototypeof", | ||
"version": "1.0.0", | ||
"description": "Object.getPrototypeOf sham function", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/mightyiam/getprototypeof.git" | ||
}, | ||
"keywords": [ | ||
"shim", | ||
"browser" | ||
], | ||
"author": "Shahar Or <mightyiampresence@gmail.com>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/mightyiam/getprototypeof/issues" | ||
}, | ||
"homepage": "https://github.com/mightyiam/getprototypeof" | ||
"name": "getprototypeof", | ||
"version": "2.0.0", | ||
"description": "An ES5 mostly-spec-compliant `Object.getPrototypeOf` sham/polyfill/replacement that works in as many engines as possible", | ||
"main": "index.js", | ||
"type": "commonjs", | ||
"exports": { | ||
".": [ | ||
{ | ||
"import": "./index.mjs", | ||
"default": "./index.js" | ||
}, | ||
"./index.js" | ||
], | ||
"./polyfill": [ | ||
{ | ||
"import": "./polyfill.mjs", | ||
"default": "./polyfill.js" | ||
}, | ||
"./polyfill.js" | ||
], | ||
"./implementation": [ | ||
{ | ||
"import": "./implementation.mjs", | ||
"default": "./implementation.js" | ||
}, | ||
"./implementation.js" | ||
], | ||
"./shim": [ | ||
{ | ||
"import": "./shim.mjs", | ||
"default": "./shim.js" | ||
}, | ||
"./shim.js" | ||
], | ||
"./auto": [ | ||
{ | ||
"import": "./auto.mjs", | ||
"default": "./auto.js" | ||
}, | ||
"./auto.js" | ||
], | ||
"./package.json": "./package.json" | ||
}, | ||
"scripts": { | ||
"prepublish": "safe-publish-latest", | ||
"prelint": "evalmd README.md", | ||
"lint": "eslint .", | ||
"postlint": "es-shim-api --bound", | ||
"pretest": "npm run lint", | ||
"tests-only": "nyc tape 'test/**/*.js'", | ||
"tests-esm": "nyc node test/index.mjs", | ||
"test": "npm run tests-only && npm run tests-esm", | ||
"posttest": "aud --production", | ||
"version": "auto-changelog && git add CHANGELOG.md", | ||
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/es-shims/Object.getPrototypeOf.git" | ||
}, | ||
"keywords": [ | ||
"Object.getPrototypeOf", | ||
"proto", | ||
"__proto__", | ||
"[[Prototype]]", | ||
"getPrototypeOf", | ||
"ES5", | ||
"shim", | ||
"polyfill", | ||
"es-shim API", | ||
"browser" | ||
], | ||
"author": "Jordan Harband <ljharb@gmail.com>", | ||
"funding": { | ||
"url": "https://github.com/sponsors/ljharb" | ||
}, | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/es-shims/Object.getPrototypeOf/issues" | ||
}, | ||
"homepage": "https://github.com/es-shims/Object.getPrototypeOf", | ||
"engines": { | ||
"node": ">= 0.4" | ||
}, | ||
"devDependencies": { | ||
"@es-shims/api": "^2.1.2", | ||
"@ljharb/eslint-config": "^17.3.0", | ||
"aud": "^1.1.3", | ||
"auto-changelog": "^2.2.1", | ||
"eslint": "^7.16.0", | ||
"evalmd": "^0.0.19", | ||
"nyc": "^10.3.2", | ||
"safe-publish-latest": "^1.1.4", | ||
"tape": "^5.0.1" | ||
}, | ||
"auto-changelog": { | ||
"output": "CHANGELOG.md", | ||
"template": "keepachangelog", | ||
"unreleased": false, | ||
"commitLimit": false, | ||
"backfillLimit": false, | ||
"hideCredit": true | ||
}, | ||
"dependencies": { | ||
"call-bind": "^1.0.0", | ||
"define-properties": "^1.1.3", | ||
"es-abstract": "^1.18.0-next.1", | ||
"get-intrinsic": "^1.0.2", | ||
"which-builtin-type": "^1.0.1" | ||
} | ||
} |
@@ -1,19 +0,70 @@ | ||
# getprototypeof | ||
# getprototypeof <sup>[![Version Badge][npm-version-svg]][package-url]</sup> | ||
As [the shim sham here](https://github.com/es-shims/es5-shim#shams), as a | ||
function. | ||
[![dependency status][deps-svg]][deps-url] | ||
[![dev dependency status][dev-deps-svg]][dev-deps-url] | ||
[![License][license-image]][license-url] | ||
[![Downloads][downloads-image]][downloads-url] | ||
## Install | ||
[![npm badge][npm-badge-png]][package-url] | ||
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](https://github.com/es-shims/api) interface. It works in an ES3-supported environment and complies with the [spec](https://www.ecma-international.org/ecma-262/5.1/). | ||
## Example | ||
```js | ||
var getPrototypeOf = require('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); | ||
``` | ||
npm i getprototypeof | ||
``` | ||
## Use | ||
```js | ||
var getPrototypeOf = require('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("getprototypeof"); | ||
proto = getPrototypeOf(someObject); | ||
```js | ||
var getPrototypeOf = require('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` | ||
[package-url]: https://npmjs.org/package/getprototypeof | ||
[npm-version-svg]: https://versionbadg.es/es-shims/Object.getPrototypeOf.svg | ||
[deps-svg]: https://david-dm.org/es-shims/Object.getPrototypeOf.svg | ||
[deps-url]: https://david-dm.org/es-shims/Object.getPrototypeOf | ||
[dev-deps-svg]: https://david-dm.org/es-shims/Object.getPrototypeOf/dev-status.svg | ||
[dev-deps-url]: https://david-dm.org/es-shims/Object.getPrototypeOf#info=devDependencies | ||
[npm-badge-png]: https://nodei.co/npm/getprototypeof.png?downloads=true&stars=true | ||
[license-image]: https://img.shields.io/npm/l/getprototypeof.svg | ||
[license-url]: LICENSE | ||
[downloads-image]: https://img.shields.io/npm/dm/getprototypeof.svg | ||
[downloads-url]: https://npm-stat.com/charts.html?package=getprototypeof |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
19020
22
198
0
71
5
9
2
+ Addedcall-bind@^1.0.0
+ Addeddefine-properties@^1.1.3
+ Addedes-abstract@^1.18.0-next.1
+ Addedget-intrinsic@^1.0.2
+ Addedwhich-builtin-type@^1.0.1
+ Addedarray-buffer-byte-length@1.0.2(transitive)
+ Addedarraybuffer.prototype.slice@1.0.4(transitive)
+ Addedasync-function@1.0.0(transitive)
+ Addedavailable-typed-arrays@1.0.7(transitive)
+ Addedcall-bind@1.0.8(transitive)
+ Addedcall-bind-apply-helpers@1.0.1(transitive)
+ Addedcall-bound@1.0.3(transitive)
+ Addeddata-view-buffer@1.0.2(transitive)
+ Addeddata-view-byte-length@1.0.2(transitive)
+ Addeddata-view-byte-offset@1.0.1(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddefine-properties@1.2.1(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addedes-abstract@1.23.9(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.1.1(transitive)
+ Addedes-set-tostringtag@2.1.0(transitive)
+ Addedes-to-primitive@1.3.0(transitive)
+ Addedfor-each@0.3.4(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedfunction.prototype.name@1.1.8(transitive)
+ Addedfunctions-have-names@1.2.3(transitive)
+ Addedget-intrinsic@1.2.7(transitive)
+ Addedget-proto@1.0.1(transitive)
+ Addedget-symbol-description@1.1.0(transitive)
+ Addedglobalthis@1.0.4(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-bigints@1.1.0(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.2.0(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedinternal-slot@1.1.0(transitive)
+ Addedis-array-buffer@3.0.5(transitive)
+ Addedis-async-function@2.1.1(transitive)
+ Addedis-bigint@1.1.0(transitive)
+ Addedis-boolean-object@1.2.1(transitive)
+ Addedis-callable@1.2.7(transitive)
+ Addedis-data-view@1.0.2(transitive)
+ Addedis-date-object@1.1.0(transitive)
+ Addedis-finalizationregistry@1.1.1(transitive)
+ Addedis-generator-function@1.1.0(transitive)
+ Addedis-map@2.0.3(transitive)
+ Addedis-number-object@1.1.1(transitive)
+ Addedis-regex@1.2.1(transitive)
+ Addedis-set@2.0.3(transitive)
+ Addedis-shared-array-buffer@1.0.4(transitive)
+ Addedis-string@1.1.1(transitive)
+ Addedis-symbol@1.1.1(transitive)
+ Addedis-typed-array@1.1.15(transitive)
+ Addedis-weakmap@2.0.2(transitive)
+ Addedis-weakref@1.1.0(transitive)
+ Addedis-weakset@2.0.4(transitive)
+ Addedisarray@2.0.5(transitive)
+ Addedmath-intrinsics@1.1.0(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedobject.assign@4.1.7(transitive)
+ Addedown-keys@1.0.1(transitive)
+ Addedpossible-typed-array-names@1.0.0(transitive)
+ Addedreflect.getprototypeof@1.0.10(transitive)
+ Addedregexp.prototype.flags@1.5.4(transitive)
+ Addedsafe-array-concat@1.1.3(transitive)
+ Addedsafe-push-apply@1.0.0(transitive)
+ Addedsafe-regex-test@1.1.0(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedset-function-name@2.0.2(transitive)
+ Addedset-proto@1.0.0(transitive)
+ Addedside-channel@1.1.0(transitive)
+ Addedside-channel-list@1.0.0(transitive)
+ Addedside-channel-map@1.0.1(transitive)
+ Addedside-channel-weakmap@1.0.2(transitive)
+ Addedstring.prototype.trim@1.2.10(transitive)
+ Addedstring.prototype.trimend@1.0.9(transitive)
+ Addedstring.prototype.trimstart@1.0.8(transitive)
+ Addedtyped-array-buffer@1.0.3(transitive)
+ Addedtyped-array-byte-length@1.0.3(transitive)
+ Addedtyped-array-byte-offset@1.0.4(transitive)
+ Addedtyped-array-length@1.0.7(transitive)
+ Addedunbox-primitive@1.1.0(transitive)
+ Addedwhich-boxed-primitive@1.1.1(transitive)
+ Addedwhich-builtin-type@1.2.1(transitive)
+ Addedwhich-collection@1.0.2(transitive)
+ Addedwhich-typed-array@1.1.18(transitive)