flat-cache 3.0.4 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015 Roy Riojas
3
+ Copyright (c) Roy Riojas and Jared Wray
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # flat-cache
2
2
  > A stupidly simple key/value storage using files to persist the data
3
3
 
4
- [![NPM Version](http://img.shields.io/npm/v/flat-cache.svg?style=flat)](https://npmjs.org/package/flat-cache)
5
- [![Build Status](https://api.travis-ci.org/royriojas/flat-cache.svg?branch=master)](https://travis-ci.org/royriojas/flat-cache)
4
+ [![NPM Version](https://img.shields.io/npm/v/flat-cache.svg?style=flat)](https://npmjs.org/package/flat-cache)
5
+ [![tests](https://github.com/jaredwray/flat-cache/actions/workflows/tests.yaml/badge.svg?branch=master)](https://github.com/jaredwray/flat-cache/actions/workflows/tests.yaml)
6
+ [![codecov](https://codecov.io/github/jaredwray/flat-cache/branch/master/graph/badge.svg?token=KxR95XT3NF)](https://codecov.io/github/jaredwray/flat-cache)
7
+ [![npm](https://img.shields.io/npm/dm/flat-cache)](https://npmjs.com/package/flat-cache)
6
8
 
7
9
  ## install
8
10
 
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "flat-cache",
3
- "version": "3.0.4",
3
+ "version": "3.1.0",
4
4
  "description": "A stupidly simple key/value storage using files to persist some data",
5
- "repository": "royriojas/flat-cache",
5
+ "repository": "jaredwray/flat-cache",
6
6
  "license": "MIT",
7
7
  "author": {
8
- "name": "Roy Riojas",
9
- "url": "http://royriojas.com"
8
+ "name": "Jared Wray",
9
+ "url": "https://jaredwray.com"
10
10
  },
11
11
  "main": "src/cache.js",
12
12
  "files": [
@@ -15,7 +15,7 @@
15
15
  "src/utils.js"
16
16
  ],
17
17
  "engines": {
18
- "node": "^10.12.0 || >=12.0.0"
18
+ "node": ">=12.0.0"
19
19
  },
20
20
  "precommit": [
21
21
  "npm run verify --silent"
@@ -37,7 +37,8 @@
37
37
  "bump-major": "npm run pre-v && npm version major -m 'BLD: Release v%s' && npm run post-v",
38
38
  "bump-minor": "npm run pre-v && npm version minor -m 'BLD: Release v%s' && npm run post-v",
39
39
  "bump-patch": "npm run pre-v && npm version patch -m 'BLD: Release v%s' && npm run post-v",
40
- "test:cache": "mocha -R spec test/specs",
40
+ "test:cache": "c8 mocha -R spec test/specs",
41
+ "test:ci:cache": "c8 --reporter=lcov mocha -R spec test/specs",
41
42
  "test": "npm run verify --silent",
42
43
  "cover": "istanbul cover test/runner.js html text-summary",
43
44
  "watch": "watch-run -i -p 'test/specs/**/*.js' istanbul cover test/runner.js html text-summary"
@@ -63,22 +64,23 @@
63
64
  "projectName": "flat-cache"
64
65
  },
65
66
  "devDependencies": {
66
- "chai": "^4.2.0",
67
+ "c8": "^8.0.1",
68
+ "chai": "^4.3.7",
67
69
  "changelogx": "^5.0.6",
68
70
  "eslint": "^7.13.0",
69
71
  "eslint-config-prettier": "^6.15.0",
70
72
  "eslint-plugin-mocha": "^8.0.0",
71
73
  "eslint-plugin-prettier": "^3.1.4",
72
74
  "glob-expand": "^0.2.1",
73
- "istanbul": "^0.4.5",
74
- "mocha": "^8.2.1",
75
+ "mocha": "^10.2.0",
75
76
  "precommit": "^1.2.2",
76
77
  "prepush": "^3.1.11",
77
78
  "prettier": "^2.1.2",
78
79
  "watch-run": "^1.2.5"
79
80
  },
80
81
  "dependencies": {
81
- "flatted": "^3.1.0",
82
+ "flatted": "^3.2.7",
83
+ "keyv": "^4.5.3",
82
84
  "rimraf": "^3.0.2"
83
85
  }
84
86
  }
package/src/cache.js CHANGED
@@ -1,5 +1,6 @@
1
1
  var path = require('path');
2
2
  var fs = require('fs');
3
+ var Keyv = require('keyv');
3
4
  var utils = require('./utils');
4
5
  var del = require('./del');
5
6
  var writeJSON = utils.writeJSON;
@@ -17,8 +18,10 @@ var cache = {
17
18
  load: function (docId, cacheDir) {
18
19
  var me = this;
19
20
 
20
- me._visited = {};
21
- me._persisted = {};
21
+ me.keyv = new Keyv();
22
+
23
+ me.__visited = {};
24
+ me.__persisted = {};
22
25
  me._pathToFile = cacheDir ? path.resolve(cacheDir, docId) : path.resolve(__dirname, '../.cache/', docId);
23
26
 
24
27
  if (fs.existsSync(me._pathToFile)) {
@@ -26,6 +29,24 @@ var cache = {
26
29
  }
27
30
  },
28
31
 
32
+ get _persisted() {
33
+ return this.__persisted;
34
+ },
35
+
36
+ set _persisted(value) {
37
+ this.__persisted = value;
38
+ this.keyv.set('persisted', value);
39
+ },
40
+
41
+ get _visited() {
42
+ return this.__visited;
43
+ },
44
+
45
+ set _visited(value) {
46
+ this.__visited = value;
47
+ this.keyv.set('visited', value);
48
+ },
49
+
29
50
  /**
30
51
  * Load the cache from the provided file
31
52
  * @method loadFile