mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-09 08:45:55 +02:00
14 lines
366 B
JavaScript
14 lines
366 B
JavaScript
function promiseChain(chain, defaultValue = null) {
|
|
let output = new Promise((resolve) => {
|
|
resolve(defaultValue);
|
|
});
|
|
for (let i = 0; i < chain.length; i++) {
|
|
const f = chain[i];
|
|
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
|
|
output = output.then(f);
|
|
}
|
|
return output;
|
|
}
|
|
|
|
module.exports = { promiseChain };
|