"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.readJSONDir = exports.readJSON = void 0;
const lib_types_1 = require("@shardeum-foundation/lib-types");
const fs_1 = require("fs");
const path_1 = require("path");
const readJSON = (filename) => {
    const file = (0, fs_1.readFileSync)(filename).toString();
    const config = lib_types_1.Utils.safeJsonParse(file);
    return config;
};
exports.readJSON = readJSON;
const readJSONDir = (dir) => {
    // => filesObj
    const filesObj = {};
    (0, fs_1.readdirSync)(dir).forEach((fileName) => {
        const name = fileName.split('.')[0];
        // eslint-disable-next-line security/detect-object-injection
        filesObj[name] = (0, exports.readJSON)((0, path_1.join)(dir, fileName));
    });
    return filesObj;
};
exports.readJSONDir = readJSONDir;
//# sourceMappingURL=json.js.map