func (w *Writer) Close() (err error) {
	if len(w.leaves) > 2 {
		if err = w.bw.WriteBits(w.valueMap[eofValue].Code()); err != nil {
			return
		}
	}
	return w.bw.Close()
}
Close closes the Huffman writer, properly sending EOF.
If the underlying io.Writer implements io.Closer,
it will be closed after sending EOF.
package hufio
import (
	"io"
	"github.com/icza/bitio"
	"github.com/icza/huffman"
)
type Writer struct {
	*symbols
	bw *bitio.Writer
}
func NewWriter(out io.Writer) *Writer {
	return NewWriterOptions(out, nil)
}
func NewWriterOptions(out io.Writer, o *Options) *Writer {
	o = checkOptions(o)
	return &Writer{symbols: newSymbols(o), bw: bitio.NewWriter(out)}
}
func (w *Writer) Write(p []byte) (n int, err error) {
	for i, v := range p {
		if err = w.WriteByte(v); err != nil {
			return i, err
		}
	}
	return len(p), nil
}
func (w *Writer) WriteByte(b byte) (err error) {
	value := huffman.ValueType(b)
	node := w.valueMap[value]
	if node == nil {
		if err = w.bw.WriteBits(w.valueMap[newValue].Code()); err != nil {
			return
		}
		if err = w.bw.WriteByte(b); err != nil {
			return
		}
		w.insert(value)
	} else {
		if err = w.bw.WriteBits(node.Code()); err != nil {
			return
		}
		w.update(node)
	}
	return
}