memorydb: rename to memdb.
This commit is contained in:
parent
df06c91557
commit
fbf73ddabf
@ -7,10 +7,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var level = require('./level');
|
var level = require('./level');
|
||||||
var MemoryDB = require('./memorydb');
|
var MemDB = require('./memdb');
|
||||||
|
|
||||||
exports.get = function get(name) {
|
exports.get = function get(name) {
|
||||||
if (name === 'memory')
|
if (name === 'memory')
|
||||||
return MemoryDB;
|
return MemDB;
|
||||||
return level;
|
return level;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
exports.get = function get(name) {
|
exports.get = function get(name) {
|
||||||
if (name === 'memory')
|
if (name === 'memory')
|
||||||
return require('./memorydb');
|
return require('./memdb');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return require(name);
|
return require(name);
|
||||||
|
|||||||
@ -6,4 +6,4 @@
|
|||||||
|
|
||||||
exports.LDB = require('./ldb');
|
exports.LDB = require('./ldb');
|
||||||
exports.LowlevelUp = require('./lowlevelup');
|
exports.LowlevelUp = require('./lowlevelup');
|
||||||
exports.MemoryDB = require('./memorydb');
|
exports.MemDB = require('./memdb');
|
||||||
|
|||||||
@ -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).
|
* Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
|
||||||
* https://github.com/bcoin-org/bcoin
|
* https://github.com/bcoin-org/bcoin
|
||||||
*/
|
*/
|
||||||
@ -14,16 +14,16 @@ var DUMMY = new Buffer(0);
|
|||||||
/**
|
/**
|
||||||
* In memory database for bcoin
|
* In memory database for bcoin
|
||||||
* using a red-black tree backend.
|
* using a red-black tree backend.
|
||||||
* @alias module:db.MemoryDB
|
* @alias module:db.MemDB
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {String?} location - Phony location.
|
* @param {String?} location - Phony location.
|
||||||
* @param {Object?} options
|
* @param {Object?} options
|
||||||
* @param {Function} options.compare - Comparator.
|
* @param {Function} options.compare - Comparator.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function MemoryDB(location) {
|
function MemDB(location) {
|
||||||
if (!(this instanceof MemoryDB))
|
if (!(this instanceof MemDB))
|
||||||
return new MemoryDB(location);
|
return new MemDB(location);
|
||||||
|
|
||||||
this.location = location || 'memory';
|
this.location = location || 'memory';
|
||||||
this.options = {};
|
this.options = {};
|
||||||
@ -37,7 +37,7 @@ function MemoryDB(location) {
|
|||||||
* @returns {Buffer?} value
|
* @returns {Buffer?} value
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MemoryDB.prototype.search = function search(key) {
|
MemDB.prototype.search = function search(key) {
|
||||||
var node;
|
var node;
|
||||||
|
|
||||||
if (typeof key === 'string')
|
if (typeof key === 'string')
|
||||||
@ -60,7 +60,7 @@ MemoryDB.prototype.search = function search(key) {
|
|||||||
* @param {Buffer} value
|
* @param {Buffer} value
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MemoryDB.prototype.insert = function insert(key, value) {
|
MemDB.prototype.insert = function insert(key, value) {
|
||||||
if (typeof key === 'string')
|
if (typeof key === 'string')
|
||||||
key = new Buffer(key, 'utf8');
|
key = new Buffer(key, 'utf8');
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ MemoryDB.prototype.insert = function insert(key, value) {
|
|||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MemoryDB.prototype.remove = function remove(key) {
|
MemDB.prototype.remove = function remove(key) {
|
||||||
if (typeof key === 'string')
|
if (typeof key === 'string')
|
||||||
key = new Buffer(key, 'utf8');
|
key = new Buffer(key, 'utf8');
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ MemoryDB.prototype.remove = function remove(key) {
|
|||||||
* @returns {RBTData[]} Records.
|
* @returns {RBTData[]} Records.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MemoryDB.prototype.range = function range(min, max) {
|
MemDB.prototype.range = function range(min, max) {
|
||||||
if (typeof min === 'string')
|
if (typeof min === 'string')
|
||||||
min = new Buffer(min, 'utf8');
|
min = new Buffer(min, 'utf8');
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ MemoryDB.prototype.range = function range(min, max) {
|
|||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MemoryDB.prototype.open = function open(options, callback) {
|
MemDB.prototype.open = function open(options, callback) {
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
callback = options;
|
callback = options;
|
||||||
options = null;
|
options = null;
|
||||||
@ -138,7 +138,7 @@ MemoryDB.prototype.open = function open(options, callback) {
|
|||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MemoryDB.prototype.close = function close(callback) {
|
MemDB.prototype.close = function close(callback) {
|
||||||
util.nextTick(callback);
|
util.nextTick(callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ MemoryDB.prototype.close = function close(callback) {
|
|||||||
* @param {Function} callback - Returns Bufer.
|
* @param {Function} callback - Returns Bufer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MemoryDB.prototype.get = function get(key, options, callback) {
|
MemDB.prototype.get = function get(key, options, callback) {
|
||||||
var value, err;
|
var value, err;
|
||||||
|
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
@ -188,7 +188,7 @@ MemoryDB.prototype.get = function get(key, options, callback) {
|
|||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MemoryDB.prototype.put = function put(key, value, options, callback) {
|
MemDB.prototype.put = function put(key, value, options, callback) {
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
callback = options;
|
callback = options;
|
||||||
options = null;
|
options = null;
|
||||||
@ -206,7 +206,7 @@ MemoryDB.prototype.put = function put(key, value, options, callback) {
|
|||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MemoryDB.prototype.del = function del(key, options, callback) {
|
MemDB.prototype.del = function del(key, options, callback) {
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
callback = options;
|
callback = options;
|
||||||
options = null;
|
options = null;
|
||||||
@ -225,7 +225,7 @@ MemoryDB.prototype.del = function del(key, options, callback) {
|
|||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MemoryDB.prototype.batch = function batch(ops, options, callback) {
|
MemDB.prototype.batch = function batch(ops, options, callback) {
|
||||||
var batch;
|
var batch;
|
||||||
|
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
@ -250,7 +250,7 @@ MemoryDB.prototype.batch = function batch(ops, options, callback) {
|
|||||||
* @returns {Leveldown.Iterator}.
|
* @returns {Leveldown.Iterator}.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MemoryDB.prototype.iterator = function iterator(options) {
|
MemDB.prototype.iterator = function iterator(options) {
|
||||||
return new Iterator(this, options);
|
return new Iterator(this, options);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ MemoryDB.prototype.iterator = function iterator(options) {
|
|||||||
* @returns {String}
|
* @returns {String}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MemoryDB.prototype.getProperty = function getProperty(name) {
|
MemDB.prototype.getProperty = function getProperty(name) {
|
||||||
return '';
|
return '';
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -271,7 +271,7 @@ MemoryDB.prototype.getProperty = function getProperty(name) {
|
|||||||
* @param {Function} callback - Returns Number.
|
* @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 items = this.range(start, end);
|
||||||
var size = 0;
|
var size = 0;
|
||||||
var i, item;
|
var i, item;
|
||||||
@ -293,7 +293,7 @@ MemoryDB.prototype.approximateSize = function approximateSize(start, end, callba
|
|||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MemoryDB.destroy = function destroy(location, callback) {
|
MemDB.destroy = function destroy(location, callback) {
|
||||||
util.nextTick(callback);
|
util.nextTick(callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ MemoryDB.destroy = function destroy(location, callback) {
|
|||||||
* @param {Function} callback
|
* @param {Function} callback
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MemoryDB.repair = function repair(location, callback) {
|
MemDB.repair = function repair(location, callback) {
|
||||||
util.nextTick(callback);
|
util.nextTick(callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -312,7 +312,7 @@ MemoryDB.repair = function repair(location, callback) {
|
|||||||
* @constructor
|
* @constructor
|
||||||
* @ignore
|
* @ignore
|
||||||
* @private
|
* @private
|
||||||
* @param {MemoryDB} db
|
* @param {MemDB} db
|
||||||
* @param {Object?} options
|
* @param {Object?} options
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -564,7 +564,7 @@ Iterator.prototype.seek = function seek(key) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* End the iterator. Free up snapshot.
|
* End the iterator. Free up snapshot.
|
||||||
* @param {FUnction} callback
|
* @param {Function} callback
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Iterator.prototype.end = function end(callback) {
|
Iterator.prototype.end = function end(callback) {
|
||||||
@ -683,4 +683,4 @@ IteratorOptions.prototype.fromOptions = function fromOptions(options) {
|
|||||||
* Expose
|
* Expose
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = MemoryDB;
|
module.exports = MemDB;
|
||||||
Loading…
Reference in New Issue
Block a user