You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
842 B
JavaScript
27 lines
842 B
JavaScript
"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();
|
|
});
|
|
}
|
|
};
|
|
};
|