• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4const fs = require('fs');
5const fsPromises = fs.promises;
6const path = require('path');
7const tmpdir = require('../common/tmpdir');
8const assert = require('assert');
9const tmpDir = tmpdir.path;
10
11tmpdir.refresh();
12
13const dest = path.resolve(tmpDir, 'tmp.txt');
14// Use a file size larger than `kReadFileMaxChunkSize`.
15const buffer = Buffer.from('012'.repeat(2 ** 14));
16
17(async () => {
18  for (const Constructor of [Uint8Array, Uint16Array, Uint32Array]) {
19    const array = new Constructor(buffer.buffer);
20    await fsPromises.writeFile(dest, array);
21    const data = await fsPromises.readFile(dest);
22    assert.deepStrictEqual(data, buffer);
23  }
24})().then(common.mustCall());
25