1234567891011121314151617181920212223242526272829303132333435 |
- 'use strict';
- var callBind = require('call-bind-apply-helpers');
- var gOPD = require('gopd');
- var $TypeError = require('es-errors/type');
- var obj = {};
- try {
- obj.__proto__ = null;
- } catch (e) {
- if (!e || typeof e !== 'object' || !('code' in e) || e.code !== 'ERR_PROTO_ACCESS') {
- throw e;
- }
- }
- var hasProtoMutator = !('toString' in obj);
- var desc = gOPD && gOPD(Object.prototype, ('__proto__'));
- module.exports = hasProtoMutator && (
- (!!desc && typeof desc.set === 'function' && (callBind([desc.set])))
- || function setDunder(object, proto) {
-
- if (object == null) {
- throw new $TypeError('set Object.prototype.__proto__ called on null or undefined');
- }
-
- (object).__proto__ = proto;
- return proto;
- }
- );
|