File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -24,13 +24,14 @@ if (crypto && crypto.getRandomValues) {
2424function 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
You can’t perform that action at this time.
0 commit comments