Merge pull request #952 from ericvergnaud/clarify-nodejs-usage

simpler and clearer identification of runtime process (nodejs vs browser)
This commit is contained in:
Terence Parr 2015-07-07 09:57:06 -07:00
commit 84588075de
1 changed files with 3 additions and 6 deletions

View File

@ -34,12 +34,9 @@
// when you construct the object.
//
var InputStream = require('./InputStream').InputStream;
try {
var fs = require("fs");
} catch(ex) {
// probably running from browser, no "Node.js/fs" makes sense
}
var isNodeJs = typeof window === 'undefined';
var fs = isNodeJs ? require("fs") : null;
function FileStream(fileName) {
var data = fs.readFileSync(fileName, "utf8");
InputStream.call(this, data);