mentie 0.1.3 → 0.1.4
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/modules/promises.js +2 -14
- package/package.json +5 -1
package/modules/promises.js
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Requests the dependencies needed for promises.
|
|
4
|
-
* The promise dependencies are not loaded by default to reduce recourse usage.
|
|
5
|
-
* @param {Error} e - The error object.
|
|
6
|
-
* @returns {Promise<void>} - A promise that resolves when the dependencies are loaded.
|
|
7
|
-
*/
|
|
8
|
-
const request_deps = async e => {
|
|
9
|
-
const { log } = await import( './logging.js' )
|
|
10
|
-
log.error( `🚨 Make sure to install the Promise dependencies with: "npm i -S promise-retry promise-parallel-throttle": `, e )
|
|
11
|
-
}
|
|
12
|
-
|
|
13
1
|
/**
|
|
14
2
|
* Creates a retryable function that wraps an async function and adds retry logic.
|
|
15
3
|
* @param {Function} async_function - The async function to be made retryable. MUST be an UNCALLED function. See example.
|
|
@@ -27,7 +15,7 @@ const request_deps = async e => {
|
|
|
27
15
|
export async function make_retryable( async_function, { retry_times=5, cooldown_in_s=10, cooldown_entropy=true, logger=null } ) {
|
|
28
16
|
|
|
29
17
|
// Function dependencies
|
|
30
|
-
const Retrier = await import( 'promise-retry' )
|
|
18
|
+
const Retrier = await import( 'promise-retry' )
|
|
31
19
|
const { wait } = await import( './time.js' )
|
|
32
20
|
|
|
33
21
|
// Set a default logger that does nothing if none was provided
|
|
@@ -84,7 +72,7 @@ export async function make_retryable( async_function, { retry_times=5, cooldown_
|
|
|
84
72
|
export async function throttle_and_retry( async_function_array=[], { max_parallel=2, retry_times, cooldown_in_s, cooldown_entropy, logger, fail_fast=true } ) {
|
|
85
73
|
|
|
86
74
|
// Function dependencies
|
|
87
|
-
const Throttle = await import( 'promise-parallel-throttle' )
|
|
75
|
+
const Throttle = await import( 'promise-parallel-throttle' )
|
|
88
76
|
|
|
89
77
|
// Create array of retryable functions
|
|
90
78
|
const retryable_async_functions = async_function_array.map( async_function => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mentie",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Mentor's toolbelt",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -26,5 +26,9 @@
|
|
|
26
26
|
"eslint-plugin-react": "^7.35.0",
|
|
27
27
|
"eslint-plugin-unused-imports": "^3.2.0",
|
|
28
28
|
"husky": "^9.1.3"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"promise-parallel-throttle": "^3.5.0",
|
|
32
|
+
"promise-retry": "^2.0.1"
|
|
29
33
|
}
|
|
30
34
|
}
|