@emqx/shared-ui-utils
Advanced tools
Comparing version 0.0.7 to 0.0.8
export * from './objectUtils'; | ||
export * from './jsonUtils'; |
@@ -1,27 +0,52 @@ | ||
const o = (e, c = [], t = {}) => { | ||
if (typeof e == "object" && !Array.isArray(e) && e !== null) | ||
for (const r of Object.keys(e)) | ||
o(e[r], c.concat(r), t); | ||
const l = (r, e = [], t = {}) => { | ||
if (typeof r == "object" && !Array.isArray(r) && r !== null) | ||
for (const n of Object.keys(r)) | ||
l(r[n], e.concat(n), t); | ||
else | ||
t[c.join(".")] = e; | ||
t[e.join(".")] = r; | ||
return t; | ||
}, a = (e) => { | ||
if (Object(e) !== e && !Array.isArray(e)) | ||
return e; | ||
const c = /\.?([^.[\]]+)|\[(\d+)\]/g, t = {}; | ||
}, i = (r) => { | ||
if (Object(r) !== r && !Array.isArray(r)) | ||
return r; | ||
const e = /\.?([^.[\]]+)|\[(\d+)\]/g, t = {}; | ||
try { | ||
for (const r in e) { | ||
let n = t, l = "", s; | ||
for (; s = c.exec(r); ) | ||
n = n[l] || (n[l] = s[2] ? [] : {}), l = s[2] || s[1]; | ||
n[l] = e[r]; | ||
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]; | ||
} | ||
} catch (r) { | ||
console.error(r); | ||
} catch (n) { | ||
console.error(n); | ||
} | ||
return t[""] || t; | ||
}, y = (r) => Object.keys(r).length === 0, a = (r) => { | ||
try { | ||
return JSON.parse(r); | ||
} catch { | ||
console.error("An error occurred while parsing the JSON string"); | ||
} | ||
}, f = (r, e) => { | ||
try { | ||
return typeof r == "string" ? r : JSON.stringify(r, null, e); | ||
} catch (t) { | ||
return console.error(t), "stringify error"; | ||
} | ||
}, u = (r) => { | ||
if (typeof r != "string") | ||
return !1; | ||
try { | ||
const e = JSON.parse(r); | ||
return typeof e == "object" && e !== null; | ||
} catch { | ||
return !1; | ||
} | ||
}; | ||
export { | ||
o as flattenObject, | ||
a as unflattenObject | ||
l as flattenObject, | ||
y as isEmptyObj, | ||
u as isJSONString, | ||
a as parseJSONSafely, | ||
f as stringifyObjSafely, | ||
i as unflattenObject | ||
}; |
@@ -14,1 +14,7 @@ /** | ||
export declare const stringifyObjSafely: (obj: Record<string, any>, tabSpaces?: number) => string; | ||
/** | ||
* Checks if a given string is a valid JSON string. | ||
* @param str - The string to be checked. | ||
* @returns A boolean indicating whether the string is a valid JSON string or not. | ||
*/ | ||
export declare const isJSONString: (str: string) => boolean; |
@@ -25,1 +25,7 @@ /** | ||
}) => any; | ||
/** | ||
* Checks if an object is empty. | ||
* @param obj - The object to check. | ||
* @returns True if the object is empty, false otherwise. | ||
*/ | ||
export declare const isEmptyObj: (obj: Record<any, any>) => boolean; |
{ | ||
"name": "@emqx/shared-ui-utils", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"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
16594
108