| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent bc6e719 commit 8a90f55
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -285,7 +285,7 @@ Reads data from the file and stores that in the given buffer. | |||
| 285 | 285 | If the file is not modified concurrently, the end-of-file is reached when the | |
| 286 | 286 | number of bytes read is zero. | |
| 287 | 287 | ||
| 288 | - #### `filehandle.read(options)` | ||
| 288 | + #### `filehandle.read([options])` | ||
| 289 | 289 | <!-- YAML | |
| 290 | 290 | added: | |
| 291 | 291 | - v13.11.0 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -400,6 +400,9 @@ async function open(path, flags, mode) { | |||
| 400 | 400 | async function read(handle, bufferOrOptions, offset, length, position) { | |
| 401 | 401 | let buffer = bufferOrOptions; | |
| 402 | 402 | if (!isArrayBufferView(buffer)) { | |
| 403 | + if (bufferOrOptions === undefined) { | ||
| 404 | + bufferOrOptions = {}; | ||
| 405 | + } | ||
| 403 | 406 | if (bufferOrOptions.buffer) { | |
| 404 | 407 | buffer = bufferOrOptions.buffer; | |
| 405 | 408 | validateBuffer(buffer); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -61,6 +61,13 @@ async function validateLargeRead(options) { | |||
| 61 | 61 | assert.strictEqual(readHandle.bytesRead, 0); | |
| 62 | 62 | } | |
| 63 | 63 | ||
| 64 | + async function validateReadNoParams() { | ||
| 65 | + const filePath = fixtures.path('x.txt'); | ||
| 66 | + const fileHandle = await open(filePath, 'r'); | ||
| 67 | + // Should not throw | ||
| 68 | + await fileHandle.read(); | ||
| 69 | + } | ||
| 70 | + | ||
| 64 | 71 | ||
| 65 | 72 | (async function() { | |
| 66 | 73 | tmpdir.refresh(); | |
@@ -70,4 +77,5 @@ async function validateLargeRead(options) { | |||
| 70 | 77 | await validateRead('', 'read-empty-file-conf', { useConf: true }); | |
| 71 | 78 | await validateLargeRead({ useConf: false }); | |
| 72 | 79 | await validateLargeRead({ useConf: true }); | |
| 80 | + await validateReadNoParams(); | ||
| 73 | 81 | })().then(common.mustCall()); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments