Skip to content

Commit

Permalink
chore: remove custom error when native promise is unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
gregjopa committed Jun 2, 2023
1 parent 1e83807 commit 4365e49
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/load-script.ts
Expand Up @@ -16,7 +16,7 @@ import type { PayPalNamespace } from "../types/index";
*/
export function loadScript(
options: PayPalScriptOptions,
PromisePonyfill: PromiseConstructor = getDefaultPromiseImplementation()
PromisePonyfill: PromiseConstructor = Promise
): Promise<PayPalNamespace | null> {
validateArguments(options, PromisePonyfill);

Expand Down Expand Up @@ -63,7 +63,7 @@ export function loadCustomScript(
url: string;
attributes?: Record<string, string>;
},
PromisePonyfill: PromiseConstructor = getDefaultPromiseImplementation()
PromisePonyfill: PromiseConstructor = Promise
): Promise<void> {
validateArguments(options, PromisePonyfill);

Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 4365e49

Please sign in to comment.