playwright-core
Advanced tools
Comparing version
@@ -26,4 +26,2 @@ /** | ||
private readonly _delegate; | ||
private _incomingMessageQueue; | ||
private _dispatchTimerId?; | ||
onmessage?: (message: string) => void; | ||
@@ -33,5 +31,3 @@ onclose?: () => void; | ||
constructor(transport: ConnectionTransport, delay: number); | ||
private _enqueueMessage; | ||
private _scheduleQueueDispatch; | ||
private _dispatchOneMessageFromQueue; | ||
private _onmessage; | ||
private _onClose; | ||
@@ -38,0 +34,0 @@ send(s: string): void; |
@@ -21,6 +21,5 @@ "use strict"; | ||
constructor(transport, delay) { | ||
this._incomingMessageQueue = []; | ||
this._delay = delay; | ||
this._delegate = transport; | ||
this._delegate.onmessage = this._enqueueMessage.bind(this); | ||
this._delegate.onmessage = this._onmessage.bind(this); | ||
this._delegate.onclose = this._onClose.bind(this); | ||
@@ -31,26 +30,6 @@ } | ||
} | ||
_enqueueMessage(message) { | ||
this._incomingMessageQueue.push(message); | ||
this._scheduleQueueDispatch(); | ||
_onmessage(message) { | ||
if (this.onmessage) | ||
this.onmessage(message); | ||
} | ||
_scheduleQueueDispatch() { | ||
if (this._dispatchTimerId) | ||
return; | ||
if (!this._incomingMessageQueue.length) | ||
return; | ||
this._dispatchTimerId = setTimeout(() => { | ||
this._dispatchTimerId = undefined; | ||
this._dispatchOneMessageFromQueue(); | ||
}, this._delay); | ||
} | ||
_dispatchOneMessageFromQueue() { | ||
const message = this._incomingMessageQueue.shift(); | ||
try { | ||
if (this.onmessage) | ||
this.onmessage(message); | ||
} | ||
finally { | ||
this._scheduleQueueDispatch(); | ||
} | ||
} | ||
_onClose() { | ||
@@ -63,3 +42,6 @@ if (this.onclose) | ||
send(s) { | ||
this._delegate.send(s); | ||
setTimeout(() => { | ||
if (this._delegate.onmessage) | ||
this._delegate.send(s); | ||
}, this._delay); | ||
} | ||
@@ -66,0 +48,0 @@ close() { |
{ | ||
"name": "playwright-core", | ||
"version": "0.11.1-next.1583879747559", | ||
"version": "0.11.1-next.1583881898738", | ||
"description": "A high-level API to automate web browsers", | ||
@@ -5,0 +5,0 @@ "repository": "github:Microsoft/playwright", |
Sorry, the diff of this file is too big to display
2443654
-0.05%57253
-0.07%