Only four helpers
Five slow hashes at once. Watch what happens to the fifth.
const crypto = require('node:crypto');let finished = 0;for (let i = 1; i <= 5; i++) { crypto.pbkdf2('secret', 'salt', 100000, 64, 'sha512', () => { finished++; if (finished === 4) console.log('four done'); if (finished === 5) console.log('fifth done'); });}console.log('all queued');1. Predict the output
Tap the lines in the order you think they print.
- 1…
- 2…
- 3…