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

index d7560d3..5774634 100644 (file)
 let BuildCache = require('@ndcode/build_cache')
 let zettair = require('@ndcode/zettair')
 
-let ZettairCache = function(diag) {
+let ZettairCache = function(diag1, diag) {
   if (!this instanceof ZettairCache)
-    throw Error('ZettairCache is a constructor')
-  this.diag = diag || false
-
-  this.build_cache = new BuildCache()
+    throw new Error('ZettairCache is a constructor')
+  BuildCache.call(this, diag)
+  this.diag1 = diag1
 }
 
-ZettairCache.prototype.get = function(key) {
-  return /*await*/ this.build_cache.get(
-    key,
-    async result => {
-      result.deps = [
-        `${key}.map.0`,
-        `${key}.param.0`,
-        `${key}.v.0`,
-        `${key}.vocab.0`
-      ]
-      result.value = new zettair.Index(key)
-      if (this.diag)
-        console.log(`opened zettair index ${key}`)
-    }
-  )
+ZettairCache.prototype = Object.create(BuildCache.prototype)
+
+ZettairCache.prototype.build = async function(key, result) {
+  result.deps = [
+    `${key}.map.0`,
+    `${key}.param.0`,
+    `${key}.v.0`,
+    `${key}.vocab.0`
+  ]
+  result.value = new zettair.Index(key)
+  if (this.diag1)
+    console.log(`opened zettair index ${key}`)
 }
 
 module.exports = ZettairCache