Frontend/25_01_07/mai/node_modules/set-proto/index.js

26 lines
733 B
JavaScript
Raw Normal View History

2025-01-28 10:38:27 +00:00
'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
);