You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
733 B
26 lines
733 B
![]()
1 week ago
|
'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
|
||
|
);
|