From 09e5d93a1514f791d94c4edccd7109030277f1ff Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 22 Jun 2016 04:35:56 -0700 Subject: [PATCH] bst: batch op. --- lib/bcoin/bst.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/bcoin/bst.js b/lib/bcoin/bst.js index e0550c79..54c482e0 100644 --- a/lib/bcoin/bst.js +++ b/lib/bcoin/bst.js @@ -610,7 +610,7 @@ function Batch(tree, options) { Batch.prototype.put = function(key, value) { assert(this.tree, 'Already written.'); - this.ops.push({ type: 'put', key: key, value: value }); + this.ops.push(new BatchOp('put', key, value)); return this; }; @@ -621,7 +621,7 @@ Batch.prototype.put = function(key, value) { Batch.prototype.del = function del(key) { assert(this.tree, 'Already written.'); - this.ops.push({ type: 'del', key: key }); + this.ops.push(new BatchOp('del', key)); return this; }; @@ -666,6 +666,21 @@ Batch.prototype.clear = function clear() { return this; }; +/** + * Batch Operation + * @constructor + * @private + * @param {String} type + * @param {Buffer} key + * @param {Buffer|null} value + */ + +function BatchOp(type, key, value) { + this.type = type; + this.key = key; + this.value = value; +} + /** * Iterator * @constructor