UNPKG

@1771technologies/lytenyte-pro

Version:

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

19 lines (18 loc) 784 B
const invalidItemKeySize = "Invalid set action items, 'relIndex' must be less than parent size"; export function checkSetActionItemKeysFit(p, pathNode) { // If we are not adding any items, then the items definitely fit - since 0 fits in 0. if (!p.items?.length) return true; // Grab the node size. The action may be updating the size, so we check for that first, otherwise // we check if the current size. const size = p.size ?? pathNode.size; // We check the relative item indices. They should be within the size. for (let i = p.items.length - 1; i >= 0; i--) { const x = p.items[i]; if (x.relIndex >= size) { console.error(invalidItemKeySize, p, pathNode); return false; } } return true; }