Write a generic TypeScript function that will use a binary search to find the index of the first item in an array for which a partition callback returns true or return -1 otherwise.
system
ek saamaanya tipscript fnction likhen jo ek sarani main pehle item ke suchakank ko khojane ke liye ek binary khoj kaa upyog karegaa, jiske liye ek vibhaajan colbach sahi yaa ritern -1 anyathaa lautaata he.
user
yahaan ek tipscript fnction he jo pehle item ke suchakank ko khojane ke liye ek binary khoj kaa upyog karata he jiske liye ek vibhaajan colbach sahi lautataa he:

niryaat fnction binaryphindpartishan <t> (
    Array: Readonly t [],
    vibhaajan: (item: tii) => bulian
): sankhya {
    if (array.length === 0) {
        vaapasi -1;
    }
    LOW = 0, ucch = ARRAY.LENGTH - 1;
    jabaki (ucch> kam) {
        const mid = nimna + math.floor ((ucch - nimna) / 2);
        if (vibhaajan (sarani [madhya])) {
            ucch = madhya;
        } anya {
            kam = madhya + 1;
        }
    }

    lauten vibhaajan (sarani [kam])?nimna: -1;
}
assistant
<|system|>
</s>
<|user|>
ek saamaanya tipscript fnction likhen jo ek sarani main pehle item ke suchakank ko khojane ke liye ek binary khoj kaa upyog karegaa, jiske liye ek vibhaajan colbach sahi yaa ritern -1 anyathaa lautaata he.</s>
<|assistant|>
yahaan ek tipscript fnction he jo pehle item ke suchakank ko khojane ke liye ek binary khoj kaa upyog karata he jiske liye ek vibhaajan colbach sahi lautataa he:

niryaat fnction binaryphindpartishan <t> (
    Array: Readonly t [],
    vibhaajan: (item: tii) => bulian
): sankhya {
    if (array.length === 0) {
        vaapasi -1;
    }
    LOW = 0, ucch = ARRAY.LENGTH - 1;
    jabaki (ucch> kam) {
        const mid = nimna + math.floor ((ucch - nimna) / 2);
        if (vibhaajan (sarani [madhya])) {
            ucch = madhya;
        } anya {
            kam = madhya + 1;
        }
    }

    lauten vibhaajan (sarani [kam])?nimna: -1;
}</s>
