promise-logic 1.3.2 → 2.3.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.
Files changed (60) hide show
  1. package/README.md +213 -227
  2. package/dist/factory.cjs.js +15 -1
  3. package/dist/factory.cjs.js.map +1 -1
  4. package/dist/factory.esm.js +15 -1
  5. package/dist/factory.esm.js.map +1 -1
  6. package/dist/index.cjs.js +15 -1
  7. package/dist/index.cjs.js.map +1 -1
  8. package/dist/index.esm.js +15 -1
  9. package/dist/index.esm.js.map +1 -1
  10. package/dist/v2/factory.cjs.js +287 -0
  11. package/dist/v2/factory.cjs.js.map +1 -0
  12. package/dist/v2/factory.esm.js +285 -0
  13. package/dist/v2/factory.esm.js.map +1 -0
  14. package/dist/v2/gates/BaseGate.d.ts +6 -0
  15. package/dist/v2/gates/BaseGate.d.ts.map +1 -0
  16. package/dist/v2/gates/and.d.ts +5 -0
  17. package/dist/v2/gates/and.d.ts.map +1 -0
  18. package/dist/v2/gates/majority.d.ts +5 -0
  19. package/dist/v2/gates/majority.d.ts.map +1 -0
  20. package/dist/v2/gates/nand.d.ts +5 -0
  21. package/dist/v2/gates/nand.d.ts.map +1 -0
  22. package/dist/v2/gates/nor.d.ts +5 -0
  23. package/dist/v2/gates/nor.d.ts.map +1 -0
  24. package/dist/v2/gates/or.d.ts +5 -0
  25. package/dist/v2/gates/or.d.ts.map +1 -0
  26. package/dist/v2/gates/xnor.d.ts +5 -0
  27. package/dist/v2/gates/xnor.d.ts.map +1 -0
  28. package/dist/v2/gates/xor.d.ts +5 -0
  29. package/dist/v2/gates/xor.d.ts.map +1 -0
  30. package/dist/v2/index.cjs.js +289 -0
  31. package/dist/v2/index.cjs.js.map +1 -0
  32. package/dist/v2/index.esm.js +285 -0
  33. package/dist/v2/index.esm.js.map +1 -0
  34. package/dist/v2/ts/gates/BaseGate.d.ts +6 -0
  35. package/dist/v2/ts/gates/BaseGate.d.ts.map +1 -0
  36. package/dist/v2/ts/gates/and.d.ts +5 -0
  37. package/dist/v2/ts/gates/and.d.ts.map +1 -0
  38. package/dist/v2/ts/gates/majority.d.ts +5 -0
  39. package/dist/v2/ts/gates/majority.d.ts.map +1 -0
  40. package/dist/v2/ts/gates/nand.d.ts +5 -0
  41. package/dist/v2/ts/gates/nand.d.ts.map +1 -0
  42. package/dist/v2/ts/gates/nor.d.ts +5 -0
  43. package/dist/v2/ts/gates/nor.d.ts.map +1 -0
  44. package/dist/v2/ts/gates/or.d.ts +5 -0
  45. package/dist/v2/ts/gates/or.d.ts.map +1 -0
  46. package/dist/v2/ts/gates/xnor.d.ts +5 -0
  47. package/dist/v2/ts/gates/xnor.d.ts.map +1 -0
  48. package/dist/v2/ts/gates/xor.d.ts +5 -0
  49. package/dist/v2/ts/gates/xor.d.ts.map +1 -0
  50. package/dist/v2/types/factory.d.ts +10 -0
  51. package/dist/v2/types/index.d.ts +85 -0
  52. package/dist/v2/utils/v2/errors.d.ts +7 -0
  53. package/dist/v2/utils/v2/errors.d.ts.map +1 -0
  54. package/dist/v2/v2/PromiseLogic.d.ts +29 -0
  55. package/dist/v2/v2/PromiseLogic.d.ts.map +1 -0
  56. package/dist/v2/v2/factory.d.ts +7 -0
  57. package/dist/v2/v2/factory.d.ts.map +1 -0
  58. package/dist/v2/v2/index.d.ts +6 -0
  59. package/dist/v2/v2/index.d.ts.map +1 -0
  60. package/package.json +14 -10
package/README.md CHANGED
@@ -1,21 +1,48 @@
1
- # PromiseLogic
2
1
 
3
- > Compose promises with logic gate semantics - Forget APIs, remember logic.
2
+ # Promise Logic - Advanced Promise Logic Gates for Async Programming
4
3
 
5
- PromiseLogic is a comprehensive utility library that provides intuitive logical gate semantics for Promise composition. It extends the standard Promise API with logical operations that mirror digital circuit design, making asynchronous programming more intuitive and expressive.
4
+ Compose promises with logic gate semantics (AND, OR, NOT, XOR, NAND, NOR, XNOR, Majority). Forget APIs, remember logic.
6
5
 
7
- ## Philosophy
6
+ ## Features
8
7
 
9
- **"Forget APIs, remember logic."** - Replace fragmented API knowledge with fundamental logic concepts that work consistently across all asynchronous operations.
8
+ - **Logic Gate Semantics**: Extend Promise API with AND, OR, NOT, XOR, NAND, NOR, XNOR, Majority operations
9
+ - **Dual Entry Points**: Choose between JavaScript or enhanced TypeScript experience
10
+ - **Type Safety**: Complete TypeScript definitions with strict type checking
11
+ - **Promise Utilities**: Additional utilities like Flip-Flop state management
12
+ - **Zero Dependencies**: Pure JavaScript/TypeScript implementation
13
+ - **Tree Shakeable**: Optimized for modern bundlers
10
14
 
11
- ## Features
15
+ ## Recent Updates
16
+
17
+ ### Version 2.3.2 Highlights
18
+
19
+ **🚀 NOT Gate Implementation**
20
+ Introduced the NOT logic gate for promise inversion, enabling flexible negation patterns in asynchronous workflows:
21
+
22
+ ```javascript
23
+ // Success -> Failure transformation
24
+ await PromiseLogic.not(Promise.resolve('success')); // Rejects with 'success'
12
25
 
13
- - **Complete Logic Gate Semantics**: AND, OR, XOR, NAND, NOR, XNOR, Majority
14
- - **Extended Promise Operations**: All fulfilled/rejected results, complete settlement analysis
15
- - **Dual API Pattern**: Static class methods + Configurable factory function
16
- - **Production Ready**: Zero dependencies, complete TypeScript support
17
- - **Test Driven**: 100% test coverage with comprehensive edge cases
18
- - **Tree Shaking**: Optimized bundle output for modern build systems
26
+ // Failure -> Success transformation
27
+ const result = await PromiseLogic.not(Promise.reject('error')); // Resolves with 'error'
28
+ ```
29
+
30
+ **📦 Enhanced TypeScript System**
31
+ Completely revamped TypeScript architecture with:
32
+ - Full generic type propagation
33
+ - Strict type checking with zero `any` types
34
+ - Advanced type inference for all operations
35
+ - Seamless IDE integration with IntelliSense
36
+
37
+ **⚡ Performance Optimizations**
38
+ - Optimized internal logic for better efficiency
39
+ - Reduced memory overhead in gate operations
40
+ - Improved error handling and edge case management
41
+
42
+ **📚 Documentation Enhancements**
43
+ - Comprehensive API reference with TypeScript examples
44
+ - Better usage guidelines and best practices
45
+ - Clear entry point documentation for different environments
19
46
 
20
47
  ## Installation
21
48
 
@@ -25,290 +52,249 @@ npm install promise-logic
25
52
 
26
53
  ## Quick Start
27
54
 
28
- ### Basic Logic Gates
55
+ ### JavaScript (Default)
29
56
 
30
57
  ```javascript
58
+ // ES Modules
31
59
  import { PromiseLogic } from 'promise-logic';
32
60
 
33
- // AND logic - All promises must succeed (equivalent to Promise.all)
34
- const results = await PromiseLogic.and([
35
- fetch('/api/users'),
36
- fetch('/api/posts'),
37
- fetch('/api/comments')
38
- ]);
61
+ // CommonJS
62
+ const { PromiseLogic } = require('promise-logic');
39
63
 
40
- // OR logic - Any promise succeeds (short-circuits on first success)
41
- const data = await PromiseLogic.or([
42
- fetchPrimaryService(),
43
- fetchBackupService()
44
- ]);
45
-
46
- // XOR logic - Exactly one promise must succeed
47
- const uniqueResult = await PromiseLogic.xor([
48
- cacheLookup(),
49
- databaseQuery()
64
+ // Use logic gates
65
+ const results = await PromiseLogic.and([
66
+ Promise.resolve('data1'),
67
+ Promise.resolve('data2')
50
68
  ]);
69
+ // results = ['data1', 'data2']
51
70
  ```
52
71
 
53
- ### Advanced Logic Operations
72
+ ### TypeScript (Enhanced)
54
73
 
55
- ```javascript
56
- // NAND logic - Not all promises succeed (at least one failure)
57
- const hasFailures = await PromiseLogic.nand([
58
- validateInput(),
59
- checkPermissions(),
60
- verifyResources()
61
- ]);
74
+ ```typescript
75
+ // TypeScript version with full type inference
76
+ import { PromiseLogic } from 'promise-logic/typescript';
62
77
 
63
- // NOR logic - All promises must fail
64
- const allFailed = await PromiseLogic.nor([
65
- experimentalFeature(),
66
- deprecatedAPI()
67
- ]);
78
+ // Type-safe operations with automatic inference
79
+ const numbers = await PromiseLogic.and<number>([
80
+ Promise.resolve(1),
81
+ Promise.resolve(2)
82
+ ]);
68
83
 
69
- // Majority logic - More than half succeed
70
- const consensus = await PromiseLogic.majority([
71
- server1.query(),
72
- server2.query(),
73
- server3.query()
74
- ]);
84
+ const strings = await PromiseLogic.or<string>([
85
+ Promise.resolve('hello'),
86
+ Promise.resolve('world')
87
+ ]);
75
88
  ```
76
89
 
77
- ### Extended Result Analysis
90
+ ## Core Logic Gates
91
+
92
+ ### `and(promises)`
93
+ Resolves with all values when all promises fulfill. Equivalent to `Promise.all()`.
78
94
 
79
95
  ```javascript
80
- // Get only successful results
81
- const successes = await PromiseLogic.allFulfilled([
82
- apiCall1(),
83
- apiCall2(),
84
- apiCall3()
96
+ const results = await PromiseLogic.and([
97
+ Promise.resolve(1),
98
+ Promise.resolve(2),
99
+ Promise.resolve(3)
85
100
  ]);
101
+ // results = [1, 2, 3]
102
+ ```
86
103
 
87
- // Get only failure reasons
88
- const failures = await PromiseLogic.allRejected([
89
- riskyOperation1(),
90
- riskyOperation2()
91
- ]);
104
+ ### `or(promises)`
105
+ Resolves with the first fulfilled promise. Equivalent to `Promise.any()`.
92
106
 
107
+ ```javascript
108
+ const result = await PromiseLogic.or([
109
+ Promise.reject('error'),
110
+ Promise.resolve('success')
111
+ ]);
112
+ // result = 'success'
93
113
  ```
94
114
 
95
- ## API Reference
115
+ ### `xor(promises)`
116
+ Exclusive OR - resolves only when exactly one promise fulfills.
96
117
 
97
- ### Core Logic Gates
118
+ ```javascript
119
+ try {
120
+ const result = await PromiseLogic.xor([
121
+ Promise.reject('error1'),
122
+ Promise.resolve('success'),
123
+ Promise.reject('error2')
124
+ ]);
125
+ // result = 'success'
126
+ } catch (error) {
127
+ // Throws if zero or multiple promises fulfill
128
+ }
129
+ ```
98
130
 
99
- #### `PromiseLogic.and(iterable)`
100
- Equivalent to `Promise.all`. Resolves when all promises fulfill, rejects if any promise rejects.
131
+ ### `nand(promises)`
132
+ Not AND - resolves when not all promises fulfill.
101
133
 
102
- #### `PromiseLogic.or(iterable)`
103
- Resolves with the first successful promise. Rejects only if all promises reject.
134
+ ```javascript
135
+ const results = await PromiseLogic.nand([
136
+ Promise.resolve('success'),
137
+ Promise.reject('error')
138
+ ]);
139
+ // results = ['success']
140
+ ```
104
141
 
105
- #### `PromiseLogic.xor(iterable)`
106
- Resolves when exactly one promise fulfills. Rejects if zero or multiple promises fulfill.
142
+ ### `nor(promises)`
143
+ Not OR - resolves only when all promises reject.
107
144
 
108
- #### `PromiseLogic.nand(iterable)`
109
- Resolves when not all promises fulfill (at least one rejection). Rejects if all promises fulfill.
145
+ ```javascript
146
+ const results = await PromiseLogic.nor([
147
+ Promise.reject('error1'),
148
+ Promise.reject('error2')
149
+ ]);
150
+ // results = []
151
+ ```
110
152
 
111
- #### `PromiseLogic.nor(iterable)`
112
- Resolves when all promises reject. Rejects if any promise fulfills.
153
+ ### `xnor(promises)`
154
+ Exclusive NOR - resolves when all promises have the same outcome.
113
155
 
114
- #### `PromiseLogic.xnor(iterable)`
115
- Resolves when all promises fulfill or all reject. Rejects in mixed scenarios.
156
+ ```javascript
157
+ const results = await PromiseLogic.xnor([
158
+ Promise.resolve('a'),
159
+ Promise.resolve('b')
160
+ ]);
161
+ // results = ['a', 'b']
162
+ ```
116
163
 
117
- #### `PromiseLogic.majority(iterable)`
118
- Resolves when more than half of promises fulfill. Rejects otherwise.
164
+ ### `majority(promises)`
165
+ Resolves when majority (>50%) of promises fulfill.
119
166
 
120
- ### Extended Operations
167
+ ```javascript
168
+ const results = await PromiseLogic.majority([
169
+ Promise.resolve('a'),
170
+ Promise.resolve('b'),
171
+ Promise.reject('error')
172
+ ]);
173
+ // results = ['a', 'b']
174
+ ```
121
175
 
122
- #### `PromiseLogic.allFulfilled(iterable)`
123
- Always resolves with an array of fulfilled values (empty if none).
176
+ ## NOT Gate - New in v2.3.2
124
177
 
125
- #### `PromiseLogic.allRejected(iterable)`
126
- Always resolves with an array of rejection reasons (empty if none).
178
+ ### `not(promise)`
179
+ Inverts promise resolution - successful promises become rejections, and vice versa.
127
180
 
128
- ### Utility Methods
181
+ ```javascript
182
+ // Success -> Failure
183
+ try {
184
+ await PromiseLogic.not(Promise.resolve('success'));
185
+ } catch (error) {
186
+ console.log(error); // 'success'
187
+ }
129
188
 
130
- #### `PromiseLogic.race(iterable)`
131
- Equivalent to `Promise.race`. Resolves or rejects with the first settled promise.
189
+ // Failure -> Success
190
+ const result = await PromiseLogic.not(Promise.reject('error'));
191
+ console.log(result); // 'error'
192
+ ```
132
193
 
133
- #### `PromiseLogic.allSettled(iterable)`
134
- Equivalent to `Promise.allSettled`. Always resolves with settlement results.
194
+ **Use Cases:**
195
+ - Transform error handling patterns
196
+ - Create conditional promise flows
197
+ - Implement retry logic with inverted conditions
198
+ - Build fallback mechanisms
135
199
 
136
- #### `PromiseLogic.createFlipFlop(initialState?)`
137
- Creates a stateful flip-flop utility for managing boolean state transitions.
200
+ ## Advanced Utilities
138
201
 
139
- ## Factory Function
202
+ ### `race(promises)`
203
+ Equivalent to `Promise.race()`.
140
204
 
141
- Create customized instances with method name transformations:
205
+ ### `allSettled(promises)`
206
+ Equivalent to `Promise.allSettled()`.
142
207
 
143
- ```javascript
144
- import { createPromiseLogic } from 'promise-logic';
145
-
146
- // Default naming
147
- const logic = createPromiseLogic();
148
- await logic.and([promise1, promise2]);
149
-
150
- // With prefix
151
- const asyncLogic = createPromiseLogic({ prefix: 'async' });
152
- await asyncLogic.asyncand([promise1, promise2]);
153
-
154
- // With suffix
155
- const logicUtils = createPromiseLogic({ suffix: 'Logic' });
156
- await logicUtils.andLogic([promise1, promise2]);
157
-
158
- // With custom renaming
159
- const customLogic = createPromiseLogic({
160
- rename: {
161
- and: 'conjunction',
162
- or: 'disjunction',
163
- xor: 'exclusiveOr'
164
- }
165
- });
166
- await customLogic.conjunction([promise1, promise2]);
167
-
168
- // Combined transformations
169
- const advancedLogic = createPromiseLogic({
170
- prefix: 'async',
171
- suffix: 'Logic',
172
- rename: { and: 'conjunction' }
173
- });
174
- await advancedLogic.asyncconjunctionLogic([promise1, promise2]);
175
- ```
208
+ ### `allFulfilled(promises)`
209
+ Resolves with all fulfilled values, ignoring rejections.
176
210
 
177
- ## Real-World Examples
211
+ ### `allRejected(promises)`
212
+ Resolves with all rejection reasons, ignoring fulfillments.
178
213
 
179
- ### Service Orchestration
214
+ ### `createFlipFlop(initialState?)`
215
+ Creates a stateful flip-flop for managing boolean state across async operations.
180
216
 
181
217
  ```javascript
182
- // Load balancing with fallback
183
- const userData = await PromiseLogic.or([
184
- primaryUserService.getUser(id),
185
- secondaryUserService.getUser(id),
186
- cacheService.getUser(id)
187
- ]);
218
+ const flipFlop = PromiseLogic.createFlipFlop(false);
188
219
 
189
- // Multi-step validation
190
- const isValid = await PromiseLogic.and([
191
- validateEmail(email),
192
- validatePassword(password),
193
- checkRateLimit(ipAddress)
194
- ]);
220
+ // Get current state
221
+ console.log(flipFlop.getState()); // false
195
222
 
196
- // Consensus-based decision making
197
- const configuration = await PromiseLogic.majority([
198
- configServer1.getConfig(),
199
- configServer2.getConfig(),
200
- configServer3.getConfig()
201
- ]);
202
- ```
223
+ // Toggle state
224
+ await flipFlop.toggle();
225
+ console.log(flipFlop.getState()); // true
203
226
 
204
- ### Error Recovery & Analysis
227
+ // Wait for specific state
228
+ await flipFlop.waitFor(true); // Resolves immediately if already true
205
229
 
206
- ```javascript
207
- // Graceful degradation
208
- const [successfulResults, failedOperations] = await Promise.all([
209
- PromiseLogic.allFulfilled(operations),
210
- PromiseLogic.allRejected(operations)
211
- ]);
230
+ // Async state change
231
+ setTimeout(() => flipFlop.set(false), 100);
232
+ await flipFlop.waitForChange(); // Waits for state change
212
233
  ```
213
234
 
214
- ### State Management
235
+ ## TypeScript Support - Enhanced in v2.3.2
215
236
 
216
- ```javascript
217
- // Flip-flop for toggle operations
218
- const toggle = PromiseLogic.createFlipFlop(false);
237
+ The TypeScript version (`promise-logic/typescript`) provides:
219
238
 
220
- // Toggle state and wait for change
221
- await toggle.toggle();
222
- console.log(toggle.getState()); // true
239
+ - **Full Type Inference**: Automatic type deduction for all operations
240
+ - **Strict Type Checking**: Zero `any` types, complete type safety
241
+ - **IDE Support**: Enhanced IntelliSense and code completion
242
+ - **Generic Type Propagation**: Proper handling of complex generic scenarios
223
243
 
224
- // Set specific state
225
- await toggle.setState(false);
226
- ```
227
-
228
- ## Error Handling
244
+ ```typescript
245
+ import { PromiseLogic } from 'promise-logic/typescript';
229
246
 
230
- All logic gates throw `PromiseLogicError` with descriptive messages:
247
+ // TypeScript infers everything
248
+ const result = await PromiseLogic.and([
249
+ Promise.resolve({ id: 1, name: 'Alice' }),
250
+ Promise.resolve({ id: 2, name: 'Bob' })
251
+ ]);
252
+ // result type: Array<{ id: number, name: string }>
231
253
 
232
- ```javascript
233
- try {
234
- await PromiseLogic.xor([apiCall1(), apiCall2()]);
235
- } catch (error) {
236
- if (error.type === 'XOR_ERROR') {
237
- console.log('Expected exactly one successful call');
238
- }
239
- console.log('Failed promises:', error.results);
254
+ // Complex generic types work seamlessly
255
+ async function processPromises<T>(promises: Promise<T>[]): Promise<T[]> {
256
+ return await PromiseLogic.and(promises);
240
257
  }
241
258
  ```
242
259
 
243
- ## TypeScript Support
260
+ ## Entry Points
244
261
 
245
- Full TypeScript support with precise type inference:
262
+ | Import Path | Purpose | Recommended For |
263
+ |------------|---------|----------------|
264
+ | `promise-logic` | Default JavaScript version | General use, mixed codebases |
265
+ | `promise-logic/typescript` | Enhanced TypeScript version | TypeScript projects, strict type safety |
246
266
 
247
- ```typescript
248
- import { PromiseLogic } from 'promise-logic';
267
+ ## Migration Note
249
268
 
250
- // Type inference for successful results
251
- const numbers: number[] = await PromiseLogic.and([
252
- Promise.resolve(1),
253
- Promise.resolve(2),
254
- Promise.resolve(3)
255
- ]);
256
-
257
- // Type-safe error handling
258
- try {
259
- await PromiseLogic.nand(operations);
260
- } catch (error: PromiseLogicError) {
261
- // error has full type information
262
- }
263
- ```
269
+ If you're upgrading from earlier versions, note that the TypeScript system has been completely redesigned for better type safety and developer experience. All existing APIs remain compatible.
264
270
 
265
- ## Advanced Usage
271
+ ## Development
266
272
 
267
- ### Custom Logic Composition
273
+ ```bash
274
+ # Install dependencies
275
+ npm install
268
276
 
269
- ```javascript
270
- // Create complex logic flows
271
- async function advancedOperation(promises) {
272
- const [successes, failures] = await Promise.all([
273
- PromiseLogic.allFulfilled(promises),
274
- PromiseLogic.allRejected(promises)
275
- ]);
277
+ # Build the project
278
+ npm run build
276
279
 
277
- if (successes.length >= failures.length) {
278
- return { data: successes, warnings: failures };
279
- } else {
280
- throw new Error('Operation mostly failed');
281
- }
282
- }
283
- ```
280
+ # Run tests
281
+ npm test
284
282
 
285
- ### Performance Optimization
283
+ # Run tests in watch mode
284
+ npm run test:watch
286
285
 
287
- ```javascript
288
- // Batch processing with logic gates
289
- const batches = chunkArray(operations, BATCH_SIZE);
290
- const batchResults = await PromiseLogic.allFulfilled(
291
- batches.map(batch => PromiseLogic.and(batch))
292
- );
293
-
294
- // Flatten results
295
- const allResults = batchResults.flat();
286
+ # Check code coverage
287
+ npm run test:coverage
296
288
  ```
297
289
 
298
290
  ## Contributing
299
291
 
300
- We welcome contributions! Please see our Contributing Guide for details.
292
+ 1. Fork the repository
293
+ 2. Create a feature branch
294
+ 3. Make your changes
295
+ 4. Add tests for new functionality
296
+ 5. Submit a pull request
301
297
 
302
298
  ## License
303
299
 
304
- MIT License - see LICENSE for details.
305
-
306
- ## Links
307
-
308
- - GitHub Repository: https://github.com/xier123456/promise-logic
309
- - npm Package: https://www.npmjs.com/package/promise-logic
310
- - Issue Tracker: https://github.com/xier123456/promise-logic/issues
311
-
312
- ---
313
-
314
- **PromiseLogic** - Making asynchronous logic as simple as digital circuits.
300
+ MIT © 2026
@@ -14,6 +14,7 @@ function createLogicError(type, fulfilledCount, total, results) {
14
14
  const messages = {
15
15
  XOR_ERROR: `XOR condition failed: expected exactly 1 promise to fulfill, but ${fulfilledCount} fulfilled.`,
16
16
  NAND_ERROR: `NAND condition failed: all ${total} promises fulfilled (expected at least one rejection).`,
17
+ NOT_ERROR: `NOT condition failed: promise resolved (expected rejection).`,
17
18
  NOR_ERROR: `NOR condition failed: ${fulfilledCount} promises fulfilled (expected all rejected).`,
18
19
  MAJORITY_ERROR: `Majority condition failed: ${fulfilledCount}/${total} fulfilled (need majority).`,
19
20
  ALL_SUCCESSFUL_ERROR: `All successful condition failed: ${fulfilledCount}/${total} promises fulfilled (expected all to succeed).`,
@@ -32,6 +33,15 @@ class PromiseLogic {
32
33
  return Promise.any(iterable);
33
34
  }
34
35
 
36
+
37
+ static not(promise) {
38
+ return Promise.resolve(promise).then(
39
+ (value) => Promise.reject(value),
40
+ (reason) => Promise.resolve(reason)
41
+ )
42
+ .catch((error) => Promise.resolve(error));
43
+ }
44
+
35
45
  static race(iterable) {
36
46
  return Promise.race(iterable);
37
47
  }
@@ -121,6 +131,7 @@ class PromiseLogic {
121
131
  });
122
132
  }
123
133
 
134
+
124
135
  // 返回所有成功的Promise结果
125
136
  static allFulfilled(iterable) {
126
137
  return Promise.allSettled(iterable).then((results) => {
@@ -203,10 +214,13 @@ function createPromiseLogic(options = {}) {
203
214
  race: PromiseLogic.race,
204
215
  allSettled: PromiseLogic.allSettled,
205
216
  xor: PromiseLogic.xor,
217
+ not: PromiseLogic.not,
206
218
  nand: PromiseLogic.nand,
207
219
  nor: PromiseLogic.nor,
208
220
  xnor: PromiseLogic.xnor,
209
- majority: PromiseLogic.majority
221
+ majority: PromiseLogic.majority,
222
+ allFulfilled: PromiseLogic.allFulfilled,
223
+ allRejected: PromiseLogic.allRejected
210
224
  };
211
225
 
212
226
  // 应用命名转换
@@ -1 +1 @@
1
- {"version":3,"file":"factory.cjs.js","sources":["../src/utils/errors.js","../src/PromiseLogic.js","../src/factory.js"],"sourcesContent":["export class PromiseLogicError extends Error {\r\n constructor(type, message, results) {\r\n super(message);\r\n this.name = 'PromiseLogicError';\r\n this.type = type; // 'XOR_ERROR', 'NAND_ERROR', etc.\r\n this.results = results; // settlement results of all Promises\r\n }\r\n}\r\n\r\n// Error factory function\r\nexport function createLogicError(type, fulfilledCount, total, results) {\r\n const messages = {\r\n XOR_ERROR: `XOR condition failed: expected exactly 1 promise to fulfill, but ${fulfilledCount} fulfilled.`,\r\n NAND_ERROR: `NAND condition failed: all ${total} promises fulfilled (expected at least one rejection).`,\r\n NOR_ERROR: `NOR condition failed: ${fulfilledCount} promises fulfilled (expected all rejected).`,\r\n MAJORITY_ERROR: `Majority condition failed: ${fulfilledCount}/${total} fulfilled (need majority).`,\r\n ALL_SUCCESSFUL_ERROR: `All successful condition failed: ${fulfilledCount}/${total} promises fulfilled (expected all to succeed).`,\r\n ALL_FAILED_ERROR: `All failed condition failed: ${total - fulfilledCount}/${total} promises rejected (expected all to fail).`\r\n };\r\n \r\n return new PromiseLogicError(type, messages[type] || 'Logic condition failed', results);\r\n}","import { createLogicError } from './utils/errors.js';\r\n\r\nexport class PromiseLogic {\r\n static and(iterable) {\r\n return Promise.all(iterable);\r\n }\r\n\r\n static or(iterable) {\r\n return Promise.any(iterable);\r\n }\r\n\r\n static race(iterable) {\r\n return Promise.race(iterable);\r\n }\r\n\r\n static allSettled(iterable) {\r\n return Promise.allSettled(iterable);\r\n }\r\n\r\n static xor(iterable) {\r\n return Promise.allSettled(iterable).then((results) => {\r\n const fulfilled = results.filter(result => result.status === 'fulfilled');\r\n const fulfilledCount = fulfilled.length;\r\n const total = results.length;\r\n \r\n if (fulfilledCount === 1) {\r\n // 恰好一个成功,返回成功的值\r\n return fulfilled[0].value;\r\n } else {\r\n // 0个或多个(>1)成功,抛出XOR_ERROR\r\n throw createLogicError('XOR_ERROR', fulfilledCount, total, results);\r\n }\r\n });\r\n }\r\n\r\n static nand(iterable) {\r\n return Promise.allSettled(iterable).then((results) => {\r\n const fulfilled = results.filter(result => result.status === 'fulfilled');\r\n const fulfilledCount = fulfilled.length;\r\n const total = results.length;\r\n \r\n if (fulfilledCount === total) {\r\n // 全部成功,抛出NAND_ERROR\r\n throw createLogicError('NAND_ERROR', fulfilledCount, total, results);\r\n } else {\r\n // 不是所有都成功,返回成功的值数组\r\n return fulfilled.map(result => result.value);\r\n }\r\n });\r\n }\r\n\r\n static nor(iterable) {\r\n return Promise.allSettled(iterable).then((results) => {\r\n const fulfilled = results.filter(result => result.status === 'fulfilled');\r\n const fulfilledCount = fulfilled.length;\r\n const total = results.length;\r\n \r\n if (fulfilledCount === 0) {\r\n // 全部失败,返回空数组表示成功\r\n return [];\r\n } else {\r\n // 任意成功,抛出NOR_ERROR\r\n throw createLogicError('NOR_ERROR', fulfilledCount, total, results);\r\n }\r\n });\r\n }\r\n\r\n static xnor(iterable) {\r\n return Promise.allSettled(iterable).then((results) => {\r\n const fulfilled = results.filter(result => result.status === 'fulfilled');\r\n const fulfilledCount = fulfilled.length;\r\n const total = results.length;\r\n \r\n if (fulfilledCount === 0 || fulfilledCount === total) {\r\n // 全部成功或全部失败,返回成功的值数组\r\n return fulfilled.map(result => result.value);\r\n } else {\r\n // 部分成功部分失败,抛出XNOR_ERROR\r\n throw createLogicError('XNOR_ERROR', fulfilledCount, total, results);\r\n }\r\n });\r\n }\r\n\r\n static majority(iterable) {\r\n return Promise.allSettled(iterable).then((results) => {\r\n const fulfilled = results.filter(result => result.status === 'fulfilled');\r\n const fulfilledCount = fulfilled.length;\r\n const total = results.length;\r\n \r\n // 多数逻辑:成功数 > 失败数\r\n if (fulfilledCount > total - fulfilledCount) {\r\n // 超过半数成功,返回成功的值数组\r\n return fulfilled.map(result => result.value);\r\n } else {\r\n // 未达到多数,抛出MAJORITY_ERROR\r\n throw createLogicError('MAJORITY_ERROR', fulfilledCount, total, results);\r\n }\r\n });\r\n }\r\n\r\n // 返回所有成功的Promise结果\r\n static allFulfilled(iterable) {\r\n return Promise.allSettled(iterable).then((results) => {\r\n const fulfilled = results.filter(result => result.status === 'fulfilled');\r\n return fulfilled.map(result => result.value);\r\n });\r\n }\r\n\r\n // 返回所有失败的Promise结果\r\n static allRejected(iterable) {\r\n return Promise.allSettled(iterable).then((results) => {\r\n const rejected = results.filter(result => result.status === 'rejected');\r\n return rejected.map(result => result.reason);\r\n });\r\n }\r\n static createFlipFlop(initialState = false) {\r\n let state = initialState;\r\n let resolveCurrent = null;\r\n let currentPromise = Promise.resolve(state);\r\n \r\n return {\r\n // 获取当前状态\r\n getState() {\r\n return state;\r\n },\r\n \r\n // 异步设置状态\r\n set(newState) {\r\n state = newState;\r\n if (resolveCurrent) {\r\n resolveCurrent(state);\r\n resolveCurrent = null;\r\n }\r\n currentPromise = Promise.resolve(state);\r\n return this;\r\n },\r\n \r\n // 切换状态\r\n toggle() {\r\n return this.set(!state);\r\n },\r\n \r\n // 等待状态变化\r\n waitForChange() {\r\n if (!resolveCurrent) {\r\n currentPromise = new Promise((resolve) => {\r\n resolveCurrent = resolve;\r\n });\r\n }\r\n return currentPromise;\r\n },\r\n \r\n // 等待特定状态\r\n waitFor(targetState) {\r\n if (state === targetState) {\r\n return Promise.resolve(state);\r\n }\r\n return new Promise((resolve) => {\r\n const checkState = () => {\r\n if (state === targetState) {\r\n resolve(state);\r\n } else {\r\n this.waitForChange().then(checkState);\r\n }\r\n };\r\n checkState();\r\n });\r\n }\r\n };\r\n }\r\n}","import { PromiseLogic } from './PromiseLogic.js';\n\nexport function createPromiseLogic(options = {}) {\n const { prefix = '', suffix = '', rename = {} } = options;\n \n // 基础方法映射\n const methods = {\n and: PromiseLogic.and,\n or: PromiseLogic.or,\n race: PromiseLogic.race,\n allSettled: PromiseLogic.allSettled,\n xor: PromiseLogic.xor,\n nand: PromiseLogic.nand,\n nor: PromiseLogic.nor,\n xnor: PromiseLogic.xnor,\n majority: PromiseLogic.majority\n };\n \n // 应用命名转换\n const result = {};\n Object.entries(methods).forEach(([key, fn]) => {\n // 优先使用rename映射,然后应用prefix和suffix\n const baseName = rename[key] || key;\n const finalName = `${prefix}${baseName}${suffix}`;\n result[finalName] = fn;\n });\n \n return result;\n}"],"names":[],"mappings":";;AAAO,MAAM,iBAAiB,SAAS,KAAK,CAAC;AAC7C,EAAE,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE;AACtC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AACnB,IAAI,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;AACpC,IAAI,IAAI,CAAC,IAAI,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I,EAAE,EAAE,YAAY,CAAC,EAAE;AACvB,IAAI,IAAI,EAAE,YAAY,CAAC,IAAI;AAC3B,IAAI,UAAU,EAAE,YAAY,CAAC,UAAU;AACvC,IAAI,GAAG,EAAE,YAAY,CAAC,GAAG;AACzB,IAAI,IAAI,EAAE,YAAY,CAAC,IAAI;AAC3B,IAAI,GAAG,EAAE,YAAY,CAAC,GAAG;AACzB,IAAI,IAAI,EAAE,YAAY,CAAC,IAAI;AAC3B,IAAI,QAAQ,EAAE,YAAY,CAAC;AAC3B,GAAG;AACH;AACA;AACA,EAAE,MAAM,MAAM,GAAG,EAAE;AACnB,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK;AACjD;AACA,IAAI,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,GAAG;AACvC,IAAI,MAAM,SAAS,GAAG,CAAC,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;AACrD,IAAI,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE;AAC1B,EAAE,CAAC,CAAC;AACJ;AACA,EAAE,OAAO,MAAM;AACf;;;;"}
1
+ {"version":3,"file":"factory.cjs.js","sources":["../src/utils/v1/errors.js","../src/v1/PromiseLogic.js","../src/v1/factory.js"],"sourcesContent":["export class PromiseLogicError extends Error {\r\n constructor(type, message, results) {\r\n super(message);\r\n this.name = 'PromiseLogicError';\r\n this.type = type; // 'XOR_ERROR', 'NAND_ERROR', etc.\r\n this.results = results; // settlement results of all Promises\r\n }\r\n}\r\n\r\n// Error factory function\r\nexport function createLogicError(type, fulfilledCount, total, results) {\r\n const messages = {\r\n XOR_ERROR: `XOR condition failed: expected exactly 1 promise to fulfill, but ${fulfilledCount} fulfilled.`,\r\n NAND_ERROR: `NAND condition failed: all ${total} promises fulfilled (expected at least one rejection).`,\r\n NOT_ERROR: `NOT condition failed: promise resolved (expected rejection).`,\r\n NOR_ERROR: `NOR condition failed: ${fulfilledCount} promises fulfilled (expected all rejected).`,\r\n MAJORITY_ERROR: `Majority condition failed: ${fulfilledCount}/${total} fulfilled (need majority).`,\r\n ALL_SUCCESSFUL_ERROR: `All successful condition failed: ${fulfilledCount}/${total} promises fulfilled (expected all to succeed).`,\r\n ALL_FAILED_ERROR: `All failed condition failed: ${total - fulfilledCount}/${total} promises rejected (expected all to fail).`\r\n };\r\n \r\n return new PromiseLogicError(type, messages[type] || 'Logic condition failed', results);\r\n}","import { createLogicError } from '../utils/v1/errors.js';\r\n\r\nexport class PromiseLogic {\r\n static and(iterable) {\r\n return Promise.all(iterable);\r\n }\r\n\r\n static or(iterable) {\r\n return Promise.any(iterable);\r\n }\r\n\r\n \r\nstatic not(promise) {\r\n return Promise.resolve(promise).then(\r\n (value) => Promise.reject(value),\r\n (reason) => Promise.resolve(reason)\r\n )\r\n .catch((error) => Promise.resolve(error));\r\n}\r\n\r\n static race(iterable) {\r\n return Promise.race(iterable);\r\n }\r\n\r\n static allSettled(iterable) {\r\n return Promise.allSettled(iterable);\r\n }\r\n\r\n static xor(iterable) {\r\n return Promise.allSettled(iterable).then((results) => {\r\n const fulfilled = results.filter(result => result.status === 'fulfilled');\r\n const fulfilledCount = fulfilled.length;\r\n const total = results.length;\r\n \r\n if (fulfilledCount === 1) {\r\n // 恰好一个成功,返回成功的值\r\n return fulfilled[0].value;\r\n } else {\r\n // 0个或多个(>1)成功,抛出XOR_ERROR\r\n throw createLogicError('XOR_ERROR', fulfilledCount, total, results);\r\n }\r\n });\r\n }\r\n\r\n static nand(iterable) {\r\n return Promise.allSettled(iterable).then((results) => {\r\n const fulfilled = results.filter(result => result.status === 'fulfilled');\r\n const fulfilledCount = fulfilled.length;\r\n const total = results.length;\r\n \r\n if (fulfilledCount === total) {\r\n // 全部成功,抛出NAND_ERROR\r\n throw createLogicError('NAND_ERROR', fulfilledCount, total, results);\r\n } else {\r\n // 不是所有都成功,返回成功的值数组\r\n return fulfilled.map(result => result.value);\r\n }\r\n });\r\n }\r\n\r\n static nor(iterable) {\r\n return Promise.allSettled(iterable).then((results) => {\r\n const fulfilled = results.filter(result => result.status === 'fulfilled');\r\n const fulfilledCount = fulfilled.length;\r\n const total = results.length;\r\n \r\n if (fulfilledCount === 0) {\r\n // 全部失败,返回空数组表示成功\r\n return [];\r\n } else {\r\n // 任意成功,抛出NOR_ERROR\r\n throw createLogicError('NOR_ERROR', fulfilledCount, total, results);\r\n }\r\n });\r\n }\r\n\r\n static xnor(iterable) {\r\n return Promise.allSettled(iterable).then((results) => {\r\n const fulfilled = results.filter(result => result.status === 'fulfilled');\r\n const fulfilledCount = fulfilled.length;\r\n const total = results.length;\r\n \r\n if (fulfilledCount === 0 || fulfilledCount === total) {\r\n // 全部成功或全部失败,返回成功的值数组\r\n return fulfilled.map(result => result.value);\r\n } else {\r\n // 部分成功部分失败,抛出XNOR_ERROR\r\n throw createLogicError('XNOR_ERROR', fulfilledCount, total, results);\r\n }\r\n });\r\n }\r\n\r\n static majority(iterable) {\r\n return Promise.allSettled(iterable).then((results) => {\r\n const fulfilled = results.filter(result => result.status === 'fulfilled');\r\n const fulfilledCount = fulfilled.length;\r\n const total = results.length;\r\n \r\n // 多数逻辑:成功数 > 失败数\r\n if (fulfilledCount > total - fulfilledCount) {\r\n // 超过半数成功,返回成功的值数组\r\n return fulfilled.map(result => result.value);\r\n } else {\r\n // 未达到多数,抛出MAJORITY_ERROR\r\n throw createLogicError('MAJORITY_ERROR', fulfilledCount, total, results);\r\n }\r\n });\r\n }\r\n\r\n\r\n // 返回所有成功的Promise结果\r\n static allFulfilled(iterable) {\r\n return Promise.allSettled(iterable).then((results) => {\r\n const fulfilled = results.filter(result => result.status === 'fulfilled');\r\n return fulfilled.map(result => result.value);\r\n });\r\n }\r\n\r\n // 返回所有失败的Promise结果\r\n static allRejected(iterable) {\r\n return Promise.allSettled(iterable).then((results) => {\r\n const rejected = results.filter(result => result.status === 'rejected');\r\n return rejected.map(result => result.reason);\r\n });\r\n }\r\n static createFlipFlop(initialState = false) {\r\n let state = initialState;\r\n let resolveCurrent = null;\r\n let currentPromise = Promise.resolve(state);\r\n \r\n return {\r\n // 获取当前状态\r\n getState() {\r\n return state;\r\n },\r\n \r\n // 异步设置状态\r\n set(newState) {\r\n state = newState;\r\n if (resolveCurrent) {\r\n resolveCurrent(state);\r\n resolveCurrent = null;\r\n }\r\n currentPromise = Promise.resolve(state);\r\n return this;\r\n },\r\n \r\n // 切换状态\r\n toggle() {\r\n return this.set(!state);\r\n },\r\n \r\n // 等待状态变化\r\n waitForChange() {\r\n if (!resolveCurrent) {\r\n currentPromise = new Promise((resolve) => {\r\n resolveCurrent = resolve;\r\n });\r\n }\r\n return currentPromise;\r\n },\r\n \r\n // 等待特定状态\r\n waitFor(targetState) {\r\n if (state === targetState) {\r\n return Promise.resolve(state);\r\n }\r\n return new Promise((resolve) => {\r\n const checkState = () => {\r\n if (state === targetState) {\r\n resolve(state);\r\n } else {\r\n this.waitForChange().then(checkState);\r\n }\r\n };\r\n checkState();\r\n });\r\n }\r\n };\r\n }\r\n}","import { PromiseLogic } from './PromiseLogic.js';\n\nexport function createPromiseLogic(options = {}) {\n const { prefix = '', suffix = '', rename = {} } = options;\n \n // 基础方法映射\n const methods = {\n and: PromiseLogic.and,\n or: PromiseLogic.or,\n race: PromiseLogic.race,\n allSettled: PromiseLogic.allSettled,\n xor: PromiseLogic.xor,\n not: PromiseLogic.not,\n nand: PromiseLogic.nand,\n nor: PromiseLogic.nor,\n xnor: PromiseLogic.xnor,\n majority: PromiseLogic.majority,\n allFulfilled: PromiseLogic.allFulfilled,\n allRejected: PromiseLogic.allRejected\n };\n \n // 应用命名转换\n const result = {};\n Object.entries(methods).forEach(([key, fn]) => {\n // 优先使用rename映射,然后应用prefix和suffix\n const baseName = rename[key] || key;\n const finalName = `${prefix}${baseName}${suffix}`;\n result[finalName] = fn;\n });\n \n return result;\n}"],"names":[],"mappings":";;AAAO,MA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