Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.
/ codec Public archive

Commit 3fc3f36

Browse files
committed
Merge pull request #10 from Level/add/none-encoding
Add "none" encoding
2 parents 8f855a3 + 6b4c328 commit 3fc3f36

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,20 @@ var codec = new Codec(db.options);
7070
}
7171
```
7272

73+
Currently supported encodings:
74+
75+
- utf8
76+
- json
77+
- binary
78+
- hex
79+
- ascii
80+
- base64
81+
- ucs2
82+
- ucs-2
83+
- utf16le
84+
- utf-16le
85+
- none (bypass level-codec)
86+
7387
## Publishers
7488

7589
* [@juliangruber](https://github.com/juliangruber)

lib/encodings.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ exports.binary = {
2828
type: 'binary'
2929
};
3030

31-
exports.id = {
31+
exports.none = {
3232
encode: function(data){
3333
return data;
3434
},
@@ -39,6 +39,8 @@ exports.id = {
3939
type: 'id'
4040
};
4141

42+
exports.id = exports.none;
43+
4244
var bufferEncodings = [
4345
'hex',
4446
'ascii',

test/kv.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ test('encode key', function(t){
1515
});
1616
t.equal(buf.toString(), '686579');
1717

18+
buf = codec.encodeKey({ foo: 'bar' }, {
19+
keyEncoding: 'none'
20+
});
21+
t.deepEqual(buf, { foo: 'bar' });
22+
1823
t.end();
1924
});
2025

0 commit comments

Comments
 (0)