Update to build_cache.git commit 1cc703b
authorNick Downing <nick@ndcode.org>
Sun, 2 Dec 2018 00:37:18 +0000 (11:37 +1100)
committerNick Downing <nick@ndcode.org>
Sun, 2 Dec 2018 00:37:18 +0000 (11:37 +1100)
JSONCache.js

index b38fc14..6475084 100644 (file)
@@ -27,24 +27,21 @@ let util = require('util')
 
 let fs_readFile = util.promisify(fs.readFile)
 
-let JSONCache = function(diag) {
+let JSONCache = function(diag1, diag) {
   if (!this instanceof JSONCache)
-    throw Error('JSONCache is a constructor')
-  this.diag = diag || false
-
-  this.build_cache = new BuildCache()
+    throw new Error('JSONCache is a constructor')
+  BuildCache.call(this, diag)
+  this.diag = diag
+  this.diag1 = diag1 || false
 }
 
-JSONCache.prototype.get = function(key) {
-  return /*await*/ this.build_cache.get(
-    key,
-    async result => {
-      let text = await fs_readFile(key, {encoding: 'utf-8'})
-      if (this.diag)
-        console.log(`loaded json file ${key}`)
-      result.value = JSON.parse(text)
-    }
-  )
+JSONCache.prototype = Object.create(BuildCache.prototype)
+
+JSONCache.prototype.build = async function(key, result) {
+  let text = await fs_readFile(key, {encoding: 'utf-8'})
+  if (this.diag1)
+    console.log(`loaded json file ${key}`)
+  result.value = JSON.parse(text)
 }
 
 module.exports = JSONCache