amourlinguini
Version:
A JSON-based translation file manager.
37 lines • 1.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TypeMappers = void 0;
var url_1 = require("url");
var utils_1 = require("./utils/");
var stringTm = function (jsonValue) { return utils_1.StringUtils.join(jsonValue, '\n'); };
var booleanTm = function (jsonValue) { return Boolean(jsonValue); };
var numberTm = function (jsonValue) { return Number(jsonValue); };
var bigIntTm = function (jsonValue) { return BigInt(jsonValue); };
var dateTm = function (jsonValue) { return new Date(jsonValue); };
var regExpTm = function (jsonValue) {
if (typeof jsonValue === 'string') {
var match = /^\/(.*)\/([^\/]*)$/.exec(jsonValue);
if (!match) {
return new RegExp('');
}
return new RegExp(match[1], match[2]);
}
else {
return new RegExp(jsonValue.pattern, jsonValue.flags);
}
};
var urlTm = function (jsonValue) { return new url_1.URL(jsonValue); };
/**
* Built-in Type Mappers
*/
var TypeMappers = {
String: stringTm,
Boolean: booleanTm,
Number: numberTm,
BigInt: bigIntTm,
Date: dateTm,
RegExp: regExpTm,
URL: urlTm,
};
exports.TypeMappers = TypeMappers;
//# sourceMappingURL=type-mappers.js.map