Merge pull request #32 from dschuff/nodejs

Support node.js in wasm loader
This commit is contained in:
JF Bastien 2017-12-15 15:04:24 -08:00 committed by GitHub
commit 51733cacc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,6 +28,18 @@ 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);
return nodeFS['readFileSync'](filename);
}
var print = console.log;
arguments = process['argv'].slice(2);
}
function setHeap(h) {
heap = h
heap_uint8 = new Uint8Array(heap);