Urara-Blog/node_modules/.pnpm-store/v3/files/33/29dd5a9fefb54fd80d5cdab58ed07221b9173684aa2c6706a82564f08a02cb368f54d0bd88564624fe25b2e77f0f222ae90681b91154d23b4384547bca9680
2022-08-14 01:14:53 +08:00

28 lines
921 B
Text

'use strict';
var GetIntrinsic = require('get-intrinsic');
var $Function = GetIntrinsic('%Function%');
var $TypeError = GetIntrinsic('%TypeError%');
var Get = require('./Get');
var IsConstructor = require('./IsConstructor');
var Type = require('./Type');
// https://ecma-international.org/ecma-262/6.0/#sec-getprototypefromconstructor
module.exports = function GetPrototypeFromConstructor(constructor, intrinsicDefaultProto) {
var intrinsic = GetIntrinsic(intrinsicDefaultProto); // throws if not a valid intrinsic
if (!IsConstructor(constructor)) {
throw new $TypeError('Assertion failed: `constructor` must be a constructor');
}
var proto = Get(constructor, 'prototype');
if (Type(proto) !== 'Object') {
if (!(constructor instanceof $Function)) {
// ignore other realms, for now
throw new $TypeError('cross-realm constructors not currently supported');
}
proto = intrinsic;
}
return proto;
};