UNPKG

equinox-web-components

Version:

Equinox design for the web using StencilJS

41 lines (40 loc) 1.28 kB
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("&quot;").join("\""); return JSON.parse(json); } catch (e) { console.log(json, e); alert("Error while trying to parse JSON in " + component + " component"); } }; var findPath = function (obj, name, val, currentPath) { if (currentPath === void 0) { currentPath = ''; } var matchingPath; if (!obj || typeof obj !== 'object') return; if (obj[name] === val) return currentPath + "'" + name + "'"; for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) { var key = _a[_i]; if (key === name && obj[key] === val) { matchingPath = currentPath; } else { matchingPath = findPath(obj[key], name, val, currentPath + "'" + key + "'"); } if (matchingPath) break; } return matchingPath; }; export { deserializeJSON as d, findPath as f, getAbbr as g };