@@ -4454,16 +4454,12 @@ const a = new Uint32Array(10);
44544454console .log (Buffer .from (randomFillSync (a).buffer ,
44554455 a .byteOffset , a .byteLength ).toString (' hex' ));
44564456
4457- const b = new Float64Array ( 10 );
4457+ const b = new DataView ( new ArrayBuffer ( 10 ) );
44584458console .log (Buffer .from (randomFillSync (b).buffer ,
44594459 b .byteOffset , b .byteLength ).toString (' hex' ));
44604460
4461- const c = new DataView (new ArrayBuffer (10 ));
4462- console .log (Buffer .from (randomFillSync (c).buffer ,
4463- c .byteOffset , c .byteLength ).toString (' hex' ));
4464-
4465- const d = new ArrayBuffer (10 );
4466- console .log (Buffer .from (randomFillSync (d)).toString (' hex' ));
4461+ const c = new ArrayBuffer (10 );
4462+ console .log (Buffer .from (randomFillSync (c)).toString (' hex' ));
44674463```
44684464
44694465``` cjs
@@ -4475,16 +4471,12 @@ const a = new Uint32Array(10);
44754471console .log (Buffer .from (randomFillSync (a).buffer ,
44764472 a .byteOffset , a .byteLength ).toString (' hex' ));
44774473
4478- const b = new Float64Array ( 10 );
4474+ const b = new DataView ( new ArrayBuffer ( 10 ) );
44794475console .log (Buffer .from (randomFillSync (b).buffer ,
44804476 b .byteOffset , b .byteLength ).toString (' hex' ));
44814477
4482- const c = new DataView (new ArrayBuffer (10 ));
4483- console .log (Buffer .from (randomFillSync (c).buffer ,
4484- c .byteOffset , c .byteLength ).toString (' hex' ));
4485-
4486- const d = new ArrayBuffer (10 );
4487- console .log (Buffer .from (randomFillSync (d)).toString (' hex' ));
4478+ const c = new ArrayBuffer (10 );
4479+ console .log (Buffer .from (randomFillSync (c)).toString (' hex' ));
44884480```
44894481
44904482### ` crypto.randomFill(buffer[, offset][, size], callback) `
@@ -4560,6 +4552,12 @@ randomFill(buf, 5, 5, (err, buf) => {
45604552Any ` ArrayBuffer ` , ` TypedArray ` , or ` DataView ` instance may be passed as
45614553` buffer ` .
45624554
4555+ While this includes instances of ` Float32Array ` and ` Float64Array ` , this
4556+ function should not be used to generate random floating-point numbers. The
4557+ result may contain ` +Infinity ` , ` -Infinity ` , and ` NaN ` , and even if the array
4558+ contains finite numbers only, they are not drawn from a uniform random
4559+ distribution and have no meaningful lower or upper bounds.
4560+
45634561``` mjs
45644562const {
45654563 randomFill ,
@@ -4572,22 +4570,15 @@ randomFill(a, (err, buf) => {
45724570 .toString (' hex' ));
45734571});
45744572
4575- const b = new Float64Array ( 10 );
4573+ const b = new DataView ( new ArrayBuffer ( 10 ) );
45764574randomFill (b, (err , buf ) => {
45774575 if (err) throw err;
45784576 console .log (Buffer .from (buf .buffer , buf .byteOffset , buf .byteLength )
45794577 .toString (' hex' ));
45804578});
45814579
4582- const c = new DataView ( new ArrayBuffer (10 ) );
4580+ const c = new ArrayBuffer (10 );
45834581randomFill (c, (err , buf ) => {
4584- if (err) throw err;
4585- console .log (Buffer .from (buf .buffer , buf .byteOffset , buf .byteLength )
4586- .toString (' hex' ));
4587- });
4588-
4589- const d = new ArrayBuffer (10 );
4590- randomFill (d, (err , buf ) => {
45914582 if (err) throw err;
45924583 console .log (Buffer .from (buf).toString (' hex' ));
45934584});
@@ -4605,22 +4596,15 @@ randomFill(a, (err, buf) => {
46054596 .toString (' hex' ));
46064597});
46074598
4608- const b = new Float64Array ( 10 );
4599+ const b = new DataView ( new ArrayBuffer ( 10 ) );
46094600randomFill (b, (err , buf ) => {
46104601 if (err) throw err;
46114602 console .log (Buffer .from (buf .buffer , buf .byteOffset , buf .byteLength )
46124603 .toString (' hex' ));
46134604});
46144605
4615- const c = new DataView ( new ArrayBuffer (10 ) );
4606+ const c = new ArrayBuffer (10 );
46164607randomFill (c, (err , buf ) => {
4617- if (err) throw err;
4618- console .log (Buffer .from (buf .buffer , buf .byteOffset , buf .byteLength )
4619- .toString (' hex' ));
4620- });
4621-
4622- const d = new ArrayBuffer (10 );
4623- randomFill (d, (err , buf ) => {
46244608 if (err) throw err;
46254609 console .log (Buffer .from (buf).toString (' hex' ));
46264610});
0 commit comments