pipeproc
Version:
Multi-process log processing for nodejs
57 lines (56 loc) • 1.67 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.ZERO_TONE = "0000000000000000";
exports.FIRST_TONE = "0000000000000001";
exports.SECOND_TONE = "0000000000000002";
function incrementCurrentTone(currentTone) {
return zeroPad(parseInt(currentTone) + 1);
}
exports.incrementCurrentTone = incrementCurrentTone;
function decrementCurrentTone(currentTone) {
const tone = parseInt(currentTone) - 1;
if (tone <= 0) {
return exports.ZERO_TONE;
}
else {
return zeroPad(tone);
}
}
exports.decrementCurrentTone = decrementCurrentTone;
function convertToClientId(nodeId) {
if (!nodeId)
return nodeId;
return nodeId.split("..").map(function (id) {
const idParts = id.split("-");
const parsedId = parseInt(idParts[1]);
if (parsedId <= 0) {
return `${idParts[0]}-0`;
}
else {
return `${idParts[0]}-${parsedId - 1}`;
}
}).join("..");
}
exports.convertToClientId = convertToClientId;
function convertRangeParams(param) {
if (!param)
return param;
if (param.includes(":")) {
const parsed = parseInt(param.replace(":", ""));
return `:${parsed + 1}`;
}
else if (param.includes("-")) {
const parts = param.split("-");
return `${parts[0]}-${incrementCurrentTone(parts[1])}`;
}
else {
return param;
}
}
exports.convertRangeParams = convertRangeParams;
function zeroPad(input) {
const parsed = String(input);
const zerosToFill = 16 - parsed.length;
return (new Array(zerosToFill)).fill("0").join("") + parsed;
}
exports.zeroPad = zeroPad;
;