@azure/core-amqp
Version:
Common library for amqp based azure sdks like @azure/event-hubs.
92 lines (91 loc) • 2.85 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 utils_exports = {};
__export(utils_exports, {
defaultCancellableLock: () => defaultCancellableLock,
delay: () => delay,
getGlobalProperty: () => getGlobalProperty,
isLoopbackAddress: () => isLoopbackAddress,
isNumber: () => isNumber,
isString: () => isString,
parseConnectionString: () => parseConnectionString
});
module.exports = __toCommonJS(utils_exports);
var import_lock = require("./lock.js");
var import_core_util = require("@azure/core-util");
function parseConnectionString(connectionString) {
const output = {};
const parts = connectionString.trim().split(";");
for (let part of parts) {
part = part.trim();
if (part === "") {
continue;
}
const splitIndex = part.indexOf("=");
if (splitIndex === -1) {
throw new Error(
"Connection string malformed: each part of the connection string must have an `=` assignment."
);
}
const key = part.substring(0, splitIndex).trim();
if (key === "") {
throw new Error("Connection string malformed: missing key for assignment");
}
const value = part.substring(splitIndex + 1).trim();
output[key] = value;
}
return output;
}
const defaultCancellableLock = new import_lock.CancellableAsyncLockImpl();
async function delay(delayInMs, abortSignal, abortErrorMsg, value) {
await (0, import_core_util.delay)(delayInMs, {
abortSignal,
abortErrorMsg
});
if (value !== void 0) {
return value;
}
}
function isLoopbackAddress(address) {
return /^(.*:\/\/)?(127\.[\d.]+|[0:]+1|localhost)/.test(address.toLowerCase());
}
function isString(s) {
return typeof s === "string";
}
function isNumber(n) {
return typeof n === "number";
}
function getGlobalProperty(key) {
try {
const g = globalThis;
return g?.[key];
} catch {
return void 0;
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
defaultCancellableLock,
delay,
getGlobalProperty,
isLoopbackAddress,
isNumber,
isString,
parseConnectionString
});
//# sourceMappingURL=utils.js.map