mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
Move the logic from the previous commit to C++ land in order to avoid creating a new string when we know we won't parse it anyway. PR-URL: https://github.com/nodejs/node/pull/15767 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
15 lines
582 B
JavaScript
15 lines
582 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const fixtures = require('../common/fixtures');
|
|
const { internalModuleReadFile } = process.binding('fs');
|
|
const { readFileSync } = require('fs');
|
|
const { strictEqual } = require('assert');
|
|
|
|
strictEqual(internalModuleReadFile('nosuchfile'), undefined);
|
|
strictEqual(internalModuleReadFile(fixtures.path('empty.txt')), '');
|
|
strictEqual(internalModuleReadFile(fixtures.path('empty-with-bom.txt')), '');
|
|
{
|
|
const filename = fixtures.path('require-bin/package.json');
|
|
strictEqual(internalModuleReadFile(filename), readFileSync(filename, 'utf8'));
|
|
}
|