ethers.js/packages/testcases/lib/disk-utils.js

25 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-11-17 07:07:24 +03:00
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
2021-03-08 02:24:04 +03:00
exports.loadData = exports.loadTests = exports.saveTests = void 0;
2020-11-17 07:07:24 +03:00
var fs_1 = __importDefault(require("fs"));
var path_1 = __importDefault(require("path"));
var zlib_1 = __importDefault(require("zlib"));
function saveTests(tag, data) {
var filename = path_1.default.resolve(__dirname, '../testcases', tag + '.json.gz');
fs_1.default.writeFileSync(filename, zlib_1.default.gzipSync(JSON.stringify(data, undefined, ' ') + '\n'));
console.log('Save testcase: ' + filename);
}
exports.saveTests = saveTests;
function loadTests(tag) {
var filename = path_1.default.resolve(__dirname, '../testcases', tag + '.json.gz');
return JSON.parse(zlib_1.default.gunzipSync(fs_1.default.readFileSync(filename)).toString());
}
exports.loadTests = loadTests;
function loadData(filename) {
return fs_1.default.readFileSync(path_1.default.resolve(__dirname, filename));
}
exports.loadData = loadData;
//# sourceMappingURL=disk-utils.js.map