mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-09 04:20:08 +08:00
26 lines
733 B
JavaScript
26 lines
733 B
JavaScript
|
|
'use strict';
|
||
|
|
|
||
|
|
var reflectSetProto = require('./Reflect.setPrototypeOf');
|
||
|
|
var originalSetProto = require('./Object.setPrototypeOf');
|
||
|
|
|
||
|
|
var setDunderProto = require('dunder-proto/set');
|
||
|
|
|
||
|
|
var $TypeError = require('es-errors/type');
|
||
|
|
|
||
|
|
/** @type {import('.')} */
|
||
|
|
module.exports = reflectSetProto
|
||
|
|
? function setProto(O, proto) {
|
||
|
|
// @ts-expect-error TS can't narrow inside a closure, for some reason
|
||
|
|
if (reflectSetProto(O, proto)) {
|
||
|
|
return O;
|
||
|
|
}
|
||
|
|
throw new $TypeError('Reflect.setPrototypeOf: failed to set [[Prototype]]');
|
||
|
|
}
|
||
|
|
: originalSetProto || (
|
||
|
|
setDunderProto ? function setProto(O, proto) {
|
||
|
|
// @ts-expect-error TS can't narrow inside a closure, for some reason
|
||
|
|
setDunderProto(O, proto);
|
||
|
|
return O;
|
||
|
|
} : null
|
||
|
|
);
|