system_assignation/node_modules/globalthis/shim.js

23 lines
722 B
JavaScript
Raw Normal View History

2022-03-24 09:22:39 -04:00
'use strict';
var define = require('define-properties');
var getPolyfill = require('./polyfill');
module.exports = function shimGlobal() {
var polyfill = getPolyfill();
if (define.supportsDescriptors) {
var descriptor = Object.getOwnPropertyDescriptor(polyfill, 'globalThis');
if (!descriptor || (descriptor.configurable && (descriptor.enumerable || descriptor.writable || globalThis !== polyfill))) { // eslint-disable-line max-len
Object.defineProperty(polyfill, 'globalThis', {
configurable: true,
enumerable: false,
value: polyfill,
writable: false
});
}
} else if (typeof globalThis !== 'object' || globalThis !== polyfill) {
polyfill.globalThis = polyfill;
}
return polyfill;
};