Files
node/test/parallel/test-module-binding.js
T
Ben Noordhuis 0fdd88a374 module: speed up package.json parsing more
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>
2017-11-15 12:01:20 +01:00

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'));
}