@emqx/shared-ui-utils
Advanced tools
Comparing version 0.0.10 to 0.0.11
export * from './objectUtils'; | ||
export * from './jsonUtils'; | ||
export * from './format'; | ||
export * from './download'; |
@@ -1,60 +0,64 @@ | ||
const i = (r, t = [], e = {}) => { | ||
if (typeof r == "object" && !Array.isArray(r) && r !== null) | ||
for (const n of Object.keys(r)) | ||
i(r[n], t.concat(n), e); | ||
const i = (e, r = [], n = {}) => { | ||
if (typeof e == "object" && !Array.isArray(e) && e !== null) | ||
for (const t of Object.keys(e)) | ||
i(e[t], r.concat(t), n); | ||
else | ||
e[t.join(".")] = r; | ||
return e; | ||
}, f = (r) => { | ||
if (Object(r) !== r && !Array.isArray(r)) | ||
return r; | ||
const t = /\.?([^.[\]]+)|\[(\d+)\]/g, e = {}; | ||
n[r.join(".")] = e; | ||
return n; | ||
}, l = (e) => { | ||
if (Object(e) !== e && !Array.isArray(e)) | ||
return e; | ||
const r = /\.?([^.[\]]+)|\[(\d+)\]/g, n = {}; | ||
try { | ||
for (const n in r) { | ||
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]; | ||
for (const t in e) { | ||
let o = n, c = "", s; | ||
for (; s = r.exec(t); ) | ||
o = o[c] || (o[c] = s[2] ? [] : {}), c = s[2] || s[1]; | ||
o[c] = e[t]; | ||
} | ||
} catch (n) { | ||
console.error(n); | ||
} catch (t) { | ||
console.error(t); | ||
} | ||
return e[""] || e; | ||
}, l = (r) => Object.keys(r).length === 0, y = (r) => { | ||
return n[""] || n; | ||
}, a = (e) => Object.keys(e).length === 0, y = (e) => { | ||
try { | ||
return JSON.parse(r); | ||
return JSON.parse(e); | ||
} catch { | ||
console.error("An error occurred while parsing the JSON string"); | ||
} | ||
}, u = (r, t) => { | ||
}, u = (e, r) => { | ||
try { | ||
return typeof r == "string" ? r : JSON.stringify(r, null, t); | ||
} catch (e) { | ||
return console.error(e), "stringify error"; | ||
return typeof e == "string" ? e : JSON.stringify(e, null, r); | ||
} catch (n) { | ||
return console.error(n), "stringify error"; | ||
} | ||
}, a = (r) => { | ||
if (typeof r != "string") | ||
}, f = (e) => { | ||
if (typeof e != "string") | ||
return !1; | ||
try { | ||
const t = JSON.parse(r); | ||
return typeof t == "object" && t !== null; | ||
const r = JSON.parse(e); | ||
return typeof r == "object" && r !== null; | ||
} catch { | ||
return !1; | ||
} | ||
}, p = (r) => { | ||
if (typeof r != "number" || isNaN(r) || r < 0) | ||
}, d = (e) => { | ||
if (typeof e != "number" || isNaN(e) || e < 0) | ||
throw new Error("Invalid input: input should be a non-negative number"); | ||
if (r === 0) | ||
if (e === 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]}`; | ||
const r = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], n = Math.floor(Math.log(e) / Math.log(1024)); | ||
return `${(e / 1024 ** n).toFixed(1)} ${r[n]}`; | ||
}, p = (e, r) => { | ||
const n = window.URL.createObjectURL(new Blob([e])), t = document.createElement("a"); | ||
t.style.display = "none", t.href = n, t.download = r, document.body.appendChild(t), t.click(), document.body.removeChild(t); | ||
}; | ||
export { | ||
p as createDownloadBlobLink, | ||
i as flattenObject, | ||
p as formatSizeUnit, | ||
l as isEmptyObj, | ||
a as isJSONString, | ||
d as formatSizeUnit, | ||
a as isEmptyObj, | ||
f as isJSONString, | ||
y as parseJSONSafely, | ||
u as stringifyObjSafely, | ||
f as unflattenObject | ||
l as unflattenObject | ||
}; |
{ | ||
"name": "@emqx/shared-ui-utils", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"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
18528
139