Buffers and custom encoding examples
See original GitHub issueIs there a canonical set of examples for no string encoding and or custom encodings?
The first example I found was https://github.com/Level/levelup/blob/master/test/inject-encoding-test.js but that requires learning about msgpack-js
.
Second example I found was https://github.com/Level/levelup/issues/412, which described binary
(a string encoding format, aliasing latin1
as per nodejs documentation) somehow returning a Buffer
…
I just want to put(keyBuffer, valueBuffer), get(keyBuffer, (err, valueBuffer) => {})
and it isn’t entirely clear how to do that…
At least with a Buffer
, I could then just push it through something like https://github.com/dominictarr/varstruct for type checking.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Encoding | Protocol Buffers - Google Developers
A protocol buffer message is a series of key-value pairs. The binary version of a message just uses the field's number as the...
Read more >Using Buffers in Node.js - DigitalOcean
Byte encoding is the format of the byte. A buffer in Node.js uses the UTF-8 encoding scheme by default if it's initialized with...
Read more >Managing Typed Buffers
The system supports encoding and decoding for the typed buffer. ... Listing 3-5 Putting Data in a Message Buffer - Example 1.
Read more >Managing groups of resources with argument buffers
This sample code project shows how to specify, encode, set, ... The Metal Shading Language defines argument buffers as custom structures.
Read more >Encoding Infinispan caches and marshalling data
Using alternative and custom marshaller implementations ... For example if you configure cache encoding as text/plain; charset=UTF-8 then REST clients ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@dcousens the encoding here is actually the codec name of your custom-encoding , which represents a pair of
encode
anddecode
functions, and abuffer
option.utf8
andbinary
are just built-in bidirectional codecs, in fact, theres also one calledjson
.Set
keyEncoding: "binary"
andvalueEncoding : "binary"
inoptions
of any main interface method.We can’t document it in levelup because the lifetime depends on the implementation of storage backend. For the
put
method in the defaultleveldown
backend, it is handled by database_async.cc#L175, so its not safe to modify buffer values until callback: