Permalink
Browse files

Tests now pass.

  • Loading branch information...
1 parent cf10265 commit 1de72b0343851d82f402e3acc0c9e549b527136b @clarkf committed Feb 8, 2012
Showing with 11 additions and 1 deletion.
  1. +11 −1 lib/bencoding.js
View
@@ -19,15 +19,24 @@ BDict.prototype.add = function (key, val) {
this.keys.push(key);
this.vals.push(val);
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) {
return this.vals[i];
};
BDict.prototype.kget = function (i) {
return this.keys[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 () {
var ret = {};
@@ -170,3 +179,4 @@ function encode(obj) {
exports = module.exports;
exports.decode = decode;
exports.encode = encode;
+exports.BDict = BDict;

0 comments on commit 1de72b0

Please sign in to comment.