`Promise.resolve().then(...)` is a convenient, but not ideal pattern because it
needlessly delays processing until the next microtick. (See the explainer for
[`Promise.try`](https://github.com/tc39/proposal-promise-try) for more details,
unfortunately it's not part of the spec yet).
I think this could be rewritten to the equivalent:
```javascript
return new Promise((resolve, reject) => {
if (!dest || !target) {
reject(new CordovaError('Need to supply a target and destination'));
}
// Create dest if it doesn't exist yet
// We can use the async `ensureDir` here rather than `ensureDirSync`
fs.ensureDir(dest).then(_ => resolve());
})
.then(...)
.catch(...)
```
[ Full content available at: https://github.com/apache/cordova-fetch/pull/49 ]
This message was relayed via gitbox.apache.org for [email protected]