19 ms·
Even without async/await, it could be better if some unnecessary nesting would be cleaned up openpgp.cleartext .readArmored(req.body.message) .
by vimslayer 7y ago
Even without async/await, it could be better if some unnecessary nesting would be cleaned up
openpgp.cleartext
.readArmored(req.body.message)
.then(message => {
openpgp.key
.readArmored(nodes[0].value.key)
.then(key => {
...
})
})
could be
openpgp.cleartext
.readArmored(req.body.message)
.then(message =>
openpgp.key.readArmored(nodes[0].value.key)
)
.then(key => {
...
})
- githubsucks 7y agoDid you try running the code with the change you suggested? The lattermost closure in your snippet (`key => { ... }`) needs to be able to reference `message`, but you've moved it out of scope. This and similar subthreads in this Show HN entry are a good example of pointless, hostile, obnoxiously-pedantic-without-even-being-technically-correct wankery that makes HN an often terrible place for conversations.
- vimslayer 7y agoUgh you're right, it wouldn't work then. For what it's worth I was mostly commenting on the "the poster child of why async/await was made" comment above with the idea that async/await wouldn't necessarily be needed to make the code cleaner. But as you pointed out, in this case it wouldn't work. I'm sorry if the commment came out as wankery.