MCPcopy Index your code
hub / github.com/immutable-js/immutable-js / listNodeFor

Function listNodeFor

src/List.js:566–579  ·  view source on GitHub ↗

* Returns the leaf `VNode` holding `rawIndex`, or `undefined` when no node is * allocated for it (an all-`undefined` region). * * @param {List} list * @param {number} rawIndex * @returns {VNode | undefined}

(list, rawIndex)

Source from the content-addressed store, hash-verified

564 * @returns {VNode | undefined}
565 */
566function listNodeFor(list, rawIndex) {
567 if (rawIndex >= getTailOffset(list._capacity)) {
568 return list._tail;
569 }
570 if (rawIndex < 1 << (list._level + SHIFT)) {
571 let node = list._root;
572 let level = list._level;
573 while (node && level > 0) {
574 node = node.array[(rawIndex >>> level) & MASK];
575 level -= SHIFT;
576 }
577 return node;
578 }
579}
580
581/**
582 * Validates requested bounds before int32 coercion in setListBounds().

Callers 2

getMethod · 0.85
setListBoundsFunction · 0.85

Calls 1

getTailOffsetFunction · 0.85

Tested by

no test coverage detected