mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 19:46:36 +00:00
perf(data-table): early return if path in object when resolving path
This commit is contained in:
parent
0a6b8fc112
commit
79b662a5f9
1 changed files with 4 additions and 2 deletions
|
@ -146,11 +146,13 @@
|
||||||
.map(({ key }, i) => ({ key, id: key }))
|
.map(({ key }, i) => ({ key, id: key }))
|
||||||
.reduce((a, c) => ({ ...a, [c.key]: c.id }), {})
|
.reduce((a, c) => ({ ...a, [c.key]: c.id }), {})
|
||||||
);
|
);
|
||||||
const resolvePath = (object, path) =>
|
const resolvePath = (object, path) => {
|
||||||
path
|
if (path in object) return object[path];
|
||||||
|
return path
|
||||||
.split(/[\.\[\]\'\"]/)
|
.split(/[\.\[\]\'\"]/)
|
||||||
.filter((p) => p)
|
.filter((p) => p)
|
||||||
.reduce((o, p) => (o && typeof o === "object" ? o[p] : o), object);
|
.reduce((o, p) => (o && typeof o === "object" ? o[p] : o), object);
|
||||||
|
};
|
||||||
|
|
||||||
setContext("DataTable", {
|
setContext("DataTable", {
|
||||||
sortHeader,
|
sortHeader,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue