From 7709369e49d08ed1e057b2c6274f6cffa3ec37a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Rebours?= Date: Wed, 22 Dec 2021 22:47:51 +0100 Subject: [PATCH] JSDoc --- lib/executor.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/executor.js b/lib/executor.js index 6f0cf34..61275be 100755 --- a/lib/executor.js +++ b/lib/executor.js @@ -1,15 +1,41 @@ /** * Responsible for sequentially executing actions on the database + * @private */ class Waterfall { constructor () { + /** + * This is the internal Promise object which resolves when all the tasks of the `Waterfall` are done. + * + * It will change any time `this.waterfall` is called, this is why there is a getter `this.guardian` which retrieves + * the latest version of the guardian. + * @type {Promise} + * @private + */ this._guardian = Promise.resolve() } + /** + * Returns a Promise which resolves when all tasks up to when this function is called are done. + * + * This Promise cannot reject. + * @return {Promise} + */ get guardian () { return this._guardian } + /** + * @callback Waterfall~function + * @param {...[*]} args + * @return {Promise<*>} + */ + + /** + * + * @param {Waterfall~function} func + * @return {Waterfall~function} + */ waterfall (func) { return (...args) => { this._guardian = this.guardian.then(() => {