fetch-json-cache 0.1.5 → 0.1.9
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/index.js +1 -1
- package/lib/get.js +4 -1
- package/package.json +7 -7
package/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var hash = require('./lib/hash');
|
|
|
5
5
|
var update = require('./lib/update');
|
|
6
6
|
|
|
7
7
|
function Cache(cacheDirectory, options) {
|
|
8
|
-
if (this
|
|
8
|
+
if (!(this instanceof Cache)) return new Cache(cacheDirectory, options);
|
|
9
9
|
if (!cacheDirectory) throw new Error('Cache needs cacheDirectory');
|
|
10
10
|
this.cacheDirectory = cacheDirectory;
|
|
11
11
|
this.options = typeof options === 'undefined' ? {} : options;
|
package/lib/get.js
CHANGED
|
@@ -19,7 +19,10 @@ module.exports = function getCache(endpoint, callback) {
|
|
|
19
19
|
var record = JSON.parse(contents.toString());
|
|
20
20
|
get(endpoint).head(function (err, res) {
|
|
21
21
|
// not accessible
|
|
22
|
-
if (err)
|
|
22
|
+
if (err) {
|
|
23
|
+
if (err.code === 'ENOTFOUND' || err.message.indexOf("routines:SSL23_GET_SERVER_HELLO") >= 0) return callback(null, record.body);
|
|
24
|
+
return callback(err);
|
|
25
|
+
}
|
|
23
26
|
if (res.headers.etag === record.headers.etag) return callback(null, record.body);
|
|
24
27
|
update.call(self, endpoint, function (err, json) {
|
|
25
28
|
err ? callback(err) : callback(null, json);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fetch-json-cache",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Caches fetched json. Updates when etag changes and is uses cache regardless if endpoint unreachable. Uses write-file-atomic for safe updates",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"every",
|
|
@@ -23,27 +23,27 @@
|
|
|
23
23
|
"test": "mocha-compat test/spec/**/*.test.js"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"get-remote": "^0.
|
|
26
|
+
"get-remote": "^0.6.0",
|
|
27
27
|
"mkpath": "^1.0.0",
|
|
28
28
|
"rimraf": "^2.7.1",
|
|
29
29
|
"write-file-atomic": "^1.3.4"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"babel-eslint": "^10.1.0",
|
|
33
|
-
"depcheck": "^
|
|
33
|
+
"depcheck": "^1.4.2",
|
|
34
34
|
"dis-dat": "^0.1.3",
|
|
35
35
|
"eslint": "^6.8.0",
|
|
36
36
|
"eslint-config-prettier": "^6.11.0",
|
|
37
37
|
"eslint-config-standard": "^14.1.1",
|
|
38
|
-
"eslint-plugin-import": "^2.
|
|
38
|
+
"eslint-plugin-import": "^2.22.0",
|
|
39
39
|
"eslint-plugin-node": "^11.1.0",
|
|
40
40
|
"eslint-plugin-promise": "^4.2.1",
|
|
41
41
|
"eslint-plugin-standard": "^4.0.1",
|
|
42
|
-
"fs-access-sync-compat": "^1.0.
|
|
42
|
+
"fs-access-sync-compat": "^1.0.1",
|
|
43
43
|
"mocha-compat": "^3.5.5",
|
|
44
|
-
"prettier": "^2.
|
|
44
|
+
"prettier": "^2.4.1"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
|
-
"node": ">=0.8
|
|
47
|
+
"node": ">=0.8"
|
|
48
48
|
}
|
|
49
49
|
}
|