Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tests now pass.

  • Loading branch information...
commit 1de72b0343851d82f402e3acc0c9e549b527136b 1 parent cf10265
@clarkf authored
Showing with 11 additions and 1 deletion.
  1. +11 −1 lib/bencoding.js
View
12 lib/bencoding.js
@@ -19,7 +19,16 @@ 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];
};
@@ -27,7 +36,7 @@ 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;
Please sign in to comment.
Something went wrong with that request. Please try again.