1 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
2 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
3 | };
|
4 | (function (factory) {
|
5 | if (typeof module === "object" && typeof module.exports === "object") {
|
6 | var v = factory(require, exports);
|
7 | if (v !== undefined) module.exports = v;
|
8 | }
|
9 | else if (typeof define === "function" && define.amd) {
|
10 | define(["require", "exports", "fs", "./parse"], factory);
|
11 | }
|
12 | })(function (require, exports) {
|
13 | "use strict";
|
14 | Object.defineProperty(exports, "__esModule", { value: true });
|
15 | exports.readFile = void 0;
|
16 | var fs_1 = __importDefault(require("fs"));
|
17 | var parse_1 = require("./parse");
|
18 | function readFile(aFile, callback) {
|
19 | fs_1.default.readFile(aFile, function (err, contents) {
|
20 | if (err) {
|
21 | return callback(err);
|
22 | }
|
23 | var results;
|
24 | try {
|
25 | results = (0, parse_1.parse)(contents, aFile);
|
26 | }
|
27 | catch (error) {
|
28 | return callback(error instanceof Error
|
29 | ? error
|
30 | : new Error("failed to read file " + aFile));
|
31 | }
|
32 | callback(null, results);
|
33 | });
|
34 | }
|
35 | exports.readFile = readFile;
|
36 | });
|