export encodingLength

master
Dominic Tarr 10 years ago
parent 03189c9ca9
commit bb93a5a51b

@ -1,4 +1,5 @@
module.exports = {
encode: require('./encode.js')
, decode: require('./decode.js')
, encodingLength: require('./length.js')
}

@ -0,0 +1,21 @@
var N1 = Math.pow(2, 7)
var N2 = Math.pow(2, 14)
var N3 = Math.pow(2, 21)
var N4 = Math.pow(2, 28)
var N5 = Math.pow(2, 35)
var N6 = Math.pow(2, 42)
var N7 = Math.pow(2, 49)
module.exports = function (value) {
return (
value < N1 ? 1
: value < N2 ? 2
: value < N3 ? 3
: value < N4 ? 4
: value < N5 ? 5
: value < N6 ? 6
: value < N7 ? 7
: 8
)
}
Loading…
Cancel
Save