web-stream-kit
    Preparing search index...

    Function indexOfPattern

    High-performance, zero-dependency Uint8Array binary manipulation utilities.

    • Finds the first index of a sequence pattern within a target Uint8Array.

      Parameters

      • source: Uint8Array

        The source buffer to search within.

      • pattern: Uint8Array

        The sequence of bytes to find.

      • start: number = 0

        The starting index in source to begin searching from. Defaults to 0.

      Returns number

      The zero-based index of the first match, or -1 if not found.

      const source = new Uint8Array([10, 20, 30, 40]);
      const pattern = new Uint8Array([20, 30]);
      const idx = indexOfPattern(source, pattern); // 1