@emqx/shared-ui-utils
Advanced tools
Comparing version 0.0.8 to 0.0.9
export * from './objectUtils'; | ||
export * from './jsonUtils'; | ||
export * from './format'; |
@@ -1,18 +0,18 @@ | ||
const l = (r, e = [], t = {}) => { | ||
const i = (r, t = [], e = {}) => { | ||
if (typeof r == "object" && !Array.isArray(r) && r !== null) | ||
for (const n of Object.keys(r)) | ||
l(r[n], e.concat(n), t); | ||
i(r[n], t.concat(n), e); | ||
else | ||
t[e.join(".")] = r; | ||
return t; | ||
}, i = (r) => { | ||
e[t.join(".")] = r; | ||
return e; | ||
}, f = (r) => { | ||
if (Object(r) !== r && !Array.isArray(r)) | ||
return r; | ||
const e = /\.?([^.[\]]+)|\[(\d+)\]/g, t = {}; | ||
const t = /\.?([^.[\]]+)|\[(\d+)\]/g, e = {}; | ||
try { | ||
for (const n in r) { | ||
let c = t, s = "", o; | ||
for (; o = e.exec(n); ) | ||
c = c[s] || (c[s] = o[2] ? [] : {}), s = o[2] || o[1]; | ||
c[s] = r[n]; | ||
let o = e, s = "", c; | ||
for (; c = t.exec(n); ) | ||
o = o[s] || (o[s] = c[2] ? [] : {}), s = c[2] || c[1]; | ||
o[s] = r[n]; | ||
} | ||
@@ -22,4 +22,4 @@ } catch (n) { | ||
} | ||
return t[""] || t; | ||
}, y = (r) => Object.keys(r).length === 0, a = (r) => { | ||
return e[""] || e; | ||
}, l = (r) => Object.keys(r).length === 0, y = (r) => { | ||
try { | ||
@@ -30,25 +30,33 @@ return JSON.parse(r); | ||
} | ||
}, f = (r, e) => { | ||
}, u = (r, t) => { | ||
try { | ||
return typeof r == "string" ? r : JSON.stringify(r, null, e); | ||
} catch (t) { | ||
return console.error(t), "stringify error"; | ||
return typeof r == "string" ? r : JSON.stringify(r, null, t); | ||
} catch (e) { | ||
return console.error(e), "stringify error"; | ||
} | ||
}, u = (r) => { | ||
}, a = (r) => { | ||
if (typeof r != "string") | ||
return !1; | ||
try { | ||
const e = JSON.parse(r); | ||
return typeof e == "object" && e !== null; | ||
const t = JSON.parse(r); | ||
return typeof t == "object" && t !== null; | ||
} catch { | ||
return !1; | ||
} | ||
}, p = (r) => { | ||
if (typeof r != "number" || isNaN(r) || r < 0) | ||
throw new Error("Invalid input: input should be a non-negative number"); | ||
if (r === 0) | ||
return "0 Bytes"; | ||
const t = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], e = Math.floor(Math.log(r) / Math.log(1024)); | ||
return `${(r / 1024 ** e).toFixed(1)} ${t[e]}`; | ||
}; | ||
export { | ||
l as flattenObject, | ||
y as isEmptyObj, | ||
u as isJSONString, | ||
a as parseJSONSafely, | ||
f as stringifyObjSafely, | ||
i as unflattenObject | ||
i as flattenObject, | ||
p as formatSizeUnit, | ||
l as isEmptyObj, | ||
a as isJSONString, | ||
y as parseJSONSafely, | ||
u as stringifyObjSafely, | ||
f as unflattenObject | ||
}; |
{ | ||
"name": "@emqx/shared-ui-utils", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"homepage": "https://emqx.io", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17608
8
125