From a6eb45f580095e74a77c4febd0ab78fe6cd0dc96 Mon Sep 17 00:00:00 2001 From: Dusty Greif Date: Tue, 15 Feb 2022 03:26:31 +0000 Subject: [PATCH 1/2] Iterate polyfills instead of calling each individually --- src/index.ts | 50 +++++++++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/src/index.ts b/src/index.ts index 9f5cdeb..d8af07e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -42,43 +42,35 @@ const baseSupport = // 'at' in Array.prototype && // Polyfilled true +const polyfills = [ + abortSignalAbort, + abortSignalTimeout, + aggregateError, + arrayAt, + cryptoRandomUUID, + eventAbortSignal, + objectHasOwn, + promiseAny, + requestIdleCallback +] + export function isSupported() { return ( baseSupport && - abortSignalAbort.isSupported() && - abortSignalTimeout.isSupported() && - aggregateError.isSupported() && - arrayAt.isSupported() && - cryptoRandomUUID.isSupported() && - eventAbortSignal.isSupported() && - objectHasOwn.isSupported() && - promiseAny.isSupported() && - requestIdleCallback.isSupported() + polyfills.every(polyfill => { + polyfill.isSupported() + }) ) } export function isPolyfilled() { - return ( - abortSignalAbort.isPolyfilled() && - abortSignalTimeout.isPolyfilled() && - aggregateError.isPolyfilled() && - arrayAt.isPolyfilled() && - cryptoRandomUUID.isPolyfilled() && - eventAbortSignal.isPolyfilled() && - objectHasOwn.isPolyfilled() && - promiseAny.isPolyfilled() && - requestIdleCallback.isPolyfilled() - ) + return polyfills.every(polyfill => { + polyfill.isPolyfilled() + }) } export function apply() { - abortSignalAbort.apply() - abortSignalTimeout.apply() - aggregateError.apply() - arrayAt.apply() - cryptoRandomUUID.apply() - eventAbortSignal.apply() - objectHasOwn.apply() - promiseAny.apply() - requestIdleCallback.apply() + for (const polyfill of polyfills) { + polyfill.apply() + } } From 968b8d508ad3af22349756f58a539d4b427af195 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Tue, 15 Feb 2022 08:18:12 +0000 Subject: [PATCH 2/2] add comma --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 1c27472..414748e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -48,7 +48,7 @@ const polyfills = [ aggregateError, arrayAt, cryptoRandomUUID, - elementReplaceChildren + elementReplaceChildren, eventAbortSignal, objectHasOwn, promiseAny,