Skip to content

Commit 6c788ab

Browse files
committed
better comments
1 parent 5a92a4c commit 6c788ab

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

browser.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ if (crypto && crypto.getRandomValues) {
2424
function randomBytes (size, cb) {
2525
// phantomjs needs to throw
2626
if (size > MAX_UINT32) throw new Error('requested too many random bytes')
27-
// in case browserify isn't using the Uint8Array version
27+
2828
var bytes = Buffer.allocUnsafe(size)
2929

30-
// This will not work in older browsers.
31-
// See https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
30+
3231
if (size > 0) { // getRandomValues fails on IE if size == 0
33-
if (size > MAX_BYTES) {
32+
33+
if (size > MAX_BYTES) { // this is the max bytes crypto.getRandomValues
34+
// can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
3435
for (var generated = 0; generated < size; generated += MAX_BYTES) {
3536
// buffer.slice automatically checks if the end is past the end of
3637
// the buffer so we don't have to here

0 commit comments

Comments
 (0)