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)
MinSVGCache.js

index 20859bf..ac8d2a6 100644 (file)
@@ -72,37 +72,33 @@ let svgo = new SVGO(
   }
 )
 
-let MinSVGCache = function(diag) {
+let MinSVGCache = function(diag1, diag) {
   if (!this instanceof MinSVGCache)
-    throw Error('MinSVGCache is a constructor')
-  this.diag = diag || false
-
-  this.build_cache = new BuildCache()
+    throw new Error('MinSVGCache is a constructor')
+  BuildCache.call(this, diag)
+  this.diag1 = diag1
 }
 
-MinSVGCache.prototype.get = function(key) {
-  return /*await*/ this.build_cache.get(
+MinSVGCache.prototype = Object.create(BuildCache.prototype)
+
+MinSVGCache.prototype.build = async function(key, result) {
+  let render = await disk_build(
     key,
-    async result => {
-      let render = await disk_build(
-        key,
-        async temp_pathname => {
-          let render = await svgo.optimize(
-            await fs_readFile(key, {encoding: 'utf-8'}),
-            {path: key}
-          )
-          return /*await*/ fs_writeFile(
-            temp_pathname,
-            render.data,
-            {encoding: 'utf-8'}
-          )
-        },
-        this.diag
+    async temp_pathname => {
+      let render = await svgo.optimize(
+        await fs_readFile(key, {encoding: 'utf-8'}),
+        {path: key}
+      )
+      return /*await*/ fs_writeFile(
+        temp_pathname,
+        render.data,
+        {encoding: 'utf-8'}
       )
-      assert(render.deps.length === 0)
-      result.value = await fs_readFile(render.pathname)
-    }
+    },
+    this.diag1
   )
+  assert(render.deps.length === 0)
+  result.value = await fs_readFile(render.pathname)
 }
 
 module.exports = MinSVGCache