Created
June 27, 2016 13:44
-
-
Save sshutovskyi/977facca1156bd6af2c17a0a77e3020f to your computer and use it in GitHub Desktop.
pbf with varint64 as string support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pbf = require 'pbf' | |
ByteBuffer = require 'bytebuffer' | |
Pbf.prototype.readVarint64 = -> | |
res = ByteBuffer.prototype.readVarint64.call( | |
buffer: this.buf, | |
noAssert: true, | |
offset: 0 | |
, this.pos) | |
this.pos += res.length | |
res.value.toString() | |
Pbf.prototype.writeVarint64 = (val) -> | |
this.realloc(10) | |
this.pos += ByteBuffer.prototype.writeVarint64.call({ | |
buffer: this.buf | |
noAssert: true | |
offset: 0 | |
}, val, this.pos) | |
Pbf.prototype.writeVarint64Field = (tag, val) -> | |
this.writeTag(tag, Pbf.Varint) | |
this.writeVarint64(val) | |
module.exports = Pbf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment