UNPKG

@pipedream/agentset

Version:

Pipedream Agentset Components

34 lines (31 loc) 655 B
export const slugify = (str) => { str = str.replace(/^\s+|\s+$/g, ""); str = str.toLowerCase(); str = str.replace(/[^a-z0-9 -]/g, "") .replace(/\s+/g, "-") .replace(/-+/g, "-"); return str; }; 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; };