perf(data-table): early return if path in object when resolving path

This commit is contained in:
Eric Liu 2022-06-05 10:50:54 -07:00
commit 79b662a5f9

View file

@ -146,11 +146,13 @@
.map(({ key }, i) => ({ key, id: key }))
.reduce((a, c) => ({ ...a, [c.key]: c.id }), {})
);
const resolvePath = (object, path) =>
path
const resolvePath = (object, path) => {
if (path in object) return object[path];
return path
.split(/[\.\[\]\'\"]/)
.filter((p) => p)
.reduce((o, p) => (o && typeof o === "object" ? o[p] : o), object);
};
setContext("DataTable", {
sortHeader,