fetch-json-cache 1.3.10 → 1.3.11
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/dist/cjs/Cache.js +2 -4
- package/dist/cjs/Cache.js.map +1 -1
- package/dist/cjs/update.js +3 -7
- package/dist/cjs/update.js.map +1 -1
- package/dist/esm/Cache.js +2 -4
- package/dist/esm/Cache.js.map +1 -1
- package/dist/esm/update.js +3 -7
- package/dist/esm/update.js.map +1 -1
- package/package.json +2 -2
package/dist/cjs/Cache.js
CHANGED
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "default", {
|
|
|
8
8
|
return Cache;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
var
|
|
11
|
+
var _fsremovecompat = require("fs-remove-compat");
|
|
12
12
|
var _getts = /*#__PURE__*/ _interop_require_default(require("./get.js"));
|
|
13
13
|
var _getSyncts = /*#__PURE__*/ _interop_require_default(require("./getSync.js"));
|
|
14
14
|
var _hashts = /*#__PURE__*/ _interop_require_default(require("./hash.js"));
|
|
@@ -67,9 +67,7 @@ var Cache = /*#__PURE__*/ function() {
|
|
|
67
67
|
var _this = this;
|
|
68
68
|
function worker(callback) {
|
|
69
69
|
// ignore errors since it is fine to delete a directory that doesn't exist from a cache standpoint
|
|
70
|
-
(0,
|
|
71
|
-
disableGlob: true
|
|
72
|
-
}, callback.bind(null, null));
|
|
70
|
+
(0, _fsremovecompat.safeRm)(this.cachePath, callback.bind(null, null));
|
|
73
71
|
}
|
|
74
72
|
if (typeof callback === 'function') return worker.call(this, callback);
|
|
75
73
|
return new Promise(function(resolve, reject) {
|
package/dist/cjs/Cache.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/fetch-json-cache/src/Cache.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/fetch-json-cache/src/Cache.ts"],"sourcesContent":["import { safeRm } from 'fs-remove-compat';\n\nimport get from './get.ts';\nimport getSync from './getSync.ts';\nimport hash from './hash.ts';\nimport type { CacheOptions, ClearCallback, GetCallback, GetOptions } from './types.ts';\nimport update from './update.ts';\n\nexport default class Cache {\n cachePath: string;\n options: CacheOptions;\n\n constructor(cachePath: string, options: CacheOptions = {}) {\n if (!(this instanceof Cache)) throw new Error('Cache needs to be called with new');\n if (!cachePath) throw new Error('Cache needs cachePath');\n this.cachePath = cachePath;\n this.options = options;\n if (!this.options.hash) this.options.hash = hash;\n }\n\n get<T>(endpoint: string, options?: GetOptions | GetCallback<T>, callback?: GetCallback<T>): undefined | Promise<object | null> {\n if (typeof options === 'function') {\n callback = options as GetCallback<T>;\n options = null;\n }\n options = options || {};\n\n function worker(endpoint, options, callback) {\n (options as GetOptions).force ? update.call(this, endpoint, callback) : get.call(this, endpoint, callback);\n }\n\n if (typeof callback === 'function') return worker.call(this, endpoint, options, callback) as undefined;\n return new Promise((resolve, reject) => worker.call(this, endpoint, options, (err, json) => (err ? reject(err) : resolve(json))));\n }\n\n getSync<T>(endpoint: string): T | null {\n // TODO: add async fetching\n return getSync.call(this, endpoint);\n }\n\n clear(callback?: ClearCallback): undefined | Promise<undefined> {\n function worker(callback) {\n // ignore errors since it is fine to delete a directory that doesn't exist from a cache standpoint\n safeRm(this.cachePath, callback.bind(null, null));\n }\n\n if (typeof callback === 'function') return worker.call(this, callback);\n return new Promise((resolve, reject) =>\n worker.call(this, (err) => {\n err ? reject(err) : resolve(undefined);\n })\n );\n }\n}\n"],"names":["Cache","cachePath","options","Error","hash","get","endpoint","callback","worker","force","update","call","Promise","resolve","reject","err","json","getSync","clear","safeRm","bind","undefined"],"mappings":";;;;;;;eAQqBA;;;8BARE;4DAEP;gEACI;6DACH;+DAEE;;;;;;;;;;;;;;;;;;AAEJ,IAAA,AAAMA,sBAAN;;aAAMA,MAIPC,SAAiB;YAAEC,UAAAA,iEAAwB,CAAC;gCAJrCF;QAKjB,IAAI,CAAE,AAAI,YAAJ,IAAI,EALOA,QAKa,MAAM,IAAIG,MAAM;QAC9C,IAAI,CAACF,WAAW,MAAM,IAAIE,MAAM;QAChC,IAAI,CAACF,SAAS,GAAGA;QACjB,IAAI,CAACC,OAAO,GAAGA;QACf,IAAI,CAAC,IAAI,CAACA,OAAO,CAACE,IAAI,EAAE,IAAI,CAACF,OAAO,CAACE,IAAI,GAAGA,eAAI;;iBAT/BJ;IAYnBK,OAAAA,GAaC,GAbDA,SAAAA,IAAOC,QAAgB,EAAEJ,OAAqC,EAAEK,QAAyB;;QACvF,IAAI,OAAOL,YAAY,YAAY;YACjCK,WAAWL;YACXA,UAAU;QACZ;QACAA,UAAUA,WAAW,CAAC;QAEtB,SAASM,OAAOF,QAAQ,EAAEJ,OAAO,EAAEK,QAAQ;YACxCL,QAAuBO,KAAK,GAAGC,iBAAM,CAACC,IAAI,CAAC,IAAI,EAAEL,UAAUC,YAAYF,cAAG,CAACM,IAAI,CAAC,IAAI,EAAEL,UAAUC;QACnG;QAEA,IAAI,OAAOA,aAAa,YAAY,OAAOC,OAAOG,IAAI,CAAC,IAAI,EAAEL,UAAUJ,SAASK;QAChF,OAAO,IAAIK,QAAQ,SAACC,SAASC;mBAAWN,OAAOG,IAAI,QAAOL,UAAUJ,SAAS,SAACa,KAAKC;uBAAUD,MAAMD,OAAOC,OAAOF,QAAQG;;;IAC3H;IAEAC,OAAAA,OAGC,GAHDA,SAAAA,QAAWX,QAAgB;QACzB,2BAA2B;QAC3B,OAAOW,kBAAO,CAACN,IAAI,CAAC,IAAI,EAAEL;IAC5B;IAEAY,OAAAA,KAYC,GAZDA,SAAAA,MAAMX,QAAwB;;QAC5B,SAASC,OAAOD,QAAQ;YACtB,kGAAkG;YAClGY,IAAAA,sBAAM,EAAC,IAAI,CAAClB,SAAS,EAAEM,SAASa,IAAI,CAAC,MAAM;QAC7C;QAEA,IAAI,OAAOb,aAAa,YAAY,OAAOC,OAAOG,IAAI,CAAC,IAAI,EAAEJ;QAC7D,OAAO,IAAIK,QAAQ,SAACC,SAASC;mBAC3BN,OAAOG,IAAI,QAAO,SAACI;gBACjBA,MAAMD,OAAOC,OAAOF,QAAQQ;YAC9B;;IAEJ;WA5CmBrB"}
|
package/dist/cjs/update.js
CHANGED
|
@@ -9,11 +9,11 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
12
|
+
var _fsremovecompat = require("fs-remove-compat");
|
|
12
13
|
var _getremote = /*#__PURE__*/ _interop_require_default(require("get-remote"));
|
|
13
14
|
var _mkdirpclassic = /*#__PURE__*/ _interop_require_default(require("mkdirp-classic"));
|
|
14
15
|
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
15
16
|
var _queuecb = /*#__PURE__*/ _interop_require_default(require("queue-cb"));
|
|
16
|
-
var _rimraf2 = /*#__PURE__*/ _interop_require_default(require("rimraf2"));
|
|
17
17
|
var _tempsuffix = /*#__PURE__*/ _interop_require_default(require("temp-suffix"));
|
|
18
18
|
function _interop_require_default(obj) {
|
|
19
19
|
return obj && obj.__esModule ? obj : {
|
|
@@ -34,17 +34,13 @@ function update(endpoint, callback) {
|
|
|
34
34
|
var queue = new _queuecb.default(1);
|
|
35
35
|
queue.defer(_fs.default.writeFile.bind(null, tempFile, JSON.stringify(record), 'utf8'));
|
|
36
36
|
queue.defer(function(cb) {
|
|
37
|
-
return (0,
|
|
38
|
-
disableGlob: true
|
|
39
|
-
}, cb.bind(null, null));
|
|
37
|
+
return (0, _fsremovecompat.rm)(fullPath, cb.bind(null, null));
|
|
40
38
|
});
|
|
41
39
|
queue.defer(_fs.default.rename.bind(null, tempFile, fullPath));
|
|
42
40
|
queue.await(function(err) {
|
|
43
41
|
if (!err) return callback(null, record.body);
|
|
44
42
|
// cleanup the temp file if the operation failed
|
|
45
|
-
(0,
|
|
46
|
-
disableGlob: true
|
|
47
|
-
}, callback.bind(err));
|
|
43
|
+
(0, _fsremovecompat.rm)(tempFile, callback.bind(err));
|
|
48
44
|
});
|
|
49
45
|
});
|
|
50
46
|
});
|
package/dist/cjs/update.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/fetch-json-cache/src/update.ts"],"sourcesContent":["import fs from 'fs';\nimport get from 'get-remote';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/fetch-json-cache/src/update.ts"],"sourcesContent":["import fs from 'fs';\nimport { rm } from 'fs-remove-compat';\nimport get from 'get-remote';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport tempSuffix from 'temp-suffix';\n\nimport type { Record, UpdateCallback } from './types.ts';\n\nexport default function update<T>(endpoint: string, callback: UpdateCallback<T>): undefined {\n const fullPath = path.join(this.cachePath, `${this.options.hash(endpoint)}.json`);\n\n mkdirp(this.cachePath, (err) => {\n if (err && err.code !== 'EEXIST') return callback(err);\n\n get(endpoint).json((err, res) => {\n if (err) return callback(err);\n const record = { headers: res.headers, body: res.body } as Record<T>;\n const tempFile = `${fullPath}-${tempSuffix()}`;\n\n const queue = new Queue(1);\n queue.defer(fs.writeFile.bind(null, tempFile, JSON.stringify(record), 'utf8'));\n queue.defer((cb) => rm(fullPath, cb.bind(null, null)));\n queue.defer(fs.rename.bind(null, tempFile, fullPath));\n queue.await((err) => {\n if (!err) return callback(null, record.body);\n // cleanup the temp file if the operation failed\n rm(tempFile, callback.bind(err));\n });\n });\n });\n}\n"],"names":["update","endpoint","callback","fullPath","path","join","cachePath","options","hash","mkdirp","err","code","get","json","res","record","headers","body","tempFile","tempSuffix","queue","Queue","defer","fs","writeFile","bind","JSON","stringify","cb","rm","rename","await"],"mappings":";;;;+BAUA;;;eAAwBA;;;yDAVT;8BACI;gEACH;oEACG;2DACF;8DACC;iEACK;;;;;;AAIR,SAASA,OAAUC,QAAgB,EAAEC,QAA2B;IAC7E,IAAMC,WAAWC,aAAI,CAACC,IAAI,CAAC,IAAI,CAACC,SAAS,EAAE,AAAC,GAA8B,OAA5B,IAAI,CAACC,OAAO,CAACC,IAAI,CAACP,WAAU;IAE1EQ,IAAAA,sBAAM,EAAC,IAAI,CAACH,SAAS,EAAE,SAACI;QACtB,IAAIA,OAAOA,IAAIC,IAAI,KAAK,UAAU,OAAOT,SAASQ;QAElDE,IAAAA,kBAAG,EAACX,UAAUY,IAAI,CAAC,SAACH,KAAKI;YACvB,IAAIJ,KAAK,OAAOR,SAASQ;YACzB,IAAMK,SAAS;gBAAEC,SAASF,IAAIE,OAAO;gBAAEC,MAAMH,IAAIG,IAAI;YAAC;YACtD,IAAMC,WAAW,AAAC,GAAcC,OAAZhB,UAAS,KAAgB,OAAbgB,IAAAA,mBAAU;YAE1C,IAAMC,QAAQ,IAAIC,gBAAK,CAAC;YACxBD,MAAME,KAAK,CAACC,WAAE,CAACC,SAAS,CAACC,IAAI,CAAC,MAAMP,UAAUQ,KAAKC,SAAS,CAACZ,SAAS;YACtEK,MAAME,KAAK,CAAC,SAACM;uBAAOC,IAAAA,kBAAE,EAAC1B,UAAUyB,GAAGH,IAAI,CAAC,MAAM;;YAC/CL,MAAME,KAAK,CAACC,WAAE,CAACO,MAAM,CAACL,IAAI,CAAC,MAAMP,UAAUf;YAC3CiB,MAAMW,KAAK,CAAC,SAACrB;gBACX,IAAI,CAACA,KAAK,OAAOR,SAAS,MAAMa,OAAOE,IAAI;gBAC3C,gDAAgD;gBAChDY,IAAAA,kBAAE,EAACX,UAAUhB,SAASuB,IAAI,CAACf;YAC7B;QACF;IACF;AACF"}
|
package/dist/esm/Cache.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { safeRm } from 'fs-remove-compat';
|
|
2
2
|
import get from './get.js';
|
|
3
3
|
import getSync from './getSync.js';
|
|
4
4
|
import hash from './hash.js';
|
|
@@ -23,9 +23,7 @@ let Cache = class Cache {
|
|
|
23
23
|
clear(callback) {
|
|
24
24
|
function worker(callback) {
|
|
25
25
|
// ignore errors since it is fine to delete a directory that doesn't exist from a cache standpoint
|
|
26
|
-
|
|
27
|
-
disableGlob: true
|
|
28
|
-
}, callback.bind(null, null));
|
|
26
|
+
safeRm(this.cachePath, callback.bind(null, null));
|
|
29
27
|
}
|
|
30
28
|
if (typeof callback === 'function') return worker.call(this, callback);
|
|
31
29
|
return new Promise((resolve, reject)=>worker.call(this, (err)=>{
|
package/dist/esm/Cache.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/fetch-json-cache/src/Cache.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/fetch-json-cache/src/Cache.ts"],"sourcesContent":["import { safeRm } from 'fs-remove-compat';\n\nimport get from './get.ts';\nimport getSync from './getSync.ts';\nimport hash from './hash.ts';\nimport type { CacheOptions, ClearCallback, GetCallback, GetOptions } from './types.ts';\nimport update from './update.ts';\n\nexport default class Cache {\n cachePath: string;\n options: CacheOptions;\n\n constructor(cachePath: string, options: CacheOptions = {}) {\n if (!(this instanceof Cache)) throw new Error('Cache needs to be called with new');\n if (!cachePath) throw new Error('Cache needs cachePath');\n this.cachePath = cachePath;\n this.options = options;\n if (!this.options.hash) this.options.hash = hash;\n }\n\n get<T>(endpoint: string, options?: GetOptions | GetCallback<T>, callback?: GetCallback<T>): undefined | Promise<object | null> {\n if (typeof options === 'function') {\n callback = options as GetCallback<T>;\n options = null;\n }\n options = options || {};\n\n function worker(endpoint, options, callback) {\n (options as GetOptions).force ? update.call(this, endpoint, callback) : get.call(this, endpoint, callback);\n }\n\n if (typeof callback === 'function') return worker.call(this, endpoint, options, callback) as undefined;\n return new Promise((resolve, reject) => worker.call(this, endpoint, options, (err, json) => (err ? reject(err) : resolve(json))));\n }\n\n getSync<T>(endpoint: string): T | null {\n // TODO: add async fetching\n return getSync.call(this, endpoint);\n }\n\n clear(callback?: ClearCallback): undefined | Promise<undefined> {\n function worker(callback) {\n // ignore errors since it is fine to delete a directory that doesn't exist from a cache standpoint\n safeRm(this.cachePath, callback.bind(null, null));\n }\n\n if (typeof callback === 'function') return worker.call(this, callback);\n return new Promise((resolve, reject) =>\n worker.call(this, (err) => {\n err ? reject(err) : resolve(undefined);\n })\n );\n }\n}\n"],"names":["safeRm","get","getSync","hash","update","Cache","endpoint","options","callback","worker","force","call","Promise","resolve","reject","err","json","clear","cachePath","bind","undefined","Error"],"mappings":"AAAA,SAASA,MAAM,QAAQ,mBAAmB;AAE1C,OAAOC,SAAS,WAAW;AAC3B,OAAOC,aAAa,eAAe;AACnC,OAAOC,UAAU,YAAY;AAE7B,OAAOC,YAAY,cAAc;AAElB,IAAA,AAAMC,QAAN,MAAMA;IAYnBJ,IAAOK,QAAgB,EAAEC,OAAqC,EAAEC,QAAyB,EAAsC;QAC7H,IAAI,OAAOD,YAAY,YAAY;YACjCC,WAAWD;YACXA,UAAU;QACZ;QACAA,UAAUA,WAAW,CAAC;QAEtB,SAASE,OAAOH,QAAQ,EAAEC,OAAO,EAAEC,QAAQ;YACxCD,QAAuBG,KAAK,GAAGN,OAAOO,IAAI,CAAC,IAAI,EAAEL,UAAUE,YAAYP,IAAIU,IAAI,CAAC,IAAI,EAAEL,UAAUE;QACnG;QAEA,IAAI,OAAOA,aAAa,YAAY,OAAOC,OAAOE,IAAI,CAAC,IAAI,EAAEL,UAAUC,SAASC;QAChF,OAAO,IAAII,QAAQ,CAACC,SAASC,SAAWL,OAAOE,IAAI,CAAC,IAAI,EAAEL,UAAUC,SAAS,CAACQ,KAAKC,OAAUD,MAAMD,OAAOC,OAAOF,QAAQG;IAC3H;IAEAd,QAAWI,QAAgB,EAAY;QACrC,2BAA2B;QAC3B,OAAOJ,QAAQS,IAAI,CAAC,IAAI,EAAEL;IAC5B;IAEAW,MAAMT,QAAwB,EAAkC;QAC9D,SAASC,OAAOD,QAAQ;YACtB,kGAAkG;YAClGR,OAAO,IAAI,CAACkB,SAAS,EAAEV,SAASW,IAAI,CAAC,MAAM;QAC7C;QAEA,IAAI,OAAOX,aAAa,YAAY,OAAOC,OAAOE,IAAI,CAAC,IAAI,EAAEH;QAC7D,OAAO,IAAII,QAAQ,CAACC,SAASC,SAC3BL,OAAOE,IAAI,CAAC,IAAI,EAAE,CAACI;gBACjBA,MAAMD,OAAOC,OAAOF,QAAQO;YAC9B;IAEJ;IAxCA,YAAYF,SAAiB,EAAEX,UAAwB,CAAC,CAAC,CAAE;QACzD,IAAI,CAAE,CAAA,IAAI,YAAYF,KAAI,GAAI,MAAM,IAAIgB,MAAM;QAC9C,IAAI,CAACH,WAAW,MAAM,IAAIG,MAAM;QAChC,IAAI,CAACH,SAAS,GAAGA;QACjB,IAAI,CAACX,OAAO,GAAGA;QACf,IAAI,CAAC,IAAI,CAACA,OAAO,CAACJ,IAAI,EAAE,IAAI,CAACI,OAAO,CAACJ,IAAI,GAAGA;IAC9C;AAmCF;AA7CA,SAAqBE,mBA6CpB"}
|
package/dist/esm/update.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
+
import { rm } from 'fs-remove-compat';
|
|
2
3
|
import get from 'get-remote';
|
|
3
4
|
import mkdirp from 'mkdirp-classic';
|
|
4
5
|
import path from 'path';
|
|
5
6
|
import Queue from 'queue-cb';
|
|
6
|
-
import rimraf2 from 'rimraf2';
|
|
7
7
|
import tempSuffix from 'temp-suffix';
|
|
8
8
|
export default function update(endpoint, callback) {
|
|
9
9
|
const fullPath = path.join(this.cachePath, `${this.options.hash(endpoint)}.json`);
|
|
@@ -18,16 +18,12 @@ export default function update(endpoint, callback) {
|
|
|
18
18
|
const tempFile = `${fullPath}-${tempSuffix()}`;
|
|
19
19
|
const queue = new Queue(1);
|
|
20
20
|
queue.defer(fs.writeFile.bind(null, tempFile, JSON.stringify(record), 'utf8'));
|
|
21
|
-
queue.defer((cb)=>
|
|
22
|
-
disableGlob: true
|
|
23
|
-
}, cb.bind(null, null)));
|
|
21
|
+
queue.defer((cb)=>rm(fullPath, cb.bind(null, null)));
|
|
24
22
|
queue.defer(fs.rename.bind(null, tempFile, fullPath));
|
|
25
23
|
queue.await((err)=>{
|
|
26
24
|
if (!err) return callback(null, record.body);
|
|
27
25
|
// cleanup the temp file if the operation failed
|
|
28
|
-
|
|
29
|
-
disableGlob: true
|
|
30
|
-
}, callback.bind(err));
|
|
26
|
+
rm(tempFile, callback.bind(err));
|
|
31
27
|
});
|
|
32
28
|
});
|
|
33
29
|
});
|
package/dist/esm/update.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/fetch-json-cache/src/update.ts"],"sourcesContent":["import fs from 'fs';\nimport get from 'get-remote';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/fetch-json-cache/src/update.ts"],"sourcesContent":["import fs from 'fs';\nimport { rm } from 'fs-remove-compat';\nimport get from 'get-remote';\nimport mkdirp from 'mkdirp-classic';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport tempSuffix from 'temp-suffix';\n\nimport type { Record, UpdateCallback } from './types.ts';\n\nexport default function update<T>(endpoint: string, callback: UpdateCallback<T>): undefined {\n const fullPath = path.join(this.cachePath, `${this.options.hash(endpoint)}.json`);\n\n mkdirp(this.cachePath, (err) => {\n if (err && err.code !== 'EEXIST') return callback(err);\n\n get(endpoint).json((err, res) => {\n if (err) return callback(err);\n const record = { headers: res.headers, body: res.body } as Record<T>;\n const tempFile = `${fullPath}-${tempSuffix()}`;\n\n const queue = new Queue(1);\n queue.defer(fs.writeFile.bind(null, tempFile, JSON.stringify(record), 'utf8'));\n queue.defer((cb) => rm(fullPath, cb.bind(null, null)));\n queue.defer(fs.rename.bind(null, tempFile, fullPath));\n queue.await((err) => {\n if (!err) return callback(null, record.body);\n // cleanup the temp file if the operation failed\n rm(tempFile, callback.bind(err));\n });\n });\n });\n}\n"],"names":["fs","rm","get","mkdirp","path","Queue","tempSuffix","update","endpoint","callback","fullPath","join","cachePath","options","hash","err","code","json","res","record","headers","body","tempFile","queue","defer","writeFile","bind","JSON","stringify","cb","rename","await"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,SAASC,EAAE,QAAQ,mBAAmB;AACtC,OAAOC,SAAS,aAAa;AAC7B,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,gBAAgB,cAAc;AAIrC,eAAe,SAASC,OAAUC,QAAgB,EAAEC,QAA2B;IAC7E,MAAMC,WAAWN,KAAKO,IAAI,CAAC,IAAI,CAACC,SAAS,EAAE,GAAG,IAAI,CAACC,OAAO,CAACC,IAAI,CAACN,UAAU,KAAK,CAAC;IAEhFL,OAAO,IAAI,CAACS,SAAS,EAAE,CAACG;QACtB,IAAIA,OAAOA,IAAIC,IAAI,KAAK,UAAU,OAAOP,SAASM;QAElDb,IAAIM,UAAUS,IAAI,CAAC,CAACF,KAAKG;YACvB,IAAIH,KAAK,OAAON,SAASM;YACzB,MAAMI,SAAS;gBAAEC,SAASF,IAAIE,OAAO;gBAAEC,MAAMH,IAAIG,IAAI;YAAC;YACtD,MAAMC,WAAW,GAAGZ,SAAS,CAAC,EAAEJ,cAAc;YAE9C,MAAMiB,QAAQ,IAAIlB,MAAM;YACxBkB,MAAMC,KAAK,CAACxB,GAAGyB,SAAS,CAACC,IAAI,CAAC,MAAMJ,UAAUK,KAAKC,SAAS,CAACT,SAAS;YACtEI,MAAMC,KAAK,CAAC,CAACK,KAAO5B,GAAGS,UAAUmB,GAAGH,IAAI,CAAC,MAAM;YAC/CH,MAAMC,KAAK,CAACxB,GAAG8B,MAAM,CAACJ,IAAI,CAAC,MAAMJ,UAAUZ;YAC3Ca,MAAMQ,KAAK,CAAC,CAAChB;gBACX,IAAI,CAACA,KAAK,OAAON,SAAS,MAAMU,OAAOE,IAAI;gBAC3C,gDAAgD;gBAChDpB,GAAGqB,UAAUb,SAASiB,IAAI,CAACX;YAC7B;QACF;IACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fetch-json-cache",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.11",
|
|
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",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"version": "tsds version"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
+
"fs-remove-compat": "*",
|
|
41
42
|
"get-remote": "*",
|
|
42
43
|
"mkdirp-classic": "*",
|
|
43
44
|
"queue-cb": "*",
|
|
44
|
-
"rimraf2": "*",
|
|
45
45
|
"temp-suffix": "*"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|