From 4365e49816676771a0ca7be69f152c7640989d9f Mon Sep 17 00:00:00 2001 From: Greg Jopa <534034+gregjopa@users.noreply.github.com> Date: Fri, 2 Jun 2023 10:49:08 -0500 Subject: [PATCH] chore: remove custom error when native promise is unavailable --- src/load-script.ts | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/load-script.ts b/src/load-script.ts index 20d5ff0c..91ab07b5 100644 --- a/src/load-script.ts +++ b/src/load-script.ts @@ -16,7 +16,7 @@ import type { PayPalNamespace } from "../types/index"; */ export function loadScript( options: PayPalScriptOptions, - PromisePonyfill: PromiseConstructor = getDefaultPromiseImplementation() + PromisePonyfill: PromiseConstructor = Promise ): Promise { validateArguments(options, PromisePonyfill); @@ -63,7 +63,7 @@ export function loadCustomScript( url: string; attributes?: Record; }, - PromisePonyfill: PromiseConstructor = getDefaultPromiseImplementation() + PromisePonyfill: PromiseConstructor = Promise ): Promise { validateArguments(options, PromisePonyfill); @@ -113,15 +113,6 @@ export function loadCustomScript( }); } -function getDefaultPromiseImplementation() { - if (typeof Promise === "undefined") { - throw new Error( - "Promise is undefined. To resolve the issue, use a Promise polyfill." - ); - } - return Promise; -} - function getPayPalWindowNamespace(namespace: string): PayPalNamespace { // eslint-disable-next-line @typescript-eslint/no-explicit-any return (window as any)[namespace];