2.0.0 • Published 8 years ago

tuple-encoding v2.0.0

Weekly downloads
5
License
ISC
Repository
github
Last release
8 years ago

tuple-encoding

Encode/decode an Object as a tuple to preserve order using bytewise

Usage

var tupleEncoding = require('tuple-encoding')

var enc = tupleEncoding(['foo', 'bar'])

enc.encode({foo: 'baz', bar: 'qux'}) // Buffer(' pbaz\u0000pqux\u0000\u0000')

enc.decode(new Buffer(' pbaz\u0000pqux\u0000\u0000', 'binary')) // {foo: 'baz', bar: 'qux'}

API

tupleEncoding : (
  keys: Array<String>
) => {
  encode: Function(obj: Object) => Buffer,
  decode: Function(buf: Buffer) => Object
}

License

ISC