@vpmedia/simplify 1.5.1 → 1.5.3

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @vpmedia/simplify
2
2
 
3
- [![npm version](https://badge.fury.io/js/@vpmedia%2Fsimplify.svg?v=1.5.1)](https://badge.fury.io/js/@vpmedia%2Fsimplify)
3
+ [![npm version](https://badge.fury.io/js/@vpmedia%2Fsimplify.svg?v=1.5.3)](https://badge.fury.io/js/@vpmedia%2Fsimplify)
4
4
  [![Node.js CI](https://github.com/vpmedia/simplify/actions/workflows/ci.yml/badge.svg)](https://github.com/vpmedia/simplify/actions/workflows/ci.yml)
5
5
 
6
6
  @vpmedia/simplify TBD
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vpmedia/simplify",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "description": "@vpmedia/simplify",
5
5
  "author": "Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)",
6
6
  "license": "MIT",
@@ -1,31 +1,31 @@
1
1
  import { Logger } from '../logging/Logger.js';
2
2
  import { delayPromise } from './delayPromise.js';
3
3
 
4
- const logger = new Logger('fetchRetry');
4
+ const logger = new Logger('fetch');
5
5
 
6
6
  /**
7
7
  * Fetch with retry.
8
8
  * @param {string | URL | Request} resource - Fetch URL.
9
9
  * @param {RequestInit} [fetchOptions] - Fetch options.
10
- * @param {{ delay?: number, numTries?: number, isLog?: boolean}} [retryOptions] - Retry options.
10
+ * @param {{delay?: number, numTries?: number}} [retryOptions] - Retry options.
11
11
  * @returns {Promise<Response>} Fetch result.
12
12
  */
13
13
  export const fetchRetry = async (resource, fetchOptions, retryOptions) => {
14
14
  retryOptions = retryOptions ?? {};
15
- retryOptions.delay = Math.max(retryOptions.delay ?? 1000, 1);
15
+ retryOptions.delay = Math.max(retryOptions.delay ?? 500, 1);
16
16
  retryOptions.numTries = Math.max(retryOptions.numTries ?? 3, 1);
17
17
  while (retryOptions.numTries > 0) {
18
- logger.info('Fetch request', { resource, fetchOptions, retryOptions });
18
+ logger.info('request', { resource, fetchOptions, retryOptions });
19
19
  try {
20
20
  const response = await fetch(resource, fetchOptions);
21
21
  if (!response.ok) {
22
- logger.warn('Fetch response', response);
23
- throw new Error(`Network error: ${response.status}`, { cause: response.status });
22
+ logger.warn('failure', response);
23
+ throw new Error(`fetch ${response.url} returned status ${response.status}`, { cause: response.status });
24
24
  }
25
- logger.info('Fetch response', response);
25
+ logger.info('success', response);
26
26
  return response;
27
27
  } catch (error) {
28
- logger.error('Fetch error', error instanceof Error ? error : new Error(String(error)));
28
+ logger.error('error', error instanceof Error ? error : new Error(String(error)));
29
29
  retryOptions.numTries -= 1;
30
30
  if (retryOptions.numTries === 0) {
31
31
  throw error;
@@ -1,6 +1,5 @@
1
1
  export function fetchRetry(resource: string | URL | Request, fetchOptions?: RequestInit, retryOptions?: {
2
2
  delay?: number;
3
3
  numTries?: number;
4
- isLog?: boolean;
5
4
  }): Promise<Response>;
6
5
  //# sourceMappingURL=fetchRetry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetchRetry.d.ts","sourceRoot":"","sources":["../../src/util/fetchRetry.js"],"names":[],"mappings":"AAYO,qCALI,MAAM,GAAG,GAAG,GAAG,OAAO,iBACtB,WAAW,iBACX;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAC,GACnD,OAAO,CAAC,QAAQ,CAAC,CA0B7B"}
1
+ {"version":3,"file":"fetchRetry.d.ts","sourceRoot":"","sources":["../../src/util/fetchRetry.js"],"names":[],"mappings":"AAYO,qCALI,MAAM,GAAG,GAAG,GAAG,OAAO,iBACtB,WAAW,iBACX;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAC,GACjC,OAAO,CAAC,QAAQ,CAAC,CA0B7B"}
package/CHANGES.md DELETED
@@ -1,53 +0,0 @@
1
- # Release notes
2
-
3
- All notable changes to this project will be documented in this file.
4
- This project adheres to [Semantic Versioning](http://semver.org/).
5
-
6
- ## 1.5.1
7
-
8
- - Bugfixes for fetch retry helper
9
-
10
- ## 1.5.0
11
-
12
- - Refactored fetch retry helper
13
-
14
- ## 1.4.0
15
-
16
- - Added fetch retry helper
17
-
18
- ## 1.3.0
19
-
20
- - Changed logger level initialization strategy
21
-
22
- ## 1.2.3
23
-
24
- - Fixed logger issue with vite compiled apps
25
-
26
- ## 1.2.0
27
-
28
- - Added Logger class
29
- - Fixed lint and typecheck issues
30
-
31
- ## 1.1.0
32
-
33
- - Updated dependencies
34
-
35
- ## 1.0.4
36
-
37
- - Reverted package module exports to main
38
-
39
- ## 1.0.3
40
-
41
- - Added deep object value getter / setter helpers
42
-
43
- ## 1.0.2
44
-
45
- - Added missing typescript typedefs
46
-
47
- ## 1.0.1
48
-
49
- - Changed export name, fixed input check
50
-
51
- ## 1.0.0
52
-
53
- - Initial release