-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFileStream.js
26 lines (22 loc) · 846 Bytes
/
FileStream.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
//
//
// This is an InputStream that is loaded from a file all at once
// when you construct the object.
//
var InputStream = require('./InputStream').InputStream;
var isNodeJs = typeof window === 'undefined' && typeof importScripts === 'undefined';
var fs = isNodeJs ? require("fs") : null;
function FileStream(fileName, decodeToUnicodeCodePoints) {
var data = fs.readFileSync(fileName, "utf8");
InputStream.call(this, data, decodeToUnicodeCodePoints);
this.fileName = fileName;
return this;
}
FileStream.prototype = Object.create(InputStream.prototype);
FileStream.prototype.constructor = FileStream;
exports.FileStream = FileStream;