func (pr *Reader) TryReadBits(nb uint) (uint, bool) {
	if pr.numBits < nb {
		return 0, false
	}
	val := uint(pr.bufBits & uint64(1<<nb-1))
	pr.bufBits >>= nb
	pr.numBits -= nb
	return val, true
}
TryReadBits attempts to read nb bits using the contents of the bit buffer
alone. It returns the value and whether it succeeded.

This method is designed to be inlined for performance reasons.
package prefix
import (
	"bufio"
	"bytes"
	"encoding/binary"
	"io"
	"strings"
	"github.com/dsnet/compress"
	"github.com/dsnet/compress/internal"
	"github.com/dsnet/compress/internal/errors"
)
type Reader struct {
	Offset int64  
	rd     io.Reader
	byteRd compress.ByteReader      
	bufRd  compress.BufferedReader  
	bufBits   uint64  
	numBits   uint    
	bigEndian bool    
	bufPeek     []byte  
	discardBits int     
	fedBits     uint    
	bb *buffer
	br *bytesReader
	sr *stringReader
	bu *bufio.Reader
}
func (pr *Reader) Init(r io.Reader, bigEndian bool) {
	*pr = Reader{
		rd:        r,
		bigEndian: bigEndian,
		bb: pr.bb,
		br: pr.br,
		sr: pr.sr,
		bu: pr.bu,
	}
	switch rr := r.(type) {
	case *bytes.Buffer:
		if pr.bb == nil {
			pr.bb = new(buffer)
		}
		*pr.bb = buffer{Buffer: rr}
		pr.bufRd = pr.bb
	case *bytes.Reader:
		if pr.br == nil {
			pr.br = new(bytesReader)
		}
		*pr.br = bytesReader{Reader: rr}
		pr.bufRd = pr.br
	case *strings.Reader:
		if pr.sr == nil {
			pr.sr = new(stringReader)
		}
		*pr.sr = stringReader{Reader: rr}
		pr.bufRd = pr.sr
	case compress.BufferedReader:
		pr.bufRd = rr
	case compress.ByteReader:
		pr.byteRd = rr
	default:
		if pr.bu == nil {
			pr.bu = bufio.NewReader(nil)
		}
		pr.bu.Reset(r)
		pr.rd, pr.bufRd = pr.bu, pr.bu
	}
}
func (pr *Reader) BitsRead() int64 {
	offset := 8*pr.Offset - int64(pr.numBits)
	if pr.bufRd != nil {
		discardBits := pr.discardBits + int(pr.fedBits-pr.numBits)
		offset = 8*pr.Offset + int64(discardBits)
	}
	return offset
}
func (pr *Reader) IsBufferedReader() bool {
	return pr.bufRd != nil
}
func (pr *Reader) ReadPads() uint {
	nb := pr.numBits % 8
	val := uint(pr.bufBits & uint64(1<<nb-1))
	pr.bufBits >>= nb
	pr.numBits -= nb
	return val
}
func (pr *Reader) Read(buf []byte) (cnt int, err error) {
	if pr.numBits > 0 {
		if pr.numBits%8 != 0 {
			return 0, errorf(errors.Invalid, "non-aligned bit buffer")
		}
		for cnt = 0; len(buf) > cnt && pr.numBits > 0; cnt++ {
			if pr.bigEndian {
				buf[cnt] = internal.ReverseLUT[byte(pr.bufBits)]
			} else {
				buf[cnt] = byte(pr.bufBits)
			}
			pr.bufBits >>= 8
			pr.numBits -= 8
		}
		return cnt, nil
	}
	if _, err := pr.Flush(); err != nil {
		return 0, err
	}
	cnt, err = pr.rd.Read(buf)
	pr.Offset += int64(cnt)
	return cnt, err
}
func (pr *Reader) ReadOffset(pd *Decoder, rcs RangeCodes) uint {
	rc := rcs[pr.ReadSymbol(pd)]
	return uint(rc.Base) + pr.ReadBits(uint(rc.Len))
}