Closed uncenter closed 9 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
d749c00
) 100.00% compared to head (741ca19
) 100.00%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
I'm not sure why this is the case but I tried the following, 5 of the tests failed:
// ...
- const utils = require('./utils');
+ const { writeJSON, tryParse } = require('./utils');
const del = require('./del');
- const writeJSON = utils.writeJSON;
const cache = {
/**
* Load a cache identified by the given Id. If the element does not exists, then initialize an empty
* cache storage. If specified `cacheDir` will be used as the directory to persist the data to. If omitted
@@ -16,12 +16,12 @@ var cache = {
* @param [cacheDir] {String} directory for the cache entry
*/
load: function (docId, cacheDir) {
const me = this;
me.keyv = new Keyv();
me.__visited = {};
me.__persisted = {};
me._pathToFile = cacheDir ? path.resolve(cacheDir, docId) : path.resolve(__dirname, '../.cache/', docId);
if (fs.existsSync(me._pathToFile)) {
- me._persisted = utils.tryParse(me._pathToFile, {});
+ me._persisted = tryParse(me._pathToFile, {});
}
},
// ...
EDIT: Ah. I see. I guess it can't access this.readJSON
when I do that.
@uncenter - thanks for the update. We will be working to make this more modern code base in the new year and might move it to typescript.
TypeScript sounds awesome! I've had a great experience with https://github.com/unjs/unbuild and there is also https://github.com/egoist/tsup.
This PR switches to using the
let
andconst
keywords instead ofvar
in the source code, as is the standard nowadays.