File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 1+ var Dict = require ( "./dict" )
2+
13/**
24 * Decodes bencoded data.
35 *
@@ -57,10 +59,10 @@ decode.dictionary = function() {
5759
5860 decode . position ++
5961
60- var dict = { }
62+ var dict = new Dict ( )
6163
6264 while ( decode . data [ decode . position ] !== 0x65 ) {
63- dict [ decode . bytes ( ) ] = decode . next ( )
65+ dict . binarySet ( decode . bytes ( ) , decode . next ( ) )
6466 }
6567
6668 decode . position ++
Original file line number Diff line number Diff line change 1+ var Dict = module . exports = function Dict ( ) {
2+ Object . defineProperty ( this , "_keys" , {
3+ enumerable : false ,
4+ value : [ ] ,
5+ } )
6+ }
7+
8+ Dict . prototype . binaryKeys = function binaryKeys ( ) {
9+ return this . _keys . slice ( )
10+ }
11+
12+ Dict . prototype . binarySet = function binarySet ( key , value ) {
13+ this . _keys . push ( key )
14+
15+ this [ key ] = value
16+ }
You can’t perform that action at this time.
0 commit comments