You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
589 B
JavaScript
23 lines
589 B
JavaScript
"use strict";
|
|
|
|
const orderableVarint = require("../../packages/orderable-varint");
|
|
|
|
module.exports = {
|
|
encode: function (number, _asIndexKey) {
|
|
// TODO: Is there any reason to use a different encoding here for the actual value storage? Or is the key encoding already space-efficient enough?
|
|
return {
|
|
value: orderableVarint.encode(number),
|
|
auxiliaryBlob: undefined
|
|
};
|
|
},
|
|
decode: function (buffer, offset) {
|
|
let { value, bytesRead } = orderableVarint.decode(buffer.slice(offset));
|
|
|
|
return {
|
|
bytesRead: bytesRead,
|
|
value: value,
|
|
auxiliaryBlob: undefined
|
|
};
|
|
}
|
|
};
|