Skip to content

Instantly share code, notes, and snippets.

@caub
Last active October 12, 2017 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caub/15109d6c815cb1f276bb3f399bf5cd46 to your computer and use it in GitHub Desktop.
Save caub/15109d6c815cb1f276bb3f399bf5cd46 to your computer and use it in GitHub Desktop.
a fast yes implementation
const { Readable } = require('stream');
const ys = Buffer.from('y\n'.repeat(2**16));
class Y extends Readable {
_read(size) {
this.push(ys.slice(0, size));
}
}
new Y().pipe(process.stdout); // test with node yes | pv -r > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment