configuru
Version:
Manage the configuration of your Nodejs application with multiple environments and custom preferences, utilizing Configuru in CI and development as well!
51 lines • 2.1 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.JSONC = exports.isObject = exports.identity = exports.parseBool = exports.anonymize = void 0;
var jsonParser = __importStar(require("jsonc-parser"));
var anonymize = function (val) { return (val === '' ? val : '[redacted]'); };
exports.anonymize = anonymize;
var parseBool = function (x) {
return x === 'false' || x === '0' ? false : Boolean(x);
};
exports.parseBool = parseBool;
var identity = function (x) { return x; };
exports.identity = identity;
var isObject = function (x) {
return typeof x === 'object' &&
Object.prototype.toString.call(x) === '[object Object]';
};
exports.isObject = isObject;
exports.JSONC = {
parse: function (text) {
var errors = [];
var parsed = jsonParser.parse(text, errors);
if (errors.length) {
throw new SyntaxError("".concat(jsonParser.printParseErrorCode(errors[0].error), " at position ").concat(errors[0].offset));
}
return parsed;
},
};
//# sourceMappingURL=helpers.js.map