findShardForByte(byteIndex) {
        if (this.shards.length === 0 || byteIndex < 0 || byteIndex >= this.byteLength) return -1;
        // If the buffers have a uniform size, compute the shard directly.
        if (this.bufferUniformSize != null) {
            this.previousShardIndex = Math.floor(byteIndex / this.bufferUniformSize);
            return this.previousShardIndex;
        }
        // If the buffers don't have a uniform size, we need to search for the
        // shard. That means we need a function to check where the byteIndex lies
        // relative to a given shard.
        function check(shard) {
            if (byteIndex < shard.start) return -1;
            if (byteIndex >= shard.end) return 1;
            return 0;
        }
        // For efficiency, try the previous shard first.
        if (check(this.shards[this.previousShardIndex]) === 0) return this.previousShardIndex;
        // Otherwise, use a generic search function.
        // This should almost never end up being used in practice since the weight
        // entries should always be in order.
        const index = search(this.shards, check);
        if (index === -1) return -1;
        this.previousShardIndex = index;
        return this.previousShardIndex;
    }
Get the index of the shard that contains the byte at `byteIndex`.