Current Folder
This commit is contained in:
1 parent
8b3382289b
commit
cfcada880d
4379 files changed
No files matched your search
-26
@@ -1,26 +0,0 @@
|
||||
module.exports = encode
|
||||
|
||||
var MSB = 0x80
|
||||
, REST = 0x7F
|
||||
, MSBALL = ~REST
|
||||
, INT = Math.pow(2, 31)
|
||||
|
||||
function encode(num, out, offset) {
|
||||
out = out || []
|
||||
offset = offset || 0
|
||||
var oldOffset = offset
|
||||
|
||||
while(num >= INT) {
|
||||
out[offset++] = (num & 0xFF) | MSB
|
||||
num /= 128
|
||||
}
|
||||
while(num & MSBALL) {
|
||||
out[offset++] = (num & 0xFF) | MSB
|
||||
num >>>= 7
|
||||
}
|
||||
out[offset] = num | 0
|
||||
|
||||
encode.bytes = offset - oldOffset + 1
|
||||
|
||||
return out
|
||||
}
|
||||
Reference in new issue
Block a user