Skip to content

Commit a6eb45f

Browse files
authored
Iterate polyfills instead of calling each individually
1 parent f715af6 commit a6eb45f

1 file changed

Lines changed: 21 additions & 29 deletions

File tree

src/index.ts

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -42,43 +42,35 @@ const baseSupport =
4242
// 'at' in Array.prototype && // Polyfilled
4343
true
4444

45+
const polyfills = [
46+
abortSignalAbort,
47+
abortSignalTimeout,
48+
aggregateError,
49+
arrayAt,
50+
cryptoRandomUUID,
51+
eventAbortSignal,
52+
objectHasOwn,
53+
promiseAny,
54+
requestIdleCallback
55+
]
56+
4557
export function isSupported() {
4658
return (
4759
baseSupport &&
48-
abortSignalAbort.isSupported() &&
49-
abortSignalTimeout.isSupported() &&
50-
aggregateError.isSupported() &&
51-
arrayAt.isSupported() &&
52-
cryptoRandomUUID.isSupported() &&
53-
eventAbortSignal.isSupported() &&
54-
objectHasOwn.isSupported() &&
55-
promiseAny.isSupported() &&
56-
requestIdleCallback.isSupported()
60+
polyfills.every(polyfill => {
61+
polyfill.isSupported()
62+
})
5763
)
5864
}
5965

6066
export function isPolyfilled() {
61-
return (
62-
abortSignalAbort.isPolyfilled() &&
63-
abortSignalTimeout.isPolyfilled() &&
64-
aggregateError.isPolyfilled() &&
65-
arrayAt.isPolyfilled() &&
66-
cryptoRandomUUID.isPolyfilled() &&
67-
eventAbortSignal.isPolyfilled() &&
68-
objectHasOwn.isPolyfilled() &&
69-
promiseAny.isPolyfilled() &&
70-
requestIdleCallback.isPolyfilled()
71-
)
67+
return polyfills.every(polyfill => {
68+
polyfill.isPolyfilled()
69+
})
7270
}
7371

7472
export function apply() {
75-
abortSignalAbort.apply()
76-
abortSignalTimeout.apply()
77-
aggregateError.apply()
78-
arrayAt.apply()
79-
cryptoRandomUUID.apply()
80-
eventAbortSignal.apply()
81-
objectHasOwn.apply()
82-
promiseAny.apply()
83-
requestIdleCallback.apply()
73+
for (const polyfill of polyfills) {
74+
polyfill.apply()
75+
}
8476
}

0 commit comments

Comments
 (0)