@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.
49 lines (48 loc) • 1.34 kB
JavaScript
import { generate } from "shortid";
export function isNumber(value) {
return typeof value === "number";
}
export function isNullOrUndefined(obj) {
return obj === undefined || obj === null;
}
export function generateId() {
return generate();
}
export function isEmpty(value) {
return !value || value.length === 0;
}
export function isEmptyArray(array) {
return !Array.isArray(array) || isEmpty(array);
}
export function nameOf(_) {
return (key) => key;
}
export function existValueInEnum(type, value) {
return (Object.keys(type)
.filter((k) => isNaN(Number(k)))
.filter((k) => type[k] === value).length > 0);
}
export 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;
}
export function callSafe(fn, ...args) {
if (typeof fn === "function") {
return fn(...args);
}
}
export function clone(objectToClone) {
try {
const cloned = JSON.parse(JSON.stringify(objectToClone));
return cloned;
}
catch (error) {
return null;
}
}