From 4abce17942036eb4f030c95eb170e7c9a355c1d4 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Thu, 6 Jul 2023 10:26:56 +0200 Subject: [PATCH] Replace wait(0) with Promise.resolve(): should reduce the bundle size --- src/Http.ts | 3 +-- src/createResponsePromise.test.ts | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Http.ts b/src/Http.ts index bf72f54..761e0aa 100644 --- a/src/Http.ts +++ b/src/Http.ts @@ -1,5 +1,4 @@ import { entriesToObject } from './utils/entriesToObject'; -import { wait } from './utils/wait'; import { HttpError } from './HttpError'; /** @@ -94,7 +93,7 @@ function request( ) { 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, diff --git a/src/createResponsePromise.test.ts b/src/createResponsePromise.test.ts index 2ff29d9..1f84be5 100644 --- a/src/createResponsePromise.test.ts +++ b/src/createResponsePromise.test.ts @@ -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'; @@ -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 :-/