@@ -14,7 +14,7 @@ const assert = require('assert');
1414const tmpDir = tmpdir . path ;
1515
1616async function read ( fileHandle , buffer , offset , length , position , options ) {
17- return options . useConf ?
17+ return options ? .useConf ?
1818 fileHandle . read ( { buffer, offset, length, position } ) :
1919 fileHandle . read ( buffer , offset , length , position ) ;
2020}
@@ -96,6 +96,21 @@ async function validateReadLength(len) {
9696 assert . strictEqual ( bytesRead , len ) ;
9797}
9898
99+ async function validateReadWithNoOptions ( byte ) {
100+ const buf = Buffer . alloc ( byte ) ;
101+ const filePath = fixtures . path ( 'x.txt' ) ;
102+ const fileHandle = await open ( filePath , 'r' ) ;
103+ let response = await fileHandle . read ( buf ) ;
104+ assert . strictEqual ( response . bytesRead , byte ) ;
105+ response = await read ( fileHandle , buf , 0 , undefined , 0 ) ;
106+ assert . strictEqual ( response . bytesRead , byte ) ;
107+ response = await read ( fileHandle , buf , 0 , null , 0 ) ;
108+ assert . strictEqual ( response . bytesRead , byte ) ;
109+ response = await read ( fileHandle , buf , 0 , undefined , 0 , { useConf : true } ) ;
110+ assert . strictEqual ( response . bytesRead , byte ) ;
111+ response = await read ( fileHandle , buf , 0 , null , 0 , { useConf : true } ) ;
112+ assert . strictEqual ( response . bytesRead , byte ) ;
113+ }
99114
100115( async function ( ) {
101116 tmpdir . refresh ( ) ;
@@ -109,4 +124,6 @@ async function validateReadLength(len) {
109124 await validateReadWithPositionZero ( ) ;
110125 await validateReadLength ( 0 ) ;
111126 await validateReadLength ( 1 ) ;
127+ await validateReadWithNoOptions ( 0 ) ;
128+ await validateReadWithNoOptions ( 1 ) ;
112129} ) ( ) . then ( common . mustCall ( ) ) ;
0 commit comments