0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-fs-readv-promisify.js
Lucas Holmquist 8e080c14cf fs: support util.promisify for fs.readv
PR-URL: https://github.com/nodejs/node/pull/33590
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-05-30 10:17:31 -07:00

19 lines
536 B
JavaScript

'use strict';
const common = require('../common');
const fixtures = require('../common/fixtures');
const fs = require('fs');
const readv = require('util').promisify(fs.readv);
const assert = require('assert');
const filepath = fixtures.path('x.txt');
const fd = fs.openSync(filepath, 'r');
const expected = [Buffer.from('xyz\n')];
readv(fd, expected)
.then(function({ bytesRead, buffers }) {
assert.deepStrictEqual(bytesRead, expected[0].length);
assert.deepStrictEqual(buffers, expected);
})
.then(common.mustCall());