Skip to content

Commit

Permalink
Switch to native Promise.allSettled
Browse files Browse the repository at this point in the history
As discussed in code review, this is widely available.  Update tsconfig.json to recognize it.
  • Loading branch information
joshkel committed Nov 20, 2024
1 parent f5c41d4 commit acd9391
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 55 deletions.
2 changes: 0 additions & 2 deletions packages/workbox-core/src/_private.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

// We either expose defaults or we expose every named export.
import {allSettled} from './_private/allSettled.js';
import {assert} from './_private/assert.js';
import {cacheNames} from './_private/cacheNames.js';
import {cacheMatchIgnoreParams} from './_private/cacheMatchIgnoreParams.js';
Expand All @@ -26,7 +25,6 @@ import {WorkboxError} from './_private/WorkboxError.js';
import './_version.js';

export {
allSettled,
assert,
cacheMatchIgnoreParams,
cacheNames,
Expand Down
46 changes: 0 additions & 46 deletions packages/workbox-core/src/_private/allSettled.ts

This file was deleted.

8 changes: 2 additions & 6 deletions packages/workbox-strategies/src/StrategyHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
https://opensource.org/licenses/MIT.
*/

import {
allSettled,
PromiseRejection,
} from 'workbox-core/_private/allSettled.js';
import {assert} from 'workbox-core/_private/assert.js';
import {cacheMatchIgnoreParams} from 'workbox-core/_private/cacheMatchIgnoreParams.js';
import {Deferred} from 'workbox-core/_private/Deferred.js';
Expand Down Expand Up @@ -566,10 +562,10 @@ class StrategyHandler {
async doneWaiting(): Promise<void> {
while (this._extendLifetimePromises.length) {
const promises = this._extendLifetimePromises.splice(0);
const result = await allSettled(promises);
const result = await Promise.allSettled(promises);
const firstRejection = result.find((i) => i.status === 'rejected');
if (firstRejection) {
throw (firstRejection as PromiseRejection).reason;
throw (firstRejection as PromiseRejectedResult).reason;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"composite": true,
"declaration": true,
"lib": ["es2017", "webworker"],
"lib": ["es2020", "webworker"],
"module": "esnext",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
Expand Down

0 comments on commit acd9391

Please sign in to comment.