mentie 0.1.12 → 0.1.14

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.
@@ -81,7 +81,8 @@ export const log_environment = logger => {
81
81
  environment: {
82
82
  dev,
83
83
  is_emulator,
84
- is_cypress
84
+ is_cypress,
85
+ loglevel
85
86
  }
86
87
  }
87
88
 
@@ -6,16 +6,16 @@
6
6
  * @param {number} [options.cooldown_in_s=10] - The cooldown time in seconds between retries.
7
7
  * @param {boolean} [options.cooldown_entropy=true] - Whether to add randomness to the cooldown time.
8
8
  * @param {Function} [options.logger=null] - The logger function to log retry attempts.
9
- * @returns {Function} - The retryable function.
9
+ * @returns {Promise<Function>} - The retryable function.
10
10
  * @example
11
11
  * make_retryable( do_thing )
12
12
  * make_retryable( () => fetch( 'https://api.com/data' ) )
13
- * @see {@link https://www.npmjs.com/package/promise-retry|promise-retry}
13
+ * @see {@link https://www.npmjs.com/package/promise-retry}
14
14
  */
15
15
  export async function make_retryable( async_function, { retry_times=5, cooldown_in_s=10, cooldown_entropy=true, logger=null } ) {
16
16
 
17
17
  // Function dependencies
18
- const Retrier = await import( 'promise-retry' )
18
+ const { default: Retrier } = await import( 'promise-retry' )
19
19
  const { wait } = await import( './time.js' )
20
20
 
21
21
  // Set a default logger that does nothing if none was provided
@@ -67,18 +67,18 @@ export async function make_retryable( async_function, { retry_times=5, cooldown_
67
67
  * @param {Function} [options.logger] - Progress callback function.
68
68
  * @param {boolean} [options.fail_fast=true] - Whether to fail fast or continue with other functions when an error occurs.
69
69
  * @returns {Promise<Array>} - A promise that resolves to an array of results from the async functions.
70
- * @see {@link https://www.npmjs.com/package/promise-parallel-throttle|promise-parallel-throttle}
70
+ * @see {@link https://www.npmjs.com/package/promise-parallel-throttle}
71
71
  */
72
72
  export async function throttle_and_retry( async_function_array=[], { max_parallel=2, retry_times, cooldown_in_s, cooldown_entropy, logger, fail_fast=true } ) {
73
73
 
74
74
  // Function dependencies
75
- const Throttle = await import( 'promise-parallel-throttle' )
75
+ const { default: Throttle } = await import( 'promise-parallel-throttle' )
76
76
 
77
77
  // Create array of retryable functions
78
- const retryable_async_functions = async_function_array.map( async_function => {
79
- const retryable_function = make_retryable( async_function, { retry_times, cooldown_in_s, logger, cooldown_entropy } )
78
+ const retryable_async_functions = Promise.all( async_function_array.map( async async_function => {
79
+ const retryable_function = await make_retryable( async_function, { retry_times, cooldown_in_s, logger, cooldown_entropy } )
80
80
  return retryable_function
81
- } )
81
+ } ) )
82
82
 
83
83
  // Throttle configuration
84
84
  const throttle_config = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mentie",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "Mentor's toolbelt",
5
5
  "type": "module",
6
6
  "main": "index.js",