UNPKG

@1771technologies/lytenyte-pro

Version:

Blazingly fast headless React data grid with 100s of features.

21 lines (20 loc) 674 B
import { ROOT_LEAF_PREFIX } from "../+constants.async-tree.js"; export function checkSetActionItemKeysAreUnique(p) { const seenKeys = new Set(); const seenPaths = new Set(); if (!p.items?.length) return true; for (let i = p.items.length - 1; i >= 0; i--) { const item = p.items[i]; if (seenKeys.has(item.relIndex)) { return false; } const pathId = item.kind === "leaf" ? `${p.path.at(-1) ?? ROOT_LEAF_PREFIX}#${item.relIndex}` : item.path; if (seenPaths.has(pathId)) { return false; } seenPaths.add(pathId); seenKeys.add(item.relIndex); } return true; }