Add kick() function, currently does nothing, forgotten JSONCache -> JSONCacheRW
authorNick Downing <nick@ndcode.org>
Tue, 4 Dec 2018 11:45:42 +0000 (22:45 +1100)
committerNick Downing <nick@ndcode.org>
Tue, 4 Dec 2018 11:45:42 +0000 (22:45 +1100)
.npmignore [deleted file]
.yarnignore [deleted file]
JSONCacheRW.js
package.json

diff --git a/.npmignore b/.npmignore
deleted file mode 100644 (file)
index 9805cda..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-/build_cache-*.tgz
-/node_modules
-/package-lock.json
-/yarn.lock
-/yarn-error.log
diff --git a/.yarnignore b/.yarnignore
deleted file mode 100644 (file)
index 9805cda..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-/build_cache-*.tgz
-/node_modules
-/package-lock.json
-/yarn.lock
-/yarn-error.log
index 3e55b93..5d49668 100644 (file)
@@ -29,9 +29,9 @@ let fs_rename = util.promisify(fs.rename)
 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
 }
@@ -68,7 +68,7 @@ let read = (pathname, default_value, diag) => {
   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)
@@ -112,7 +112,7 @@ let write = (pathname, result, timeout, 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
@@ -130,7 +130,7 @@ JSONCache.prototype.write = async function(key, value, timeout) {
   write(key, result, timeout, this.diag)
 }
 
-JSONCache.prototype.modify = async function(
+JSONCacheRW.prototype.modify = async function(
   key,
   default_value,
   modify_func,
@@ -158,4 +158,8 @@ JSONCache.prototype.modify = async function(
   delete result.done
 }
 
-module.exports = JSONCache
+JSONCacheRW.prototype.kick = function() {
+  // not yet implemented
+}
+
+module.exports = JSONCacheRW
index b738588..238e05e 100644 (file)
@@ -11,6 +11,8 @@
     "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"
@@ -21,8 +23,5 @@
   "main": "JSONCacheRW.js",
   "directories": {},
   "dependencies": {},
-  "devDependencies": {},
-  "scripts": {},
-  "author": "Nick Downing <nick@ndcode.org>",
-  "license": "MIT"
+  "devDependencies": {}
 }