Diff

Differences From Artifact [5685c81b13]:

To Artifact [3231551b1f]:


    11     11   // 0 - 11, 1 - 110, 2 - 1100, 3 - 1101, 4 - 11000
    12     12   package fibonacci
    13     13   
    14     14   import (
    15     15   	"io"
    16     16   )
    17     17   
           18  +// Alias type with methods for encoding and decoding integers
    18     19   type Numbers []uint64
    19     20   
    20     21   var (
    21     22   	// Used for encoding and decoding byte values
    22     23   	bytesCodec = New(14)
    23     24   )
    24     25   
................................................................................
    75     76   
    76     77   		value >>= 1
    77     78   		length++
    78     79   	}
    79     80   	return result + f[length] - 1, length + 1
    80     81   }
    81     82   
    82         -func Writer(target io.Writer) io.Writer {
           83  +// Returns a fibonacci encoder over the provided io.Writer
           84  +func Encoder(target io.Writer) io.Writer {
    83     85   	var enc encoder
    84     86   	enc.target = target
    85     87   	return &enc
    86     88   }
    87     89   
    88     90   type encoder struct {
    89     91   	target    io.Writer
    90     92   	remaining byte
    91     93   	length    byte
    92     94   }
    93     95   
           96  +// Implements io.Writer
    94     97   func (e *encoder) Write(input []byte) (int, error) {
    95     98   	var (
    96     99   		total int
    97    100   		err   error
    98    101   	)
    99    102   
   100    103   	// Flush on a nil slice
................................................................................
   151    154   
   152    155   		// Account for the processed input byte
   153    156   		total++
   154    157   	}
   155    158   	return total, err
   156    159   }
   157    160   
   158         -func Reader(source io.Reader) io.Reader {
          161  +// Returns a fibonacci decoder over the provided io.Reader
          162  +func Decoder(source io.Reader) io.Reader {
   159    163   	var dec decoder
   160    164   	dec.source = source
   161    165   	return &dec
   162    166   }
   163    167   
   164    168   type decoder struct {
   165    169   	source io.Reader
   166    170   	buffer uint64
   167    171   	at     byte
   168    172   }
   169    173   
          174  +// Implements io.Reader
   170    175   func (d *decoder) Read(output []byte) (int, error) {
   171    176   	var (
   172    177   		total int
   173    178   		err   error
   174    179   	)
   175    180   
   176    181   start: