UNPKG

jet-paths

Version:

Preprend strings in an object with the value from a base-key.

21 lines 820 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const DEFAULT_BASE_KEY = 'Base'; function setupPaths(pathObj, baseKey) { return setupPathsHelper(pathObj, (baseKey !== null && baseKey !== void 0 ? baseKey : DEFAULT_BASE_KEY), ''); } function setupPathsHelper(parentObj, baseKey, baseUrl) { const url = (baseUrl + parentObj[baseKey]), keys = Object.keys(parentObj), retVal = { [baseKey]: url }; for (const key of keys) { const pval = parentObj[key]; if (key !== baseKey && typeof pval === 'string') { retVal[key] = (url + pval); } else if (typeof pval === 'object') { retVal[key] = setupPathsHelper(pval, baseKey, url); } } return retVal; } exports.default = setupPaths; //# sourceMappingURL=setupPaths.js.map