UNPKG

@applitools/execution-grid-tunnel

Version:

Allows user to run tests with exection-grid and navigate to private hosts and ips

28 lines (24 loc) 804 B
const {Transform} = require('stream') class KeepaliveMessageFilter extends Transform { constructor(options) { super(options); this._keepAliveMessage = options.keepAliveMessage this._waitForChunkResolver = null this._waitForChunkPromise = new Promise(resolve => this._waitForChunkResolver = resolve) } _transform(chunk, encoding, callback){ const transformedChunk = chunk if (chunk.length !== this._keepAliveMessage.length || transformedChunk.toString() !== this._keepAliveMessage){ if(this._waitForChunkResolver){ this._waitForChunkResolver() this._waitForChunkResolver = null } this.push(chunk); } callback(); } async waitForChunk(){ return this._waitForChunkPromise } } module.exports = {KeepaliveMessageFilter}