Skip to content

Instantly share code, notes, and snippets.

View tytrdev's full-sized avatar

Ty Tracey tytrdev

View GitHub Profile
@tytrdev
tytrdev / keybase.md
Last active April 29, 2020 22:31
keybase.md

Keybase proof

I hereby claim:

  • I am tytrdev on github.
  • I am tydev (https://keybase.io/tydev) on keybase.
  • I have a public key ASATuq1VtDGPELGW335z9SqdYaReD2x2dHD7hkxg-jsATgo

To claim this, I am signing this object:

_read(n) {
this.bytesRead += n;
const value = this.buffer.toString('utf-8', this.bytesRead - n, this.bytesRead);
this.push(value || null);
}
@tytrdev
tytrdev / duplex-consumer.js
Last active December 26, 2019 02:25
Medium code snipper
const duplex = new MyDuplexStream(numberOfBytes);
const writeStream = getWriteStreamSomehow();
duplex.pipe(writeStream);
const { Duplex } = require('stream');
class MyDuplexStream extends Duplex {
constructor(bytes) {
this.buffer = Buffer.alloc(bytes, '', 'utf-8');
this.bytesRead = 0;
}
_read(n) {
this.bytesRead += n;