equinox-web-components
Version:
Equinox design for the web using StencilJS
34 lines (33 loc) • 1.03 kB
JavaScript
var getAbbr = function (str) {
if (str) {
return str.split(' ').length >= 2 ? str.match(/\b(\w)/g).join('') : str.substr(0, 2);
}
else {
return "";
}
};
var deserializeJSON = function (json, component) {
if (component === void 0) { component = 'unknown'; }
try {
json = json.split(""").join("\"");
return JSON.parse(json);
}
catch (e) {
console.log(json, e);
alert("Error while trying to parse JSON in " + component + " component");
}
};
var getPath = function (c, name, v, currentPath, t) {
if (currentPath === void 0) { currentPath = "root"; }
if (t === void 0) { t = currentPath; }
for (var i in c) {
if (i == name && c[i] == v) {
t = currentPath;
}
else if (typeof c[i] == "object") {
return getPath(c[i], name, v, currentPath + "." + i, t);
}
}
return t + "." + name;
};
export { getPath as a, deserializeJSON as d, getAbbr as g };