Skip to content

Instantly share code, notes, and snippets.

View aliaksandr-kazarez's full-sized avatar
🔫
Жаль, нет ружья

Aliaksandr Kazarez aliaksandr-kazarez

🔫
Жаль, нет ружья
View GitHub Profile
@aliaksandr-kazarez
aliaksandr-kazarez / MockDuplex.ts
Created December 28, 2018 09:24
Mock Duplex implementation
class MockResponse extends Duplex {
private chunks = Buffer.alloc(0);
_write(chunk: Buffer, encoding: string, cb: Function) {
this.chunks = Buffer.concat([this.chunks, chunk]);
cb();
}
_read(size: number) {
let result = true;
while (result && this.chunks.length > 0) {