Skip to content

Commit b1414a6

Browse files
committed
decode merged
1 parent 5b6e5fc commit b1414a6

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

lib/decode.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ decode.dictionary = function() {
5757
var dict = {}
5858

5959
while( decode.data[decode.position] !== 0x65 ) {
60-
dict[ decode.next() ] = decode.next()
60+
dict[ decode.bytes() ] = decode.next()
6161
}
6262

6363
decode.position++
@@ -85,7 +85,7 @@ decode.list = function() {
8585
decode.integer = function() {
8686

8787
var end = decode.find( 0x65 )
88-
var number = decode.data.slice( decode.position+1, end )
88+
var number = +decode.data.toString('ascii', decode.position+1, end )
8989

9090
decode.position += end + 1 - decode.position
9191

@@ -96,15 +96,14 @@ decode.integer = function() {
9696
decode.bytes = function() {
9797

9898
var sep = decode.find( 0x3A )
99-
var length = +decode.data.slice( decode.position, sep ).toString()
100-
var sepl = ++sep + length
101-
var bytes = decode.data.slice( sep, sepl )
99+
var length = +decode.data.toString('ascii', decode.position, sep )
100+
var end = ++sep + length
102101

103-
decode.position += sepl - decode.position
102+
decode.position += end - decode.position
104103

105104
return decode.encoding
106-
? bytes.toString( decode.encoding )
107-
: bytes
105+
? decode.data.toString(decode.encoding, sep, end )
106+
: decode.data.slice( sep, end )
108107

109108
}
110109

0 commit comments

Comments
 (0)