UNPKG

@jovian/type-tools

Version:

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

34 lines 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.completeConfig = void 0; function completeConfig(targetConfig, defaultConfig, directAssign, depth) { if (directAssign === void 0) { directAssign = false; } if (depth === void 0) { depth = 0; } if (depth === 0) { if (targetConfig && typeof targetConfig === 'object' || Array.isArray(targetConfig)) { if (!directAssign) { targetConfig = JSON.parse(JSON.stringify(targetConfig)); } } if (defaultConfig && typeof defaultConfig === 'object' || Array.isArray(defaultConfig)) { defaultConfig = JSON.parse(JSON.stringify(defaultConfig)); } } if (targetConfig === null || targetConfig === undefined) { return defaultConfig; } if (defaultConfig) { if (Array.isArray(defaultConfig)) { return targetConfig; } else if (typeof defaultConfig === 'object') { for (var _i = 0, _a = Object.keys(defaultConfig); _i < _a.length; _i++) { var key = _a[_i]; targetConfig[key] = completeConfig(targetConfig[key], defaultConfig[key], false, depth + 1); } } } return targetConfig; } exports.completeConfig = completeConfig; //# sourceMappingURL=config.util.js.map