set-global.js 359 B

123456789101112
  1. var global = require('../internals/global');
  2. // eslint-disable-next-line es-x/no-object-defineproperty -- safe
  3. var defineProperty = Object.defineProperty;
  4. module.exports = function (key, value) {
  5. try {
  6. defineProperty(global, key, { value: value, configurable: true, writable: true });
  7. } catch (error) {
  8. global[key] = value;
  9. } return value;
  10. };