-
Notifications
You must be signed in to change notification settings - Fork 6
refactor: use async/await instead of callbacks #37
Conversation
bbfb00c to
fff701a
Compare
achingbrain
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor nits but LGTM
chore: move promisify to dev dep
|
👍 nits fixed |
| */ | ||
| async function findAsync (array, asyncCompare) { | ||
| const promises = array.map(asyncCompare) | ||
| const results = await Promise.all(promises) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to wait for all these promises to resolve before we can find the value. This is a change in behaviour from async/detect which executes in parallel but will call the callback _as soon as _ one returns true.
...we can leave this for a separate PR.
vasco-santos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just pointed some minor stuff mostly regarding jsdocs
src/keychain.js
Outdated
| const kid = await privateKey.id() | ||
| // if (err) return throwDelayed(callback, err) | ||
| const pem = await privateKey.export(this._()) | ||
| // if (err) return throwDelayed(callback, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remove all the above comments?
We should probably add a try...catch from the const kid line until the commit throwing using the throwDelayed if we catch any error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, I also wrapped renameKey to make sure we're delaying there as well.
Co-Authored-By: Vasco Santos <vasco.santos@moxy.studio>
BREAKING CHANGE: The api now uses async/await instead of callbacks.