import { PlayerInstant } from "./index" ; export function findInstantIndex ( instants , time ) { let low = 0 , high = instants . length ; while ( low + 1 < high ) { const mid = ( low + high ) / 2 | 0 ; const state = instants [ mid ] ; if ( state . t <= time ) { low = mid ; } else { high = mid ; } } let instant = instants [ low ] ; if ( instant ) { while ( low + 1 < instants . length ) { const nextInstant = instants [ low + 1 ] ; if ( nextInstant . t !== instant . t ) break ; low += 1 ; } } return low ; } export function findInstant ( instants , time ) { const index = findInstantIndex ( instants , time ) ; return instants [ index ] ; }