INNER CODE UNIT · TypeScript

pruneStream

okasi/bot-signal · src/behavioral/index.ts:27

function pruneStream(stream: Array<{ t: number }>, cutoff: number): void {
  let firstFresh = 0;
  while (firstFresh < stream.length && stream[firstFresh].t < cutoff) {
    firstFresh += 1;
  }
  if (firstFresh > 0) {
    stream.splice(0, firstFresh);
  }
}

function createEmptySamples(observationMs = 0): Required<BehavioralSamples> {
  return {
    mouseMoves: [],
    scrolls: [],
    keyPresses: [],
    clicks: [],
    touches: [],
    observationMs,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…