I am looking for a way to structure my JavaScript test and read a simple binary WebAssembly file i.e. wasm from the local file system i.e. not in the browser application without using third party tools like node. So far i have found that this can be done with node fs object. but I do not want to load such a huge tool only to read one file. i.e.
I am looking of the way to replace a node call like this
var file = fs.readFileSync('myTestFile.wasm');
var buffer = new Uint8Array(file).buffer;
how will that look like in a JavaScript without node and without browser?
All JavaScript engines have a non-browser build of their source code which runs on the command line. JSC has
jsc
, V8 hasd8
, SpiderMonkeyjs
, and ChakraCorech
.Those are used by each browser vendor for testing, and inevitably we sometimes need to read ASCII or binary files. There's unfortunately not really a standard for such functionality, but I've found that this works for my purpose:
This will only work in node.js or an engine's shell, and not in a browser.