"use strict"; const propagateAbort = require("@promistream/propagate-abort"); const createSequentialQueue = require("./sequential-queue"); module.exports = function sequentialize() { let withQueue = createSequentialQueue(); return { _promistreamVersion: 0, description: `sequentialize`, // FIXME: We don't queue up aborts because once a downstream has encountered an error, it may have stopped trying to read, and we would deadlock. While the Aborted marker reads *do* get queued, the abort itself should probably be immediate. Need to make sure that this doesn't clash with any other part of the spec. abort: propagateAbort, peek: function peek(source) { return withQueue(() => { return source.peek(); }); }, read: function read(source) { return withQueue(() => { return source.read(); }); } }; };