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
26 lines
509 B
JavaScript
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;
|
|
};
|
|
};
|