Created
February 1, 2022 23:21
-
-
Save ralphtheninja/12b4f4bdc2fa82730d46321b8d45ad97 to your computer and use it in GitHub Desktop.
mixmap storage wrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Storage wrapper object for relaying operations to backend. | |
*/ | |
module.exports = function (backend) { | |
var storageFn = function (name) { | |
return { | |
write: function (offset, buf, cb) { | |
cb(new Error('write not implemented')) | |
}, | |
truncate: function (length, cb) { | |
cb(new Error('truncate not implemented')) | |
}, | |
del: function (cb) { | |
cb(new Error('del not implemented')) | |
}, | |
sync: function (cb) { | |
cb(new Error('sync not implemented')) | |
}, | |
length: function (cb) { | |
backend.length(name, cb) | |
}, | |
read: function (offset, length, cb) { | |
backend.read(name,offset, length, cb) | |
} | |
} | |
} | |
storageFn.getBackend = function () { return backend } | |
storageFn.setBackend = function (_backend) { backend = _backend } | |
storageFn.destroy = function (name, cb) { backend.destroy(name, cb) } | |
return storageFn | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment