-
Notifications
You must be signed in to change notification settings - Fork 24
Conversation
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.
Working with Promises I always find it hard to make sure errors are really bubbled up correctly. Could you please add more tests for failure scenarios? It seems a bit hard to do as the hashing won't fail in many reasons, but at least one case I could think of is using a non supported hash function. Perhaps you could think of more cases.
As the API is so small it would be great if you could expand the BREAKING CHANGE
notice on the commit message with an example on how the API changes. I think we should do this for all breaking changes, so that the changelog contains the upgrade path if you want to use the new version.
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.
In summary, there's no reason to use new Promise
unless we're converting a callback API and we should always use async/await
over .then
- there's no reason not to.
Really great review, @alanshaw 👏🏽👏🏽👏🏽 Lot's of knowledge shared on how to better use async/await. Thank you :) |
Address comments on [parent PR](#37)
7233f53
to
fa17918
Compare
Address comments on [parent PR](#37)
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 a super minor detail
benchmarks/hash.js
Outdated
list.push(res) | ||
d.resolve() | ||
}) | ||
multihashing(buf, alg) |
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.
change this to use await instead?
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.
LGTM
sha.sha2256((Buffer.from(firstHash)), cb) | ||
}) | ||
default: | ||
throw new TypeError(`${algorithm} is not a supported algorithm`) |
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.
I think this should be a regular Error
...
src/sha.browser.js
Outdated
return Buffer.from(await crypto.subtle.digest({ name: 'SHA-256' }, d)) | ||
} | ||
default: | ||
throw new TypeError(`${algorithm} is not a supported algorithm`) |
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.
Regular Error
?
src/sha.js
Outdated
return crypto.createHash('sha256').update(first).digest() | ||
} | ||
default: | ||
throw new TypeError(`${algorithm} is not a supported algorithm`) |
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.
Regular Error
?
Lets get this released @hugomrdias! |
BREAKING CHANGE: callbacks are not supported!!
Address comments on [parent PR](#37)
46e961d
to
d6889e9
Compare
BREAKING CHANGE: callbacks are not supported!!