@@ -49,19 +49,19 @@ function assertSize(size, elementSize, offset, length) {
4949 return size >>> 0 ; // Convert to uint32.
5050}
5151
52- function randomBytes ( size , cb ) {
52+ function randomBytes ( size , callback ) {
5353 size = assertSize ( size , 1 , 0 , Infinity ) ;
54- if ( cb !== undefined && typeof cb !== 'function' )
55- throw new ERR_INVALID_CALLBACK ( cb ) ;
54+ if ( callback !== undefined && typeof callback !== 'function' )
55+ throw new ERR_INVALID_CALLBACK ( callback ) ;
5656
5757 const buf = new FastBuffer ( size ) ;
5858
59- if ( ! cb ) return handleError ( _randomBytes ( buf , 0 , size ) , buf ) ;
59+ if ( ! callback ) return handleError ( _randomBytes ( buf , 0 , size ) , buf ) ;
6060
6161 const wrap = new AsyncWrap ( Providers . RANDOMBYTESREQUEST ) ;
6262 wrap . ondone = ( ex ) => { // Retains buf while request is in flight.
63- if ( ex ) return cb . call ( wrap , ex ) ;
64- cb . call ( wrap , null , buf ) ;
63+ if ( ex ) return callback . call ( wrap , ex ) ;
64+ callback . call ( wrap , null , buf ) ;
6565 } ;
6666
6767 _randomBytes ( buf , 0 , size , wrap ) ;
@@ -85,22 +85,22 @@ function randomFillSync(buf, offset = 0, size) {
8585 return handleError ( _randomBytes ( buf , offset , size ) , buf ) ;
8686}
8787
88- function randomFill ( buf , offset , size , cb ) {
88+ function randomFill ( buf , offset , size , callback ) {
8989 if ( ! isArrayBufferView ( buf ) ) {
9090 throw new ERR_INVALID_ARG_TYPE ( 'buf' , 'ArrayBufferView' , buf ) ;
9191 }
9292
9393 const elementSize = buf . BYTES_PER_ELEMENT || 1 ;
9494
9595 if ( typeof offset === 'function' ) {
96- cb = offset ;
96+ callback = offset ;
9797 offset = 0 ;
9898 size = buf . bytesLength ;
9999 } else if ( typeof size === 'function' ) {
100- cb = size ;
100+ callback = size ;
101101 size = buf . byteLength - offset ;
102- } else if ( typeof cb !== 'function' ) {
103- throw new ERR_INVALID_CALLBACK ( cb ) ;
102+ } else if ( typeof callback !== 'function' ) {
103+ throw new ERR_INVALID_CALLBACK ( callback ) ;
104104 }
105105
106106 offset = assertOffset ( offset , elementSize , buf . byteLength ) ;
@@ -113,8 +113,8 @@ function randomFill(buf, offset, size, cb) {
113113
114114 const wrap = new AsyncWrap ( Providers . RANDOMBYTESREQUEST ) ;
115115 wrap . ondone = ( ex ) => { // Retains buf while request is in flight.
116- if ( ex ) return cb . call ( wrap , ex ) ;
117- cb . call ( wrap , null , buf ) ;
116+ if ( ex ) return callback . call ( wrap , ex ) ;
117+ callback . call ( wrap , null , buf ) ;
118118 } ;
119119
120120 _randomBytes ( buf , offset , size , wrap ) ;
@@ -126,22 +126,22 @@ const RAND_MAX = 0xFFFF_FFFF_FFFF;
126126
127127// Generates an integer in [min, max) range where min is inclusive and max is
128128// exclusive.
129- function randomInt ( min , max , cb ) {
129+ function randomInt ( min , max , callback ) {
130130 // Detect optional min syntax
131131 // randomInt(max)
132- // randomInt(max, cb )
132+ // randomInt(max, callback )
133133 const minNotSpecified = typeof max === 'undefined' ||
134134 typeof max === 'function' ;
135135
136136 if ( minNotSpecified ) {
137- cb = max ;
137+ callback = max ;
138138 max = min ;
139139 min = 0 ;
140140 }
141141
142- const isSync = typeof cb === 'undefined' ;
143- if ( ! isSync && typeof cb !== 'function' ) {
144- throw new ERR_INVALID_CALLBACK ( cb ) ;
142+ const isSync = typeof callback === 'undefined' ;
143+ if ( ! isSync && typeof callback !== 'function' ) {
144+ throw new ERR_INVALID_CALLBACK ( callback ) ;
145145 }
146146 if ( ! NumberIsSafeInteger ( min ) ) {
147147 throw new ERR_INVALID_ARG_TYPE ( 'min' , 'safe integer' , min ) ;
@@ -180,15 +180,15 @@ function randomInt(min, max, cb) {
180180 // Async API
181181 const pickAttempt = ( ) => {
182182 randomBytes ( 6 , ( err , bytes ) => {
183- if ( err ) return cb ( err ) ;
183+ if ( err ) return callback ( err ) ;
184184 const x = bytes . readUIntBE ( 0 , 6 ) ;
185185 // If x > (maxVal - (maxVal % range)), we will get "modulo bias"
186186 if ( x > randLimit ) {
187187 // Try again
188188 return pickAttempt ( ) ;
189189 }
190190 const n = ( x % range ) + min ;
191- cb ( null , n ) ;
191+ callback ( null , n ) ;
192192 } ) ;
193193 } ;
194194
0 commit comments