I currently have the following promise wrapping function:
var promiseWrap = (promiseInstance, resolveFunc, rejectFunc) => {
return new Promise((resolvePath, rejectPath) => {
promiseInstance
.then((...args) => {
resolvePath(resolveFunc.apply(null, args))
})
.catch((...args) => {
rejectPath(rejectFunc.apply(null, args))
})
});
}
While this works, I get the feeling that it isn't the most efficient way of achieving the desired result, and may even betray a fundamental lack of understanding of how promises work. So this is fairly generic, but how would you refactor this code? Is there even a better way of achieving the same result?