svg-layout-designer-react/public/workers/worker.js
Eric Nguyen c256a76e01 Merged PR 212: Optimize FindChildrenById from O(n) to O(1)
Optimize FindChildrenById from O(n) to O(1):
- Deprecate FindContainerByIdDFS
- Container: Replace Children to string[]
- Add HashMap to IHistoryState that contains all containers

To access a container by id now cost O(1) without any additional cost

+ Implement CICD for SVGLibs
2022-10-12 09:39:54 +00:00

26 lines
509 B
JavaScript

onmessage = (e) => {
const data = JSON.stringify(e.data.editorState, getCircularReplacer(), e.data.spaces);
postMessage(data);
};
const getCircularReplacer = () => {
return (key, value) => {
if (key === 'parent') {
return;
}
if (key === 'containers') {
return Array.from(value.entries());
}
if (key === 'symbols') {
return Array.from(value.entries());
}
if (key === 'linkedContainers') {
return Array.from(value);
}
return value;
};
};