lut.js
function findNodeFromPos(pos) {
    const lut = this.begins;
    assert(is.finitenumber(pos) && pos >= 0);

    let left = 0;
    let right = lut.length - 1;
    while (left < right) {
        const mid = Math.floor((left + right) / 2);
        assert(mid >= 0 && mid < lut.length);
        if (pos > lut[mid].range[0]) {
            left = mid + 1;
        }
        else {
            right = mid;
        }
    }
    if (left > right) {
        assert(last(lut).range[0] < pos);
        return null;
    }

    const found = left;
    const foundPos = lut[found].range[0];
    assert(foundPos >= pos);
    if (found >= 1) {
        const prevPos = lut[found - 1].range[0];
        assert(prevPos < pos);
    }

    return lut[found];
}
function findNodeFromPos(pos) {
    const lut = this.begins;
    assert(is.finitenumber(pos) && pos >= 0);

    let left = 0;
    let right = lut.length - 1;
    while (left < right) {
        const mid = Math.floor((left + right) / 2);
        assert(mid >= 0 && mid < lut.length);
        if (pos > lut[mid].range[0]) {
            left = mid + 1;
        }
        else {
            right = mid;
        }
    }
    if (left > right) {
        assert(last(lut).range[0] < pos);
        return null;
    }

    const found = left;
    const foundPos = lut[found].range[0];
    assert(foundPos >= pos);
    if (found >= 1) {
        const prevPos = lut[found - 1].range[0];
        assert(prevPos < pos);
    }

    return lut[found];
}
function findNodeFromPos ( pos ) { const lut = this . begins ; assert ( is . finitenumber ( pos ) && pos >= 0 ) ; let left = 0 ; let right = lut . length - 1 ; while ( left < right ) { const mid = Math . floor ( ( left + right ) / 2 ) ; assert ( mid >= 0 && mid < lut . length ) ; if ( pos > lut [ mid ] . range [ 0 ] ) { left = mid + 1 ; } else { right = mid ; } } if ( left > right ) { assert ( last ( lut ) . range [ 0 ] < pos ) ; return null ; } const found = left ; const foundPos = lut [ found ] . range [ 0 ] ; assert ( foundPos >= pos ) ; if ( found >= 1 ) { const prevPos = lut [ found - 1 ] . range [ 0 ] ; assert ( prevPos < pos ) ; } return lut [ found ] ; }
binary search lut to find node beginning at pos or as close after pos as possible. null if none
binary search lut to find node beginning at pos or as close after pos as possible . null if none