@jahed/sparql-engine
Version:
SPARQL query engine for servers and web browsers.
25 lines • 720 B
JavaScript
// SPDX-License-Identifier: MIT
import { Consumable } from "./consumer.js";
/**
* ManyConsumers group multiple {@link Consumable} to be evaluated in sequence
*/
export default class ManyConsumers extends Consumable {
_consumers;
/**
* Constructor
* @param consumers - Set of consumables
*/
constructor(consumers) {
super();
this._consumers = consumers;
}
execute() {
if (this._consumers.length === 1) {
return this._consumers[0].execute();
}
return this._consumers.reduce((prev, consumer) => {
return prev.then(() => consumer.execute());
}, Promise.resolve());
}
}
//# sourceMappingURL=many-consumers.js.map