promise-logic 2.8.0 → 2.8.1
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 +8 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,11 +32,13 @@ Traditional Promise combinations (such as `Promise.all`, `Promise.race`) have na
|
|
|
32
32
|
5. **Timeout Control**
|
|
33
33
|
- `maxTimer`: Adds timeout functionality to any Promise operation (unit: milliseconds).
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
**Note**:
|
|
36
|
+
- After timeout, it immediately interrupts the execution of the current Promise chain and jumps to error handling
|
|
37
|
+
- However, please note that this does not cancel underlying asynchronous operations that have already started (such as network requests, file read/write, etc.)
|
|
36
38
|
|
|
37
39
|
6. **Extended Operations**
|
|
38
|
-
- `allFulfilled`: Returns all successful results. Returns immediately when a result exists
|
|
39
|
-
- `allRejected`: Returns all failed results. Returns immediately when a result exists
|
|
40
|
+
- `allFulfilled`: Returns all successful results in order. Returns immediately when a result exists.
|
|
41
|
+
- `allRejected`: Returns all failed results in order. Returns immediately when a result exists.
|
|
40
42
|
- `allSettled`: Returns all results (both successful and failed)
|
|
41
43
|
|
|
42
44
|
---
|
|
@@ -338,14 +340,13 @@ PromiseLogic.and<number>([Promise.resolve(1), Promise.resolve(2)]);
|
|
|
338
340
|
| `nor` | All Promises fail (no task succeeds), returns empty array; any success causes overall failure. |
|
|
339
341
|
| `xnor` | All Promises succeed or all fail (same state), returns success result array; otherwise throws `XNOR_ERROR`. |
|
|
340
342
|
| `not` | Inverts the result of a single Promise: success becomes failure, failure becomes success. |
|
|
341
|
-
| `majority` | More than specified threshold of Promises succeed, returns success result array; otherwise overall failure. Accepts `options` parameter, where `max` property can customize threshold (default: 0.5), range:
|
|
342
|
-
| `allFulfilled` | Returns all successful results as an array, ignoring failures. Returns immediately when a result exists, while maintaining input order. |
|
|
343
|
-
| `allRejected` | Returns all failed results as an array, ignoring successes. Returns immediately when a result exists, while maintaining input order. |
|
|
343
|
+
| `majority` | More than specified threshold of Promises succeed, returns success result array; otherwise overall failure. Accepts `options` parameter, where `max` property can customize threshold (default: 0.5), range: [0, 1]. |
|
|
344
|
+
| `allFulfilled` | Returns all successful results as an array, ignoring failures. Returns immediately when a result exists, while maintaining consistent input and output order. |
|
|
345
|
+
| `allRejected` | Returns all failed results as an array, ignoring successes. Returns immediately when a result exists, while maintaining consistent input and output order. |
|
|
344
346
|
| `allSettled` | Returns all results (both successful and failed) as an array. Equivalent to native `Promise.allSettled`. |
|
|
345
347
|
| `race` | Returns the first completed Promise result (regardless of success or failure). Equivalent to native `Promise.race`. |
|
|
346
348
|
| `maxTimer` | Adds timeout functionality to any Promise operation (unit: milliseconds). Supports custom timeout error messages. |
|
|
347
349
|
|
|
348
|
-
## **Note**: `maxTimer` can only detect timeout of Promise operations, cannot interrupt or cancel Promise operations themselves, this is a JavaScript characteristic.
|
|
349
350
|
|
|
350
351
|
### **6. Real-world Application Scenarios**
|
|
351
352
|
|
package/package.json
CHANGED