@@ -2,10 +2,11 @@ // as specified by RFC1978 - PPP Predictor Compression Protocol package predictor import ( bits "0dev.org/bits" + iou "0dev.org/ioutil" "io" ) type context struct { table [1 << 16]byte @@ -116,25 +117,17 @@ } return write } -// A function type alias so that it can have methods attached to it -type decompressor func([]byte) (int, error) - -// Required to implement io.Reader -func (r decompressor) Read(output []byte) (int, error) { - return r(output) -} - // Returns an io.Reader implementation that wraps the provided io.Reader // and decompresses data according to the predictor algorithm func Decompressor(reader io.Reader) io.Reader { var ctx context ctx.input = make([]byte, 0, 8) - return decompressor(func(output []byte) (int, error) { + return iou.ReaderFunc(func(output []byte) (int, error) { var ( err error flags, predicted byte rc, total, copied int )