From 0209ccb2cd95b785e7e8868fab035cdc87216b58 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 29 Apr 2024 13:51:31 -0700 Subject: [PATCH] [Refactor] use `gopd` --- package.json | 3 ++- shim.js | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index dffe898..6858534 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "shim" ], "dependencies": { - "define-properties": "^1.2.1" + "define-properties": "^1.2.1", + "gopd": "^1.0.1" }, "devDependencies": { "@es-shims/api": "^2.5.0", diff --git a/shim.js b/shim.js index 7ccf455..ee89bbb 100644 --- a/shim.js +++ b/shim.js @@ -1,13 +1,20 @@ 'use strict'; var define = require('define-properties'); +var gOPD = require('gopd'); 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 + var descriptor = gOPD(polyfill, 'globalThis'); + if ( + !descriptor + || ( + descriptor.configurable + && (descriptor.enumerable || !descriptor.writable || globalThis !== polyfill) + ) + ) { Object.defineProperty(polyfill, 'globalThis', { configurable: true, enumerable: false,