def getChildIndex(parent, toFind):
    JS("""
    var count = 0, child = @{{parent}}['firstChild'];
    while (child) {
        if (child == @{{toFind}})
            return count;
        if (child['nodeType'] == 1)
            ++count;
        child = child['nextSibling'];
    }

    return -1;
    """)
Read up to n bytes with at most one read() system call.
dataset/ETHPy150Open pyjs/pyjs/pyjswidgets/pyjamas/DOM.browser.py/getChildIndex--crossover with--dataset/ETHPy150Open AndroBugs/AndroBugs_Framework/tools/modified/androguard/patch/zipfile.py/ZipExtFile.read1