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