UNPKG

attranslate

Version:

Text Translator for Websites and Apps

30 lines (29 loc) 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FlatJson = void 0; const parse_utils_1 = require("../common/parse-utils"); const managed_json_1 = require("../common/managed-json"); class FlatJson { readTFile(args) { const json = (0, managed_json_1.readManagedJson)(args.path); const tMap = new Map(); for (const key of Object.keys(json)) { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore const value = json[key]; if (typeof value !== "string" && value !== null) { (0, parse_utils_1.logParseError)(`Property '${key}' is not a string or null`, args); } tMap.set(key, value); } return Promise.resolve(tMap); } writeTFile(args) { const flatJson = {}; args.tSet.forEach((value, key) => { flatJson[key] = value; }); (0, managed_json_1.writeManagedJson)({ path: args.path, object: flatJson }); } } exports.FlatJson = FlatJson;