deanlandolt/bytewise — pull request #6 by dominictarr (2013-08-15 09:23:15+00:00)
Title: support new levelup encoding pattern

in the next release, levelup will support custom encodings.

https://github.com/rvagg/node-levelup/pull/149

this pull request means that bytewise can be dropped in to an encoding field as a custom encoding.

``` js
levelup(path, {keyEncoding: require('bytewise'), valueEncoding: 'binary'})
```
The important addition is `buffer: true` which tells levelup to retrive a binary value when doing a read to a custom encoded field.

Also, I've added `bytewise-hex` encoding:
``` js
levelup(path, {keyEncoding: require('bytewise/hex'), valueEncoding: 'binary'})
```
this is only a few extra lines, but if you need a string, then you need hex.
(base64 is not useful, because order is not consistent)

Currently, this is needed for sublevel - however, soon I will refactor sublevel to support binary keyEncodings.