What is the best way to create a readable stream from an array and pipe values to a writable stream? I have seen substack\'s example using setInterval and I can implement that s
tl;dr;
This is a LIFO solution. Array.prototype.pop() has similar behavior to shift but applied to the last element in an array.
const items = [1,2,3] const stream = new Readable({ objectMode: true, read() { const item = items.pop() if (!item) { this.push(null); return; } this.push(item) }, })