Skip to content

Commit

Permalink
doc: fix outdated 'try/catch' statement in sync
Browse files Browse the repository at this point in the history
Fixes description about crypto.randomBytes.

Fixes: #3081
PR-URL: #3087
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Brendan Ashworth <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
  • Loading branch information
JungMinu authored and rvagg committed Oct 2, 2015
1 parent 5a9e795 commit f92aee7
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions doc/api/crypto.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -651,13 +651,8 @@ Generates cryptographically strong pseudo-random data. Usage:
});

// sync
try {
var buf = crypto.randomBytes(256);
console.log('Have %d bytes of random data: %s', buf.length, buf);
} catch (ex) {
// handle error
// most likely, entropy sources are drained
}
const buf = crypto.randomBytes(256);
console.log('Have %d bytes of random data: %s', buf.length, buf);

NOTE: This will block if there is insufficient entropy, although it should
normally never take longer than a few milliseconds. The only time when this
Expand Down

0 comments on commit f92aee7

Please sign in to comment.