aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/get-proto
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--node_modules/get-proto/.eslintrc10
-rw-r--r--node_modules/get-proto/.github/FUNDING.yml12
-rw-r--r--node_modules/get-proto/.nycrc9
-rw-r--r--node_modules/get-proto/CHANGELOG.md21
-rw-r--r--node_modules/get-proto/LICENSE21
-rw-r--r--node_modules/get-proto/Object.getPrototypeOf.d.ts5
-rw-r--r--node_modules/get-proto/Object.getPrototypeOf.js6
-rw-r--r--node_modules/get-proto/README.md50
-rw-r--r--node_modules/get-proto/Reflect.getPrototypeOf.d.ts3
-rw-r--r--node_modules/get-proto/Reflect.getPrototypeOf.js4
-rw-r--r--node_modules/get-proto/index.d.ts5
-rw-r--r--node_modules/get-proto/index.js27
-rw-r--r--node_modules/get-proto/package.json81
-rw-r--r--node_modules/get-proto/test/index.js68
-rw-r--r--node_modules/get-proto/tsconfig.json9
15 files changed, 331 insertions, 0 deletions
diff --git a/node_modules/get-proto/.eslintrc b/node_modules/get-proto/.eslintrc
new file mode 100644
index 0000000..1d21a8a
--- /dev/null
+++ b/node_modules/get-proto/.eslintrc
@@ -0,0 +1,10 @@
+{
+ "root": true,
+
+ "extends": "@ljharb",
+
+ "rules": {
+ "id-length": "off",
+ "sort-keys": "off",
+ },
+}
diff --git a/node_modules/get-proto/.github/FUNDING.yml b/node_modules/get-proto/.github/FUNDING.yml
new file mode 100644
index 0000000..93183ef
--- /dev/null
+++ b/node_modules/get-proto/.github/FUNDING.yml
@@ -0,0 +1,12 @@
+# These are supported funding model platforms
+
+github: [ljharb]
+patreon: # Replace with a single Patreon username
+open_collective: # Replace with a single Open Collective username
+ko_fi: # Replace with a single Ko-fi username
+tidelift: npm/get-proto
+community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
+liberapay: # Replace with a single Liberapay username
+issuehunt: # Replace with a single IssueHunt username
+otechie: # Replace with a single Otechie username
+custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
diff --git a/node_modules/get-proto/.nycrc b/node_modules/get-proto/.nycrc
new file mode 100644
index 0000000..bdd626c
--- /dev/null
+++ b/node_modules/get-proto/.nycrc
@@ -0,0 +1,9 @@
+{
+ "all": true,
+ "check-coverage": false,
+ "reporter": ["text-summary", "text", "html", "json"],
+ "exclude": [
+ "coverage",
+ "test"
+ ]
+}
diff --git a/node_modules/get-proto/CHANGELOG.md b/node_modules/get-proto/CHANGELOG.md
new file mode 100644
index 0000000..5860229
--- /dev/null
+++ b/node_modules/get-proto/CHANGELOG.md
@@ -0,0 +1,21 @@
+# Changelog
+
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
+and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+
+## [v1.0.1](https://github.com/ljharb/get-proto/compare/v1.0.0...v1.0.1) - 2025-01-02
+
+### Commits
+
+- [Fix] for the `Object.getPrototypeOf` window, throw for non-objects [`7fe6508`](https://github.com/ljharb/get-proto/commit/7fe6508b71419ebe1976bedb86001d1feaeaa49a)
+
+## v1.0.0 - 2025-01-01
+
+### Commits
+
+- Initial implementation, tests, readme, types [`5c70775`](https://github.com/ljharb/get-proto/commit/5c707751e81c3deeb2cf980d185fc7fd43611415)
+- Initial commit [`7c65c2a`](https://github.com/ljharb/get-proto/commit/7c65c2ad4e33d5dae2f219ebe1a046ae2256972c)
+- npm init [`0b8cf82`](https://github.com/ljharb/get-proto/commit/0b8cf824c9634e4a34ef7dd2a2cdc5be6ac79518)
+- Only apps should have lockfiles [`a6d1bff`](https://github.com/ljharb/get-proto/commit/a6d1bffc364f5828377cea7194558b2dbef7aea2)
diff --git a/node_modules/get-proto/LICENSE b/node_modules/get-proto/LICENSE
new file mode 100644
index 0000000..eeabd1c
--- /dev/null
+++ b/node_modules/get-proto/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2025 Jordan Harband
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/node_modules/get-proto/Object.getPrototypeOf.d.ts b/node_modules/get-proto/Object.getPrototypeOf.d.ts
new file mode 100644
index 0000000..028b3ff
--- /dev/null
+++ b/node_modules/get-proto/Object.getPrototypeOf.d.ts
@@ -0,0 +1,5 @@
+declare function getProto<O extends object>(object: O): object | null;
+
+declare const x: typeof getProto | null;
+
+export = x; \ No newline at end of file
diff --git a/node_modules/get-proto/Object.getPrototypeOf.js b/node_modules/get-proto/Object.getPrototypeOf.js
new file mode 100644
index 0000000..c2cbbdf
--- /dev/null
+++ b/node_modules/get-proto/Object.getPrototypeOf.js
@@ -0,0 +1,6 @@
+'use strict';
+
+var $Object = require('es-object-atoms');
+
+/** @type {import('./Object.getPrototypeOf')} */
+module.exports = $Object.getPrototypeOf || null;
diff --git a/node_modules/get-proto/README.md b/node_modules/get-proto/README.md
new file mode 100644
index 0000000..f8b4cce
--- /dev/null
+++ b/node_modules/get-proto/README.md
@@ -0,0 +1,50 @@
+# get-proto <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
+
+[![github actions][actions-image]][actions-url]
+[![coverage][codecov-image]][codecov-url]
+[![License][license-image]][license-url]
+[![Downloads][downloads-image]][downloads-url]
+
+[![npm badge][npm-badge-png]][package-url]
+
+Robustly get the [[Prototype]] of an object. Uses the best available method.
+
+## Getting started
+
+```sh
+npm install --save get-proto
+```
+
+## Usage/Examples
+
+```js
+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`
+
+[package-url]: https://npmjs.org/package/get-proto
+[npm-version-svg]: https://versionbadg.es/ljharb/get-proto.svg
+[deps-svg]: https://david-dm.org/ljharb/get-proto.svg
+[deps-url]: https://david-dm.org/ljharb/get-proto
+[dev-deps-svg]: https://david-dm.org/ljharb/get-proto/dev-status.svg
+[dev-deps-url]: https://david-dm.org/ljharb/get-proto#info=devDependencies
+[npm-badge-png]: https://nodei.co/npm/get-proto.png?downloads=true&stars=true
+[license-image]: https://img.shields.io/npm/l/get-proto.svg
+[license-url]: LICENSE
+[downloads-image]: https://img.shields.io/npm/dm/get-proto.svg
+[downloads-url]: https://npm-stat.com/charts.html?package=get-proto
+[codecov-image]: https://codecov.io/gh/ljharb/get-proto/branch/main/graphs/badge.svg
+[codecov-url]: https://app.codecov.io/gh/ljharb/get-proto/
+[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/get-proto
+[actions-url]: https://github.com/ljharb/get-proto/actions
diff --git a/node_modules/get-proto/Reflect.getPrototypeOf.d.ts b/node_modules/get-proto/Reflect.getPrototypeOf.d.ts
new file mode 100644
index 0000000..2388fe0
--- /dev/null
+++ b/node_modules/get-proto/Reflect.getPrototypeOf.d.ts
@@ -0,0 +1,3 @@
+declare const x: typeof Reflect.getPrototypeOf | null;
+
+export = x; \ No newline at end of file
diff --git a/node_modules/get-proto/Reflect.getPrototypeOf.js b/node_modules/get-proto/Reflect.getPrototypeOf.js
new file mode 100644
index 0000000..e6c51be
--- /dev/null
+++ b/node_modules/get-proto/Reflect.getPrototypeOf.js
@@ -0,0 +1,4 @@
+'use strict';
+
+/** @type {import('./Reflect.getPrototypeOf')} */
+module.exports = (typeof Reflect !== 'undefined' && Reflect.getPrototypeOf) || null;
diff --git a/node_modules/get-proto/index.d.ts b/node_modules/get-proto/index.d.ts
new file mode 100644
index 0000000..2c021f3
--- /dev/null
+++ b/node_modules/get-proto/index.d.ts
@@ -0,0 +1,5 @@
+declare function getProto<O extends object>(object: O): object | null;
+
+declare const x: typeof getProto | null;
+
+export = x;
diff --git a/node_modules/get-proto/index.js b/node_modules/get-proto/index.js
new file mode 100644
index 0000000..7e5747b
--- /dev/null
+++ b/node_modules/get-proto/index.js
@@ -0,0 +1,27 @@
+'use strict';
+
+var reflectGetProto = require('./Reflect.getPrototypeOf');
+var originalGetProto = require('./Object.getPrototypeOf');
+
+var getDunderProto = require('dunder-proto/get');
+
+/** @type {import('.')} */
+module.exports = reflectGetProto
+ ? function getProto(O) {
+ // @ts-expect-error TS can't narrow inside a closure, for some reason
+ return reflectGetProto(O);
+ }
+ : originalGetProto
+ ? function getProto(O) {
+ if (!O || (typeof O !== 'object' && typeof O !== 'function')) {
+ throw new TypeError('getProto: not an object');
+ }
+ // @ts-expect-error TS can't narrow inside a closure, for some reason
+ return originalGetProto(O);
+ }
+ : getDunderProto
+ ? function getProto(O) {
+ // @ts-expect-error TS can't narrow inside a closure, for some reason
+ return getDunderProto(O);
+ }
+ : null;
diff --git a/node_modules/get-proto/package.json b/node_modules/get-proto/package.json
new file mode 100644
index 0000000..9c35cec
--- /dev/null
+++ b/node_modules/get-proto/package.json
@@ -0,0 +1,81 @@
+{
+ "name": "get-proto",
+ "version": "1.0.1",
+ "description": "Robustly get the [[Prototype]] of an object",
+ "main": "index.js",
+ "exports": {
+ ".": "./index.js",
+ "./Reflect.getPrototypeOf": "./Reflect.getPrototypeOf.js",
+ "./Object.getPrototypeOf": "./Object.getPrototypeOf.js",
+ "./package.json": "./package.json"
+ },
+ "scripts": {
+ "prepack": "npmignore --auto --commentLines=autogenerated",
+ "prepublish": "not-in-publish || npm run prepublishOnly",
+ "prepublishOnly": "safe-publish-latest",
+ "pretest": "npm run --silent lint",
+ "test": "npm run tests-only",
+ "posttest": "npx npm@\">=10.2\" audit --production",
+ "tests-only": "nyc tape 'test/**/*.js'",
+ "prelint": "evalmd README.md",
+ "lint": "eslint --ext=js,mjs .",
+ "postlint": "tsc && attw -P",
+ "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/ljharb/get-proto.git"
+ },
+ "keywords": [
+ "get",
+ "proto",
+ "prototype",
+ "getPrototypeOf",
+ "[[Prototype]]"
+ ],
+ "author": "Jordan Harband <ljharb@gmail.com>",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/ljharb/get-proto/issues"
+ },
+ "homepage": "https://github.com/ljharb/get-proto#readme",
+ "dependencies": {
+ "dunder-proto": "^1.0.1",
+ "es-object-atoms": "^1.0.0"
+ },
+ "devDependencies": {
+ "@arethetypeswrong/cli": "^0.17.2",
+ "@ljharb/eslint-config": "^21.1.1",
+ "@ljharb/tsconfig": "^0.2.3",
+ "@types/tape": "^5.8.0",
+ "auto-changelog": "^2.5.0",
+ "eslint": "=8.8.0",
+ "evalmd": "^0.0.19",
+ "in-publish": "^2.0.1",
+ "npmignore": "^0.3.1",
+ "nyc": "^10.3.2",
+ "safe-publish-latest": "^2.0.0",
+ "tape": "^5.9.0",
+ "typescript": "next"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "auto-changelog": {
+ "output": "CHANGELOG.md",
+ "template": "keepachangelog",
+ "unreleased": false,
+ "commitLimit": false,
+ "backfillLimit": false,
+ "hideCredit": true
+ },
+ "publishConfig": {
+ "ignore": [
+ ".github/workflows"
+ ]
+ },
+ "testling": {
+ "files": "test/index.js"
+ }
+}
diff --git a/node_modules/get-proto/test/index.js b/node_modules/get-proto/test/index.js
new file mode 100644
index 0000000..5a2ece2
--- /dev/null
+++ b/node_modules/get-proto/test/index.js
@@ -0,0 +1,68 @@
+'use strict';
+
+var test = require('tape');
+
+var getProto = require('../');
+
+test('getProto', function (t) {
+ t.equal(typeof getProto, 'function', 'is a function');
+
+ t.test('can get', { skip: !getProto }, function (st) {
+ if (getProto) { // TS doesn't understand tape's skip
+ var proto = { b: 2 };
+ st.equal(getProto(proto), Object.prototype, 'proto: returns the [[Prototype]]');
+
+ st.test('nullish value', function (s2t) {
+ // @ts-expect-error
+ s2t['throws'](function () { return getProto(undefined); }, TypeError, 'undefined is not an object');
+ // @ts-expect-error
+ s2t['throws'](function () { return getProto(null); }, TypeError, 'null is not an object');
+ s2t.end();
+ });
+
+ // @ts-expect-error
+ st['throws'](function () { getProto(true); }, 'throws for true');
+ // @ts-expect-error
+ st['throws'](function () { getProto(false); }, 'throws for false');
+ // @ts-expect-error
+ st['throws'](function () { getProto(42); }, 'throws for 42');
+ // @ts-expect-error
+ st['throws'](function () { getProto(NaN); }, 'throws for NaN');
+ // @ts-expect-error
+ st['throws'](function () { getProto(0); }, 'throws for +0');
+ // @ts-expect-error
+ st['throws'](function () { getProto(-0); }, 'throws for -0');
+ // @ts-expect-error
+ st['throws'](function () { getProto(Infinity); }, 'throws for ∞');
+ // @ts-expect-error
+ st['throws'](function () { getProto(-Infinity); }, 'throws for -∞');
+ // @ts-expect-error
+ st['throws'](function () { getProto(''); }, 'throws for empty string');
+ // @ts-expect-error
+ st['throws'](function () { getProto('foo'); }, 'throws for non-empty string');
+ st.equal(getProto(/a/g), RegExp.prototype);
+ st.equal(getProto(new Date()), Date.prototype);
+ st.equal(getProto(function () {}), Function.prototype);
+ st.equal(getProto([]), Array.prototype);
+ st.equal(getProto({}), Object.prototype);
+
+ var nullObject = { __proto__: null };
+ if ('toString' in nullObject) {
+ st.comment('no null objects in this engine');
+ st.equal(getProto(nullObject), Object.prototype, '"null" object has Object.prototype as [[Prototype]]');
+ } else {
+ st.equal(getProto(nullObject), null, 'null object has null [[Prototype]]');
+ }
+ }
+
+ st.end();
+ });
+
+ t.test('can not get', { skip: !!getProto }, function (st) {
+ st.equal(getProto, null);
+
+ st.end();
+ });
+
+ t.end();
+});
diff --git a/node_modules/get-proto/tsconfig.json b/node_modules/get-proto/tsconfig.json
new file mode 100644
index 0000000..60fb90e
--- /dev/null
+++ b/node_modules/get-proto/tsconfig.json
@@ -0,0 +1,9 @@
+{
+ "extends": "@ljharb/tsconfig",
+ "compilerOptions": {
+ //"target": "es2021",
+ },
+ "exclude": [
+ "coverage",
+ ],
+}