Skip to content

Commit

Permalink
Replace wait(0) with Promise.resolve(): should reduce the bundle size
Browse files Browse the repository at this point in the history
  • Loading branch information
tkrotoff committed Jul 6, 2023
1 parent cd5a2f5 commit 4abce17
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/Http.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { entriesToObject } from './utils/entriesToObject';
import { wait } from './utils/wait';
import { HttpError } from './HttpError';

/**
Expand Down Expand Up @@ -94,7 +93,7 @@ function request<T extends BodyInit>(
) {
async function _fetch() {
// Have to wait for headers to be modified inside extendResponsePromiseWithBodyMethods
await wait(1);
await Promise.resolve();

const response = await fetch(input, {
...defaults.init,
Expand Down
3 changes: 1 addition & 2 deletions src/createResponsePromise.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import assert from 'node:assert';

import { entriesToObject } from './utils/entriesToObject';
import { wait } from './utils/wait';
import { createJSONResponsePromise, createResponsePromise } from './createResponsePromise';
import * as Http from './Http';
import { HttpStatus } from './HttpStatus';
Expand Down Expand Up @@ -295,7 +294,7 @@ describe('post()', () => {
});
});

const flushPromises = () => wait(0);
const flushPromises = () => Promise.resolve();

describe('flushPromises()', () => {
// Throws "HttpError: Service Unavailable", this cannot be catched so we have to skip the test :-/
Expand Down

0 comments on commit 4abce17

Please sign in to comment.