diff --git a/lib/db/backends-browser.js b/lib/db/backends-browser.js index 5920f6ff..457bb04a 100644 --- a/lib/db/backends-browser.js +++ b/lib/db/backends-browser.js @@ -7,10 +7,10 @@ 'use strict'; var level = require('./level'); -var MemoryDB = require('./memorydb'); +var MemDB = require('./memdb'); exports.get = function get(name) { if (name === 'memory') - return MemoryDB; + return MemDB; return level; }; diff --git a/lib/db/backends.js b/lib/db/backends.js index 32f8f647..a96976c7 100644 --- a/lib/db/backends.js +++ b/lib/db/backends.js @@ -8,7 +8,7 @@ exports.get = function get(name) { if (name === 'memory') - return require('./memorydb'); + return require('./memdb'); try { return require(name); diff --git a/lib/db/index.js b/lib/db/index.js index 95ec31bf..b9e99e26 100644 --- a/lib/db/index.js +++ b/lib/db/index.js @@ -6,4 +6,4 @@ exports.LDB = require('./ldb'); exports.LowlevelUp = require('./lowlevelup'); -exports.MemoryDB = require('./memorydb'); +exports.MemDB = require('./memdb'); diff --git a/lib/db/memorydb.js b/lib/db/memdb.js similarity index 91% rename from lib/db/memorydb.js rename to lib/db/memdb.js index 2f12ce82..9b0495c6 100644 --- a/lib/db/memorydb.js +++ b/lib/db/memdb.js @@ -1,5 +1,5 @@ /*! - * memorydb.js - in-memory database for bcoin + * memdb.js - in-memory database for bcoin * Copyright (c) 2016-2017, Christopher Jeffrey (MIT License). * https://github.com/bcoin-org/bcoin */ @@ -14,16 +14,16 @@ var DUMMY = new Buffer(0); /** * In memory database for bcoin * using a red-black tree backend. - * @alias module:db.MemoryDB + * @alias module:db.MemDB * @constructor * @param {String?} location - Phony location. * @param {Object?} options * @param {Function} options.compare - Comparator. */ -function MemoryDB(location) { - if (!(this instanceof MemoryDB)) - return new MemoryDB(location); +function MemDB(location) { + if (!(this instanceof MemDB)) + return new MemDB(location); this.location = location || 'memory'; this.options = {}; @@ -37,7 +37,7 @@ function MemoryDB(location) { * @returns {Buffer?} value */ -MemoryDB.prototype.search = function search(key) { +MemDB.prototype.search = function search(key) { var node; if (typeof key === 'string') @@ -60,7 +60,7 @@ MemoryDB.prototype.search = function search(key) { * @param {Buffer} value */ -MemoryDB.prototype.insert = function insert(key, value) { +MemDB.prototype.insert = function insert(key, value) { if (typeof key === 'string') key = new Buffer(key, 'utf8'); @@ -83,7 +83,7 @@ MemoryDB.prototype.insert = function insert(key, value) { * @returns {Boolean} */ -MemoryDB.prototype.remove = function remove(key) { +MemDB.prototype.remove = function remove(key) { if (typeof key === 'string') key = new Buffer(key, 'utf8'); @@ -100,7 +100,7 @@ MemoryDB.prototype.remove = function remove(key) { * @returns {RBTData[]} Records. */ -MemoryDB.prototype.range = function range(min, max) { +MemDB.prototype.range = function range(min, max) { if (typeof min === 'string') min = new Buffer(min, 'utf8'); @@ -119,7 +119,7 @@ MemoryDB.prototype.range = function range(min, max) { * @param {Function} callback */ -MemoryDB.prototype.open = function open(options, callback) { +MemDB.prototype.open = function open(options, callback) { if (!callback) { callback = options; options = null; @@ -138,7 +138,7 @@ MemoryDB.prototype.open = function open(options, callback) { * @param {Function} callback */ -MemoryDB.prototype.close = function close(callback) { +MemDB.prototype.close = function close(callback) { util.nextTick(callback); }; @@ -149,7 +149,7 @@ MemoryDB.prototype.close = function close(callback) { * @param {Function} callback - Returns Bufer. */ -MemoryDB.prototype.get = function get(key, options, callback) { +MemDB.prototype.get = function get(key, options, callback) { var value, err; if (!callback) { @@ -188,7 +188,7 @@ MemoryDB.prototype.get = function get(key, options, callback) { * @param {Function} callback */ -MemoryDB.prototype.put = function put(key, value, options, callback) { +MemDB.prototype.put = function put(key, value, options, callback) { if (!callback) { callback = options; options = null; @@ -206,7 +206,7 @@ MemoryDB.prototype.put = function put(key, value, options, callback) { * @param {Function} callback */ -MemoryDB.prototype.del = function del(key, options, callback) { +MemDB.prototype.del = function del(key, options, callback) { if (!callback) { callback = options; options = null; @@ -225,7 +225,7 @@ MemoryDB.prototype.del = function del(key, options, callback) { * @param {Function} callback */ -MemoryDB.prototype.batch = function batch(ops, options, callback) { +MemDB.prototype.batch = function batch(ops, options, callback) { var batch; if (!callback) { @@ -250,7 +250,7 @@ MemoryDB.prototype.batch = function batch(ops, options, callback) { * @returns {Leveldown.Iterator}. */ -MemoryDB.prototype.iterator = function iterator(options) { +MemDB.prototype.iterator = function iterator(options) { return new Iterator(this, options); }; @@ -260,7 +260,7 @@ MemoryDB.prototype.iterator = function iterator(options) { * @returns {String} */ -MemoryDB.prototype.getProperty = function getProperty(name) { +MemDB.prototype.getProperty = function getProperty(name) { return ''; }; @@ -271,7 +271,7 @@ MemoryDB.prototype.getProperty = function getProperty(name) { * @param {Function} callback - Returns Number. */ -MemoryDB.prototype.approximateSize = function approximateSize(start, end, callback) { +MemDB.prototype.approximateSize = function approximateSize(start, end, callback) { var items = this.range(start, end); var size = 0; var i, item; @@ -293,7 +293,7 @@ MemoryDB.prototype.approximateSize = function approximateSize(start, end, callba * @param {Function} callback */ -MemoryDB.destroy = function destroy(location, callback) { +MemDB.destroy = function destroy(location, callback) { util.nextTick(callback); }; @@ -303,7 +303,7 @@ MemoryDB.destroy = function destroy(location, callback) { * @param {Function} callback */ -MemoryDB.repair = function repair(location, callback) { +MemDB.repair = function repair(location, callback) { util.nextTick(callback); }; @@ -312,7 +312,7 @@ MemoryDB.repair = function repair(location, callback) { * @constructor * @ignore * @private - * @param {MemoryDB} db + * @param {MemDB} db * @param {Object?} options */ @@ -564,7 +564,7 @@ Iterator.prototype.seek = function seek(key) { /** * End the iterator. Free up snapshot. - * @param {FUnction} callback + * @param {Function} callback */ Iterator.prototype.end = function end(callback) { @@ -683,4 +683,4 @@ IteratorOptions.prototype.fromOptions = function fromOptions(options) { * Expose */ -module.exports = MemoryDB; +module.exports = MemDB;