mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-06 08:36:52 +02:00
13 lines
271 B
JavaScript
13 lines
271 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];
|
|
output = output.then(f);
|
|
}
|
|
return output;
|
|
}
|
|
|
|
module.exports = { promiseChain };
|