@pipedream/ninjaone
Version:
Pipedream NinjaOne Components
29 lines (26 loc) • 580 B
JavaScript
export const parseObject = (obj) => {
if (!obj) return undefined;
if (Array.isArray(obj)) {
return obj.map((item) => {
if (typeof item === "string") {
try {
return JSON.parse(item);
} catch (e) {
return item;
}
}
return item;
});
}
if (typeof obj === "string") {
try {
return JSON.parse(obj);
} catch (e) {
return obj;
}
}
return obj;
};
export const normalCase = (s) =>
s?.replace (/^[-_]*(.)/, (_, c) => c.toUpperCase())
.replace (/[-_]+(.)/g, (_, c) => " " + c);