mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
b6da55f0fd
This makes all the parameters of the `fs.read` function, except for `fd` and the callback(when not using as a promise) optional. They will default to sensible defaults. Fixes: https://github.com/nodejs/node/issues/31237 PR-URL: https://github.com/nodejs/node/pull/31402 Reviewed-By: Robert Nagy <ronagy@icloud.com>
20 lines
588 B
JavaScript
20 lines
588 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const fixtures = require('../common/fixtures');
|
|
const fs = require('fs');
|
|
const read = require('util').promisify(fs.read);
|
|
const assert = require('assert');
|
|
const filepath = fixtures.path('x.txt');
|
|
const fd = fs.openSync(filepath, 'r');
|
|
|
|
const expected = Buffer.from('xyz\n');
|
|
const defaultBufferAsync = Buffer.alloc(16384);
|
|
|
|
read(fd, {})
|
|
.then(function({ bytesRead, buffer }) {
|
|
assert.strictEqual(bytesRead, expected.length);
|
|
assert.deepStrictEqual(defaultBufferAsync.length, buffer.length);
|
|
})
|
|
.then(common.mustCall());
|