Skip to content

Commit

Permalink
Tests now pass.
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkf committed Feb 8, 2012
1 parent cf10265 commit 1de72b0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/bencoding.js
Expand Up @@ -19,15 +19,24 @@ BDict.prototype.add = function (key, val) {
this.keys.push(key); this.keys.push(key);
this.vals.push(val); this.vals.push(val);
this.length++; this.length++;
return this;
}; };

BDict.prototype.remove = function (i) {
this.keys.splice(i, 1);
this.vals.splice(i, 1);
this.length--;
return this;
};

BDict.prototype.vget = function (i) { BDict.prototype.vget = function (i) {
return this.vals[i]; return this.vals[i];
}; };
BDict.prototype.kget = function (i) { BDict.prototype.kget = function (i) {
return this.keys[i]; return this.keys[i];
} }
BDict.prototype.get = function (i) { BDict.prototype.get = function (i) {
return [this.keys[i], this.vals[i]]; return this.keys[i] && this.vals[i] ? [this.keys[i], this.vals[i]] : undefined;
}; };
BDict.prototype.toJSON = function () { BDict.prototype.toJSON = function () {
var ret = {}; var ret = {};
Expand Down Expand Up @@ -170,3 +179,4 @@ function encode(obj) {
exports = module.exports; exports = module.exports;
exports.decode = decode; exports.decode = decode;
exports.encode = encode; exports.encode = encode;
exports.BDict = BDict;

0 comments on commit 1de72b0

Please sign in to comment.