mentie 0.1.2 → 0.1.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,3 +1,7 @@
1
1
  # Mentie
2
2
 
3
- Mentor's favorite helpers.
3
+ Mentor's favorite helpers.
4
+
5
+ Notes:
6
+
7
+ - If you're going to use promise utilities `make_retryable` and `throttle_and_retry`, make sure to install their dependencies: `npm i -S promise-retry promise-parallel-throttle`
@@ -1,3 +1,15 @@
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
+
1
13
  /**
2
14
  * Creates a retryable function that wraps an async function and adds retry logic.
3
15
  * @param {Function} async_function - The async function to be made retryable. MUST be an UNCALLED function. See example.
@@ -15,7 +27,7 @@
15
27
  export async function make_retryable( async_function, { retry_times=5, cooldown_in_s=10, cooldown_entropy=true, logger=null } ) {
16
28
 
17
29
  // Function dependencies
18
- const Retrier = await import( 'promise-retry' )
30
+ const Retrier = await import( 'promise-retry' ).catch( request_deps )
19
31
  const { wait } = await import( './time.js' )
20
32
 
21
33
  // Set a default logger that does nothing if none was provided
@@ -72,7 +84,7 @@ export async function make_retryable( async_function, { retry_times=5, cooldown_
72
84
  export async function throttle_and_retry( async_function_array=[], { max_parallel=2, retry_times, cooldown_in_s, cooldown_entropy, logger, fail_fast=true } ) {
73
85
 
74
86
  // Function dependencies
75
- const Throttle = await import( 'promise-parallel-throttle' )
87
+ const Throttle = await import( 'promise-parallel-throttle' ).catch( request_deps )
76
88
 
77
89
  // Create array of retryable functions
78
90
  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.2",
3
+ "version": "0.1.3",
4
4
  "description": "Mentor's toolbelt",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -26,9 +26,5 @@
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
- "dependencies": {
31
- "promise-parallel-throttle": "^3.5.0",
32
- "promise-retry": "^2.0.1"
33
29
  }
34
30
  }