function process () {
return new Promise((resolve, reject) => {
//make sure module exists
let module = modules[queueData.module];
if (!module) reject('module not found: '+queueData.module);
//make sure processor exists
let processor = fileProcessors[module.type];
if (!processor) reject('processor not found: '+module.type);
return anotherPromiseFunction();
})
}
processFile().catch(e => console.error)
anotherPromiseFunction() returns a promise. normally inside a .then() I can return a promise to make the then() wait for that promise to finish, but how do I do it when creating a promise?
Am I supposed to do this:
anotherPromiseFunction()
.then(e=>resolve(e))
.catch(e=>reject(e))
That seems wrong...