af-consul
Advanced tools
Comparing version 3.0.34 to 3.0.35
@@ -26,3 +26,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isObject = exports.sleep = exports.getPackageJson = exports.toMills = exports.minimizeCache = exports.serviceConfigDiff = exports.parseTags = exports.parseMeta = exports.substitutePercentBracket = exports.parseBoolean = exports.removeAroundQuotas = void 0; | ||
exports.isObject = exports.sleep = exports.getPackageJson = exports.toMills = exports.minimizeCache = exports.serviceConfigDiff = exports.parseTags = exports.parseMeta = exports.substitute = exports.substitutePercentBracket = exports.parseBoolean = exports.removeAroundQuotas = void 0; | ||
const fs = __importStar(require("fs")); | ||
@@ -50,15 +50,21 @@ const removeAroundQuotas = (str) => { | ||
exports.parseBoolean = parseBoolean; | ||
const substitutePercentBracket = (meta, data) => { | ||
const re = /%?{([^}]+)}/g; | ||
const substitutePercentBracket = (v, data) => { | ||
const re = /%{([^}]+)}/g; | ||
let result = v; | ||
const matches = [...v.matchAll(re)]; | ||
matches.forEach(([found, propName]) => { | ||
const substitution = String(data[propName] || ''); | ||
result = result.replace(found, substitution); | ||
}); | ||
return result; | ||
}; | ||
exports.substitutePercentBracket = substitutePercentBracket; | ||
const substitute = (meta, data) => { | ||
Object.entries(meta).forEach(([k, v]) => { | ||
if (typeof v === 'string') { | ||
const matches = [...v.matchAll(re)]; | ||
matches.forEach(([found, propName]) => { | ||
const substitution = String(data[propName] || ''); | ||
meta[k] = meta[k].replace(found, substitution); | ||
}); | ||
meta[k] = (0, exports.substitutePercentBracket)(v, data); | ||
} | ||
}); | ||
}; | ||
exports.substitutePercentBracket = substitutePercentBracket; | ||
exports.substitute = substitute; | ||
const parseMeta = (m, data) => { | ||
@@ -105,3 +111,3 @@ const metaData = {}; | ||
} | ||
(0, exports.substitutePercentBracket)(metaData, data); | ||
(0, exports.substitute)(metaData, data); | ||
return metaData; | ||
@@ -108,0 +114,0 @@ }; |
@@ -21,11 +21,16 @@ import * as fs from 'fs'; | ||
}; | ||
export const substitutePercentBracket = (meta, data) => { | ||
const re = /%?{([^}]+)}/g; | ||
export const substitutePercentBracket = (v, data) => { | ||
const re = /%{([^}]+)}/g; | ||
let result = v; | ||
const matches = [...v.matchAll(re)]; | ||
matches.forEach(([found, propName]) => { | ||
const substitution = String(data[propName] || ''); | ||
result = result.replace(found, substitution); | ||
}); | ||
return result; | ||
}; | ||
export const substitute = (meta, data) => { | ||
Object.entries(meta).forEach(([k, v]) => { | ||
if (typeof v === 'string') { | ||
const matches = [...v.matchAll(re)]; | ||
matches.forEach(([found, propName]) => { | ||
const substitution = String(data[propName] || ''); | ||
meta[k] = meta[k].replace(found, substitution); | ||
}); | ||
meta[k] = substitutePercentBracket(v, data); | ||
} | ||
@@ -75,3 +80,3 @@ }); | ||
} | ||
substitutePercentBracket(metaData, data); | ||
substitute(metaData, data); | ||
return metaData; | ||
@@ -78,0 +83,0 @@ }; |
import { ICache, IConsulServiceInfo, IRegisterConfig } from '../interfaces'; | ||
export declare const removeAroundQuotas: (str: string) => string; | ||
export declare const parseBoolean: (bv: any) => boolean; | ||
export declare const substitutePercentBracket: (meta: any, data: any) => void; | ||
export declare const substitutePercentBracket: (v: string, data: object) => string; | ||
export declare const substitute: (meta: any, data: any) => void; | ||
export declare const parseMeta: (m: string | object | undefined, data: object) => any; | ||
@@ -6,0 +7,0 @@ export declare const parseTags: (t: any) => string[]; |
{ | ||
"name": "af-consul", | ||
"version": "3.0.34", | ||
"version": "3.0.35", | ||
"description": "A highly specialized function library", | ||
@@ -5,0 +5,0 @@ "main": "./dist/cjs/src/index.js", |
@@ -25,11 +25,17 @@ import * as fs from 'fs'; | ||
export const substitutePercentBracket = (meta: any, data: any): void => { | ||
const re = /%?{([^}]+)}/g; | ||
export const substitutePercentBracket = (v: string, data: object): string => { | ||
const re = /%{([^}]+)}/g; | ||
let result: string = v; | ||
const matches = [...v.matchAll(re)]; | ||
matches.forEach(([found, propName]) => { | ||
const substitution = String(data[propName] || ''); | ||
result = result.replace(found, substitution); | ||
}); | ||
return result; | ||
}; | ||
export const substitute = (meta: any, data: any): void => { | ||
Object.entries(meta).forEach(([k, v]) => { | ||
if (typeof v === 'string') { | ||
const matches = [...v.matchAll(re)]; | ||
matches.forEach(([found, propName]) => { | ||
const substitution = String(data[propName] || ''); | ||
meta[k] = meta[k].replace(found, substitution); | ||
}); | ||
meta[k] = substitutePercentBracket(v, data); | ||
} | ||
@@ -78,3 +84,3 @@ }); | ||
} | ||
substitutePercentBracket(metaData, data); | ||
substitute(metaData, data); | ||
return metaData; | ||
@@ -81,0 +87,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
325133
4882