@1771technologies/lytenyte-pro
Version:
Blazingly fast headless React data grid with 100s of features.
20 lines (19 loc) • 631 B
JavaScript
import { applyDeleteActionToTree } from "./apply-delete-action-to-tree.js";
import { applySetActionToTree } from "./apply-set-action-to-tree.js";
import { getParentNodeByPath } from "./get-parent-node-by-path.js";
export function makeAsyncTree() {
const tree = {
kind: "root",
byIndex: new Map(),
byPath: new Map(),
size: 0,
asOf: Date.now(),
};
const api = {
set: (p) => applySetActionToTree(p, tree),
delete: (p) => applyDeleteActionToTree(p, tree),
get: (p) => getParentNodeByPath(tree, p.path),
};
Object.assign(tree, api);
return tree;
}