Support node.js in wasm loader

The latest LTS of Node supports wasm, and this allows us to test
against it, as well as the shells.
This commit is contained in:
Derek Schuff 2017-12-13 15:53:52 -08:00
parent e43efbe62d
commit 4b606b59d4

View File

@ -28,6 +28,20 @@ var heap;
var heap_uint8;
var heap_uint32;
if (typeof process === 'object' && typeof require === 'function') { // This is node.js
// Emulate JS shell behavior used below
const nodeFS = require('fs');
const nodePath = require('path');
var read = function(file_path) {
filename = nodePath['normalize'](file_path);
console.log(file_path);
console.log(filename);
return nodeFS['readFileSync'](filename);
}
var print = console.log;
arguments = process['argv'].slice(2);
}
function setHeap(h) {
heap = h
heap_uint8 = new Uint8Array(heap);