This commit is contained in:
Christopher Jeffrey 2016-07-03 14:00:44 -07:00
parent e41a44b9a4
commit e80785654c
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -29,6 +29,11 @@ function RBT(location, options) {
if (!(this instanceof RBT))
return new RBT(location, options);
if (typeof location !== 'string') {
options = location;
location = null;
}
if (!options)
options = {};
@ -804,7 +809,7 @@ RBTNode.prototype.copy = function copy() {
RBTNode.prototype.inspect = function inspect() {
return {
key: this.key.toString('ascii'),
key: stringify(this.key),
value: this.value.toString('hex'),
color: this.color === RED ? 'red' : 'black',
left: this.left,
@ -882,7 +887,7 @@ function RBTData(key, value) {
RBTData.prototype.inspect = function inspect() {
return {
key: this.key.toString('ascii'),
key: stringify(this.key),
value: this.value.toString('hex')
};
};
@ -1051,7 +1056,7 @@ Iterator.prototype.next = function(callback) {
value = DUMMY;
if (this.options.keyAsBuffer === false)
key = key.toString('ascii');
key = stringify(key);
if (this.options.valueAsBuffer === false)
value = value.toString('utf8');
@ -1112,6 +1117,12 @@ Iterator.prototype.end = function end(callback) {
SENTINEL = new RBTSentinel();
function stringify(value) {
if (Buffer.isBuffer(value))
return value.toString('ascii');
return value;
}
/*
* Expose
*/