fetch-json-cache 1.2.54 → 1.2.55
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/types.d.cts +5 -0
- package/dist/cjs/types.d.ts +5 -0
- package/dist/cjs/update.d.cts +2 -1
- package/dist/cjs/update.d.ts +2 -1
- package/dist/cjs/update.js.map +1 -1
- package/dist/esm/types.d.ts +5 -0
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/update.d.ts +2 -1
- package/dist/esm/update.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/types.d.cts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export interface Record {
|
|
2
|
+
headers: object;
|
|
3
|
+
body: JSON;
|
|
4
|
+
}
|
|
1
5
|
export interface CacheOptions {
|
|
2
6
|
hash?: (string: string) => string;
|
|
3
7
|
}
|
|
@@ -6,3 +10,4 @@ export interface GetOptions {
|
|
|
6
10
|
}
|
|
7
11
|
export type GetCallback = (error?: Error, json?: JSON) => undefined;
|
|
8
12
|
export type ClearCallback = (error?: Error) => undefined;
|
|
13
|
+
export type UpdateCallback = (error?: Error, json?: JSON) => undefined;
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export interface Record {
|
|
2
|
+
headers: object;
|
|
3
|
+
body: JSON;
|
|
4
|
+
}
|
|
1
5
|
export interface CacheOptions {
|
|
2
6
|
hash?: (string: string) => string;
|
|
3
7
|
}
|
|
@@ -6,3 +10,4 @@ export interface GetOptions {
|
|
|
6
10
|
}
|
|
7
11
|
export type GetCallback = (error?: Error, json?: JSON) => undefined;
|
|
8
12
|
export type ClearCallback = (error?: Error) => undefined;
|
|
13
|
+
export type UpdateCallback = (error?: Error, json?: JSON) => undefined;
|
package/dist/cjs/update.d.cts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { UpdateCallback } from './types.ts';
|
|
2
|
+
export default function update(endpoint: string, callback: UpdateCallback): undefined;
|
package/dist/cjs/update.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { UpdateCallback } from './types.ts';
|
|
2
|
+
export default function update(endpoint: string, callback: UpdateCallback): undefined;
|
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 rimraf2 from 'rimraf2';\nimport tempSuffix from 'temp-suffix';\n\nexport default function update(endpoint, callback) {\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 };\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) => rimraf2(fullPath, { disableGlob: true }, 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 rimraf2(tempFile, { disableGlob: true }, 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","rimraf2","disableGlob","rename","await"],"mappings":";;;;+
|
|
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 rimraf2 from 'rimraf2';\nimport tempSuffix from 'temp-suffix';\n\nimport type { Record, UpdateCallback } from './types.ts';\n\nexport default function update(endpoint: string, callback: UpdateCallback): 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;\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) => rimraf2(fullPath, { disableGlob: true }, 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 rimraf2(tempFile, { disableGlob: true }, 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","rimraf2","disableGlob","rename","await"],"mappings":";;;;+BAUA;;;eAAwBA;;;yDAVT;gEACC;oEACG;2DACF;8DACC;8DACE;iEACG;;;;;;AAIR,SAASA,OAAOC,QAAgB,EAAEC,QAAwB;IACvE,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,gBAAO,EAAC1B,UAAU;oBAAE2B,aAAa;gBAAK,GAAGF,GAAGH,IAAI,CAAC,MAAM;;YAC3EL,MAAME,KAAK,CAACC,WAAE,CAACQ,MAAM,CAACN,IAAI,CAAC,MAAMP,UAAUf;YAC3CiB,MAAMY,KAAK,CAAC,SAACtB;gBACX,IAAI,CAACA,KAAK,OAAOR,SAAS,MAAMa,OAAOE,IAAI;gBAC3C,gDAAgD;gBAChDY,IAAAA,gBAAO,EAACX,UAAU;oBAAEY,aAAa;gBAAK,GAAG5B,SAASuB,IAAI,CAACf;YACzD;QACF;IACF;AACF"}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export interface Record {
|
|
2
|
+
headers: object;
|
|
3
|
+
body: JSON;
|
|
4
|
+
}
|
|
1
5
|
export interface CacheOptions {
|
|
2
6
|
hash?: (string: string) => string;
|
|
3
7
|
}
|
|
@@ -6,3 +10,4 @@ export interface GetOptions {
|
|
|
6
10
|
}
|
|
7
11
|
export type GetCallback = (error?: Error, json?: JSON) => undefined;
|
|
8
12
|
export type ClearCallback = (error?: Error) => undefined;
|
|
13
|
+
export type UpdateCallback = (error?: Error, json?: JSON) => undefined;
|
package/dist/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/fetch-json-cache/src/types.ts"],"sourcesContent":["export interface CacheOptions {\n hash?: (string: string) => string;\n}\n\nexport interface GetOptions {\n force?: boolean;\n}\nexport type GetCallback = (error?: Error, json?: JSON) => undefined;\nexport type ClearCallback = (error?: Error) => undefined;\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/fetch-json-cache/src/types.ts"],"sourcesContent":["export interface Record {\n headers: object;\n body: JSON;\n}\n\nexport interface CacheOptions {\n hash?: (string: string) => string;\n}\n\nexport interface GetOptions {\n force?: boolean;\n}\nexport type GetCallback = (error?: Error, json?: JSON) => undefined;\nexport type ClearCallback = (error?: Error) => undefined;\nexport type UpdateCallback = (error?: Error, json?: JSON) => undefined;\n"],"names":[],"mappings":"AAcA,WAAuE"}
|
package/dist/esm/update.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { UpdateCallback } from './types.ts';
|
|
2
|
+
export default function update(endpoint: string, callback: UpdateCallback): undefined;
|
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 rimraf2 from 'rimraf2';\nimport tempSuffix from 'temp-suffix';\n\nexport default function update(endpoint, callback) {\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 };\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) => rimraf2(fullPath, { disableGlob: true }, 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 rimraf2(tempFile, { disableGlob: true }, callback.bind(err));\n });\n });\n });\n}\n"],"names":["fs","get","mkdirp","path","Queue","rimraf2","tempSuffix","update","endpoint","callback","fullPath","join","cachePath","options","hash","err","code","json","res","record","headers","body","tempFile","queue","defer","writeFile","bind","JSON","stringify","cb","disableGlob","rename","await"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,SAAS,aAAa;AAC7B,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,aAAa,UAAU;AAC9B,OAAOC,gBAAgB,cAAc;
|
|
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 rimraf2 from 'rimraf2';\nimport tempSuffix from 'temp-suffix';\n\nimport type { Record, UpdateCallback } from './types.ts';\n\nexport default function update(endpoint: string, callback: UpdateCallback): 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;\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) => rimraf2(fullPath, { disableGlob: true }, 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 rimraf2(tempFile, { disableGlob: true }, callback.bind(err));\n });\n });\n });\n}\n"],"names":["fs","get","mkdirp","path","Queue","rimraf2","tempSuffix","update","endpoint","callback","fullPath","join","cachePath","options","hash","err","code","json","res","record","headers","body","tempFile","queue","defer","writeFile","bind","JSON","stringify","cb","disableGlob","rename","await"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,SAAS,aAAa;AAC7B,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,aAAa,UAAU;AAC9B,OAAOC,gBAAgB,cAAc;AAIrC,eAAe,SAASC,OAAOC,QAAgB,EAAEC,QAAwB;IACvE,MAAMC,WAAWP,KAAKQ,IAAI,CAAC,IAAI,CAACC,SAAS,EAAE,GAAG,IAAI,CAACC,OAAO,CAACC,IAAI,CAACN,UAAU,KAAK,CAAC;IAEhFN,OAAO,IAAI,CAACU,SAAS,EAAE,CAACG;QACtB,IAAIA,OAAOA,IAAIC,IAAI,KAAK,UAAU,OAAOP,SAASM;QAElDd,IAAIO,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,IAAInB,MAAM;YACxBmB,MAAMC,KAAK,CAACxB,GAAGyB,SAAS,CAACC,IAAI,CAAC,MAAMJ,UAAUK,KAAKC,SAAS,CAACT,SAAS;YACtEI,MAAMC,KAAK,CAAC,CAACK,KAAOxB,QAAQK,UAAU;oBAAEoB,aAAa;gBAAK,GAAGD,GAAGH,IAAI,CAAC,MAAM;YAC3EH,MAAMC,KAAK,CAACxB,GAAG+B,MAAM,CAACL,IAAI,CAAC,MAAMJ,UAAUZ;YAC3Ca,MAAMS,KAAK,CAAC,CAACjB;gBACX,IAAI,CAACA,KAAK,OAAON,SAAS,MAAMU,OAAOE,IAAI;gBAC3C,gDAAgD;gBAChDhB,QAAQiB,UAAU;oBAAEQ,aAAa;gBAAK,GAAGrB,SAASiB,IAAI,CAACX;YACzD;QACF;IACF;AACF"}
|
package/package.json
CHANGED