@glue42/bbg-market-data
Version:
A high-level API that wraps existing Glue42 Bloomberg Bridge Market Data interop methods. The API is based on the jBloomberg open source wrapper.
63 lines • 2.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.clone = exports.callSafe = exports.extractErrorMessage = exports.existValueInEnum = exports.nameOf = exports.isEmptyArray = exports.isEmpty = exports.generateId = exports.isNullOrUndefined = exports.isNumber = void 0;
const shortid_1 = require("shortid");
function isNumber(value) {
return typeof value === "number";
}
exports.isNumber = isNumber;
function isNullOrUndefined(obj) {
return obj === undefined || obj === null;
}
exports.isNullOrUndefined = isNullOrUndefined;
function generateId() {
return shortid_1.generate();
}
exports.generateId = generateId;
function isEmpty(value) {
return !value || value.length === 0;
}
exports.isEmpty = isEmpty;
function isEmptyArray(array) {
return !Array.isArray(array) || isEmpty(array);
}
exports.isEmptyArray = isEmptyArray;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function nameOf(_) {
return (key) => key;
}
exports.nameOf = nameOf;
function existValueInEnum(type, value) {
return (Object.keys(type)
.filter((k) => isNaN(Number(k)))
.filter((k) => type[k] === value).length > 0);
}
exports.existValueInEnum = existValueInEnum;
function extractErrorMessage(error, alternative) {
const stringError = typeof error === "string"
? error
: typeof error.message === "string"
? error.message
: typeof alternative != "string"
? alternative
: JSON.stringify(error);
return stringError;
}
exports.extractErrorMessage = extractErrorMessage;
function callSafe(fn, ...args) {
if (typeof fn === "function") {
return fn(...args);
}
}
exports.callSafe = callSafe;
function clone(objectToClone) {
try {
const cloned = JSON.parse(JSON.stringify(objectToClone));
return cloned;
}
catch (error) {
return null;
}
}
exports.clone = clone;
//# sourceMappingURL=utils.js.map