Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 99732e3

Browse files
committedJul 12, 2021
Remove wait function and use delay instead.
1 parent 38c10ed commit 99732e3

File tree

1 file changed

+6
-9
lines changed
  • packages/net-stubbing/lib/server

1 file changed

+6
-9
lines changed
 

‎packages/net-stubbing/lib/server/util.ts

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import _ from 'lodash'
22
import Debug from 'debug'
33
import isHtml from 'is-html'
4+
import Promise from 'bluebird'
45
import { IncomingMessage } from 'http'
56
import {
67
RouteMatcherOptionsGeneric,
@@ -220,17 +221,13 @@ export async function getBodyStream (body: Buffer | string | Readable | undefine
220221
return writable.end()
221222
}
222223

223-
delay ? await wait(sendBody, delay) : sendBody()
224+
if (delay) {
225+
await Promise.delay(delay)
226+
}
224227

225-
return pt
226-
}
228+
sendBody()
227229

228-
function wait (fn, ms) {
229-
return new Promise((resolve) => {
230-
setTimeout(() => {
231-
resolve(fn())
232-
}, ms)
233-
})
230+
return pt
234231
}
235232

236233
export function mergeDeletedHeaders (before: CyHttpMessages.BaseMessage, after: CyHttpMessages.BaseMessage) {

0 commit comments

Comments
 (0)
Please sign in to comment.