blob: 8fafd66b81f36b05e38e6f51e7e4f9b7c3bc3fe9 [file] [log] [blame]
/**
* @license
* Copyright 2019 The Emscripten Authors
* SPDX-License-Identifier: MIT
*/
readBinary = (filename) => {
// We need to re-wrap `file://` strings to URLs.
filename = isFileURI(filename) ? new URL(filename) : filename;
var ret = fs.readFileSync(filename);
#if ASSERTIONS
assert(Buffer.isBuffer(ret));
#endif
return ret;
};
readAsync = async (filename, binary = true) => {
// See the comment in the `readBinary` function.
filename = isFileURI(filename) ? new URL(filename) : filename;
var ret = fs.readFileSync(filename, binary ? undefined : 'utf8');
#if ASSERTIONS
assert(binary ? Buffer.isBuffer(ret) : typeof ret == 'string');
#endif
return ret;
};