From b49b288e2e4fdb23d1af66c6d9e7f3b5a6cf1943 Mon Sep 17 00:00:00 2001 From: Nick Downing Date: Sun, 2 Dec 2018 11:37:19 +1100 Subject: [PATCH] Update to build_cache.git commit 1cc703b --- TextCache.js | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/TextCache.js b/TextCache.js index 60b2b07..77db324 100644 --- a/TextCache.js +++ b/TextCache.js @@ -27,24 +27,20 @@ let util = require('util') let fs_readFile = util.promisify(fs.readFile) -let TextCache = function(diag) { +let TextCache = function(diag1, diag) { if (!this instanceof TextCache) - throw Error('TextCache is a constructor') - this.diag = diag || false - - this.build_cache = new BuildCache() + throw new Error('TextCache is a constructor') + BuildCache.call(this, diag) + this.diag1 = diag1 } -TextCache.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 text file ${key}`) - result.value = text - } - ) +TextCache.prototype = Object.create(BuildCache.prototype) + +TextCache.prototype.build = async function(key, result) { + let text = await fs_readFile(key, {encoding: 'utf-8'}) + if (this.diag1) + console.log(`loaded text file ${key}`) + result.value = text } module.exports = TextCache -- 2.34.1