let fs_unlink = util.promisify(fs.unlink)
let fs_writeFile = util.promisify(fs.writeFile)
-let JSONCache = function(diag) {
- if (!this instanceof JSONCache)
- throw Error('JSONCache is a constructor')
+let JSONCacheRW = function(diag) {
+ if (!this instanceof JSONCacheRW)
+ throw new Error('JSONCacheRW is a constructor')
this.map = new Map()
this.diag = diag || false
}
return result
}
-JSONCache.prototype.read = async function(key, default_value) {
+JSONCacheRW.prototype.read = async function(key, default_value) {
let result = this.map.get(key)
if (result === undefined) {
result = read(key, default_value, this.diag)
}
}
-JSONCache.prototype.write = async function(key, value, timeout) {
+JSONCacheRW.prototype.write = async function(key, value, timeout) {
let result = this.map.get(key)
if (result === undefined) {
// we no longer support passing an undefined value to indicate that the
write(key, result, timeout, this.diag)
}
-JSONCache.prototype.modify = async function(
+JSONCacheRW.prototype.modify = async function(
key,
default_value,
modify_func,
delete result.done
}
-module.exports = JSONCache
+JSONCacheRW.prototype.kick = function() {
+ // not yet implemented
+}
+
+module.exports = JSONCacheRW
"write-back"
],
"homepage": "https://www.ndcode.org",
+ "author": "Nick Downing <nick@ndcode.org>",
+ "license": "MIT",
"repository": {
"type": "git",
"url": "https://git.ndcode.org/public/json_cache_rw.git"
"main": "JSONCacheRW.js",
"directories": {},
"dependencies": {},
- "devDependencies": {},
- "scripts": {},
- "author": "Nick Downing <nick@ndcode.org>",
- "license": "MIT"
+ "devDependencies": {}
}