(respond: (chunk: Buffer, push: (data: Uint8Array) => void) => void)
| 93 | // with no kernel in the path. The read side is unbounded, so this measures the |
| 94 | // Socket layer rather than transport backpressure. |
| 95 | const loopbackDuplex = (respond: (chunk: Buffer, push: (data: Uint8Array) => void) => void): Duplex => { |
| 96 | const duplex: Duplex = new Duplex({ |
| 97 | read() {}, |
| 98 | write(chunk: Buffer, _encoding, callback) { |
| 99 | respond(chunk, (data) => { |
| 100 | duplex.push(data) |
| 101 | }) |
| 102 | callback() |
| 103 | } |
| 104 | }) |
| 105 | return duplex |
| 106 | } |
| 107 | |
| 108 | const duplexEcho = (): Duplex => loopbackDuplex((chunk, push) => push(chunk)) |
| 109 |
no outgoing calls
no test coverage detected