fetch-json-cache 1.3.6 → 1.3.7

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.
@@ -0,0 +1,9 @@
1
+ import type { CacheOptions, ClearCallback, GetCallback, GetOptions } from './types.js';
2
+ export default class Cache {
3
+ cachePath: string;
4
+ options: CacheOptions;
5
+ constructor(cachePath: string, options?: CacheOptions);
6
+ get<T>(endpoint: string, options?: GetOptions | GetCallback<T>, callback?: GetCallback<T>): undefined | Promise<object | null>;
7
+ getSync<T>(endpoint: string): T | null;
8
+ clear(callback?: ClearCallback): undefined | Promise<undefined>;
9
+ }
@@ -0,0 +1,2 @@
1
+ import type { GetCallback } from './types.js';
2
+ export default function getCache<T>(endpoint: string, callback: GetCallback<T>): undefined;
@@ -0,0 +1 @@
1
+ export default function getCacheAsync<T>(endpoint: string): T;
@@ -0,0 +1 @@
1
+ export default function hash(data: string): string;
@@ -0,0 +1,2 @@
1
+ export { default } from './Cache.js';
2
+ export * from './types.js';
@@ -0,0 +1,13 @@
1
+ export interface Record<T> {
2
+ headers: object;
3
+ body: T;
4
+ }
5
+ export interface CacheOptions {
6
+ hash?: (string: string) => string;
7
+ }
8
+ export interface GetOptions {
9
+ force?: boolean;
10
+ }
11
+ export type GetCallback<T> = (error?: Error, result?: T) => undefined;
12
+ export type ClearCallback = (error?: Error) => undefined;
13
+ export type UpdateCallback<T> = (error?: Error, result?: T) => undefined;
@@ -0,0 +1,2 @@
1
+ import type { UpdateCallback } from './types.js';
2
+ export default function update<T>(endpoint: string, callback: UpdateCallback<T>): undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fetch-json-cache",
3
- "version": "1.3.6",
3
+ "version": "1.3.7",
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",