UNPKG

@jovian/type-tools

Version:

TypeTools is a Typescript library for providing extensible tooling runtime validations and type helpers.

31 lines 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.destorParseFromSerializedFormat = exports.DESTOR = void 0; var env_profile_1 = require("./env.profile"); var destorTarget = { LIST: destorParseFromSerializedFormat(process.env.DESTOR_LIST) ? destorParseFromSerializedFormat(process.env.DESTOR_LIST) : [] }; if (!env_profile_1.globalRoot.DESTOR) { env_profile_1.globalRoot.DESTOR = destorTarget; } exports.DESTOR = new Proxy(env_profile_1.globalRoot.DESTOR, {}); function destorParseFromSerializedFormat(v) { if (!v || typeof v !== 'string') { return null; } v = v.trim(); if (v.startsWith('[') && v.endsWith(']')) { return JSON.parse(v); } try { return JSON.parse(Buffer.from(v, 'base64').toString('utf8')); } catch (e) { var message = "unexpected serialized destor input format, only JSON or Base64 are allowed. Supplied value:\n".concat(v); e.message = message; console.error(e); } } exports.destorParseFromSerializedFormat = destorParseFromSerializedFormat; //# sourceMappingURL=env.destor.js.map