@binyamin/data-cache
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -43,6 +43,9 @@ const fs = require("fs"); | ||
datacache.get = function(key, encoding="utf8") { | ||
let keypath = path.resolve(_cachedir, key.replace(/\./g, path.sep)); | ||
const keypath = path.resolve(_cachedir, key.replace(/\./g, path.sep)); | ||
if(fs.existsSync(keypath)){ | ||
if(fs.existsSync(keypath)) { | ||
return fs.readFileSync(keypath, {encoding}) | ||
} else if(fs.existsSync(keypath+".json")) { | ||
const filedata = fs.readFileSync(keypath+".json", {encoding}); | ||
return JSON.parse(filedata); | ||
} | ||
@@ -49,0 +52,0 @@ |
{ | ||
"name": "@binyamin/data-cache", | ||
"private": false, | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Tiny module for caching data", | ||
"main": "index.js", | ||
"engines": { | ||
"node": ">=8" | ||
"node": ">=10" | ||
}, | ||
@@ -10,0 +10,0 @@ "files": [ |
3729
42