Skip to content

Instantly share code, notes, and snippets.

View jacwright's full-sized avatar
👨‍💻
Working on Dabble

Jacob Wright jacwright

👨‍💻
Working on Dabble
View GitHub Profile
@Rich-Harris
Rich-Harris / index.js
Last active January 22, 2020 22:21
whatwg stream utils
const fs = require('fs');
const { ReadableStream, TransformStream, WritableStream} = require('web-streams-polyfill/ponyfill/es2018');
function createReadStream(file, opts) {
return new ReadableStream({
start(controller) {
const stream = fs.createReadStream(file, opts);
stream.on('readable', () => {
const data = stream.read();
controller.enqueue(data);