@azure/cosmos
Version:
Microsoft Azure Cosmos DB Service Node.js SDK for NOSQL API
58 lines (57 loc) • 2.13 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var queryMetricsUtils_exports = {};
__export(queryMetricsUtils_exports, {
isNumeric: () => isNumeric,
parseDelimitedString: () => parseDelimitedString,
timeSpanFromMetrics: () => timeSpanFromMetrics
});
module.exports = __toCommonJS(queryMetricsUtils_exports);
var import_timeSpan = require("./timeSpan.js");
function parseDelimitedString(delimitedString) {
if (delimitedString == null) {
throw new Error("delimitedString is null or undefined");
}
const metrics = {};
const headerAttributes = delimitedString.split(";");
for (const attribute of headerAttributes) {
const attributeKeyValue = attribute.split("=");
if (attributeKeyValue.length !== 2) {
throw new Error("recieved a malformed delimited string");
}
const attributeKey = attributeKeyValue[0];
const attributeValue = parseFloat(attributeKeyValue[1]);
metrics[attributeKey] = attributeValue;
}
return metrics;
}
function timeSpanFromMetrics(metrics, key) {
if (key in metrics) {
return import_timeSpan.TimeSpan.fromMilliseconds(metrics[key]);
}
return import_timeSpan.TimeSpan.zero;
}
function isNumeric(input) {
return !isNaN(parseFloat(input)) && isFinite(input);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
isNumeric,
parseDelimitedString,
timeSpanFromMetrics
});