effect 4.0.0-beta.41 → 4.0.0-beta.42
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/dist/Effect.d.ts +19 -63
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +24 -65
- package/dist/Effect.js.map +1 -1
- package/dist/MutableList.d.ts.map +1 -1
- package/dist/MutableList.js +3 -0
- package/dist/MutableList.js.map +1 -1
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +12 -3
- package/dist/Number.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +16 -14
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/TxChunk.d.ts +39 -39
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxChunk.js +3 -3
- package/dist/TxChunk.js.map +1 -1
- package/dist/TxDeferred.d.ts +9 -9
- package/dist/TxDeferred.d.ts.map +1 -1
- package/dist/TxDeferred.js +2 -2
- package/dist/TxDeferred.js.map +1 -1
- package/dist/TxHashMap.d.ts +59 -59
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +8 -8
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts +35 -35
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js +7 -7
- package/dist/TxHashSet.js.map +1 -1
- package/dist/TxPriorityQueue.d.ts +23 -23
- package/dist/TxPriorityQueue.d.ts.map +1 -1
- package/dist/TxPriorityQueue.js +4 -4
- package/dist/TxPriorityQueue.js.map +1 -1
- package/dist/TxPubSub.d.ts +14 -14
- package/dist/TxPubSub.d.ts.map +1 -1
- package/dist/TxPubSub.js +12 -12
- package/dist/TxPubSub.js.map +1 -1
- package/dist/TxQueue.d.ts +33 -33
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +29 -44
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +10 -33
- package/dist/TxReentrantLock.d.ts.map +1 -1
- package/dist/TxReentrantLock.js +14 -37
- package/dist/TxReentrantLock.js.map +1 -1
- package/dist/TxRef.d.ts +36 -42
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +16 -25
- package/dist/TxRef.js.map +1 -1
- package/dist/TxSemaphore.d.ts +8 -8
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +10 -10
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/TxSubscriptionRef.d.ts +14 -14
- package/dist/TxSubscriptionRef.d.ts.map +1 -1
- package/dist/TxSubscriptionRef.js +5 -5
- package/dist/TxSubscriptionRef.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/unstable/ai/OpenAiStructuredOutput.js +3 -0
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +12 -1
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +1 -4
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +1 -1
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +1 -1
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/package.json +1 -1
- package/src/Effect.ts +24 -75
- package/src/MutableList.ts +3 -0
- package/src/Number.ts +13 -3
- package/src/SchemaRepresentation.ts +8 -6
- package/src/TxChunk.ts +53 -62
- package/src/TxDeferred.ts +14 -17
- package/src/TxHashMap.ts +91 -101
- package/src/TxHashSet.ts +68 -70
- package/src/TxPriorityQueue.ts +34 -38
- package/src/TxPubSub.ts +30 -32
- package/src/TxQueue.ts +70 -84
- package/src/TxReentrantLock.ts +30 -54
- package/src/TxRef.ts +53 -65
- package/src/TxSemaphore.ts +23 -24
- package/src/TxSubscriptionRef.ts +25 -27
- package/src/index.ts +3 -3
- package/src/unstable/ai/OpenAiStructuredOutput.ts +3 -0
- package/src/unstable/cli/internal/command.ts +16 -1
- package/src/unstable/cluster/SqlMessageStorage.ts +0 -4
- package/src/unstable/socket/Socket.ts +1 -1
|
@@ -54,7 +54,7 @@ export interface TxReentrantLock extends Inspectable, Pipeable {
|
|
|
54
54
|
* @since 4.0.0
|
|
55
55
|
* @category constructors
|
|
56
56
|
*/
|
|
57
|
-
export declare const make: () => Effect.Effect<TxReentrantLock
|
|
57
|
+
export declare const make: () => Effect.Effect<TxReentrantLock>;
|
|
58
58
|
/**
|
|
59
59
|
* Acquires a read lock. Blocks if another fiber holds the write lock.
|
|
60
60
|
* If the current fiber already holds the write lock, the read lock is granted (reentrancy).
|
|
@@ -75,7 +75,7 @@ export declare const make: () => Effect.Effect<TxReentrantLock, never, Effect.Tr
|
|
|
75
75
|
* @since 4.0.0
|
|
76
76
|
* @category mutations
|
|
77
77
|
*/
|
|
78
|
-
export declare const acquireRead: (self: TxReentrantLock) => Effect.Effect<number
|
|
78
|
+
export declare const acquireRead: (self: TxReentrantLock) => Effect.Effect<number>;
|
|
79
79
|
/**
|
|
80
80
|
* Acquires a write lock. Blocks if any other fiber holds any lock.
|
|
81
81
|
* If the current fiber already holds the write lock, the count is incremented (reentrancy).
|
|
@@ -97,7 +97,7 @@ export declare const acquireRead: (self: TxReentrantLock) => Effect.Effect<numbe
|
|
|
97
97
|
* @since 4.0.0
|
|
98
98
|
* @category mutations
|
|
99
99
|
*/
|
|
100
|
-
export declare const acquireWrite: (self: TxReentrantLock) => Effect.Effect<number
|
|
100
|
+
export declare const acquireWrite: (self: TxReentrantLock) => Effect.Effect<number>;
|
|
101
101
|
/**
|
|
102
102
|
* Releases a read lock held by the current fiber.
|
|
103
103
|
* Returns the remaining number of read locks held by this fiber.
|
|
@@ -117,7 +117,7 @@ export declare const acquireWrite: (self: TxReentrantLock) => Effect.Effect<numb
|
|
|
117
117
|
* @since 4.0.0
|
|
118
118
|
* @category mutations
|
|
119
119
|
*/
|
|
120
|
-
export declare const releaseRead: (self: TxReentrantLock) => Effect.Effect<number
|
|
120
|
+
export declare const releaseRead: (self: TxReentrantLock) => Effect.Effect<number>;
|
|
121
121
|
/**
|
|
122
122
|
* Releases a write lock held by the current fiber.
|
|
123
123
|
* Returns the remaining number of write locks held by this fiber.
|
|
@@ -137,7 +137,7 @@ export declare const releaseRead: (self: TxReentrantLock) => Effect.Effect<numbe
|
|
|
137
137
|
* @since 4.0.0
|
|
138
138
|
* @category mutations
|
|
139
139
|
*/
|
|
140
|
-
export declare const releaseWrite: (self: TxReentrantLock) => Effect.Effect<number
|
|
140
|
+
export declare const releaseWrite: (self: TxReentrantLock) => Effect.Effect<number>;
|
|
141
141
|
/**
|
|
142
142
|
* Acquires a read lock for the duration of the scope.
|
|
143
143
|
* The lock is automatically released when the scope closes.
|
|
@@ -188,29 +188,6 @@ export declare const readLock: (self: TxReentrantLock) => Effect.Effect<number,
|
|
|
188
188
|
* @category mutations
|
|
189
189
|
*/
|
|
190
190
|
export declare const writeLock: (self: TxReentrantLock) => Effect.Effect<number, never, Scope.Scope>;
|
|
191
|
-
/**
|
|
192
|
-
* Alias for `writeLock`. Acquires a write lock for the duration of the scope.
|
|
193
|
-
*
|
|
194
|
-
* @example
|
|
195
|
-
* ```ts
|
|
196
|
-
* import { Effect, TxReentrantLock } from "effect"
|
|
197
|
-
*
|
|
198
|
-
* const program = Effect.gen(function*() {
|
|
199
|
-
* const lock = yield* TxReentrantLock.make()
|
|
200
|
-
*
|
|
201
|
-
* yield* Effect.scoped(
|
|
202
|
-
* Effect.gen(function*() {
|
|
203
|
-
* yield* TxReentrantLock.lock(lock)
|
|
204
|
-
* // exclusive lock is held
|
|
205
|
-
* })
|
|
206
|
-
* )
|
|
207
|
-
* })
|
|
208
|
-
* ```
|
|
209
|
-
*
|
|
210
|
-
* @since 4.0.0
|
|
211
|
-
* @category mutations
|
|
212
|
-
*/
|
|
213
|
-
export declare const lock: (self: TxReentrantLock) => Effect.Effect<number, never, Scope.Scope>;
|
|
214
191
|
/**
|
|
215
192
|
* Runs the provided effect while holding a read lock. The lock is automatically
|
|
216
193
|
* released after the effect completes, fails, or is interrupted.
|
|
@@ -428,7 +405,7 @@ export declare const withLock: {
|
|
|
428
405
|
* @since 4.0.0
|
|
429
406
|
* @category getters
|
|
430
407
|
*/
|
|
431
|
-
export declare const readLocks: (self: TxReentrantLock) => Effect.Effect<number
|
|
408
|
+
export declare const readLocks: (self: TxReentrantLock) => Effect.Effect<number>;
|
|
432
409
|
/**
|
|
433
410
|
* Returns the number of write locks held (0 or the reentrant count).
|
|
434
411
|
*
|
|
@@ -446,7 +423,7 @@ export declare const readLocks: (self: TxReentrantLock) => Effect.Effect<number,
|
|
|
446
423
|
* @since 4.0.0
|
|
447
424
|
* @category getters
|
|
448
425
|
*/
|
|
449
|
-
export declare const writeLocks: (self: TxReentrantLock) => Effect.Effect<number
|
|
426
|
+
export declare const writeLocks: (self: TxReentrantLock) => Effect.Effect<number>;
|
|
450
427
|
/**
|
|
451
428
|
* Checks if the lock is held by any fiber (read or write).
|
|
452
429
|
*
|
|
@@ -464,7 +441,7 @@ export declare const writeLocks: (self: TxReentrantLock) => Effect.Effect<number
|
|
|
464
441
|
* @since 4.0.0
|
|
465
442
|
* @category getters
|
|
466
443
|
*/
|
|
467
|
-
export declare const locked: (self: TxReentrantLock) => Effect.Effect<boolean
|
|
444
|
+
export declare const locked: (self: TxReentrantLock) => Effect.Effect<boolean>;
|
|
468
445
|
/**
|
|
469
446
|
* Checks if any fiber holds a read lock.
|
|
470
447
|
*
|
|
@@ -482,7 +459,7 @@ export declare const locked: (self: TxReentrantLock) => Effect.Effect<boolean, n
|
|
|
482
459
|
* @since 4.0.0
|
|
483
460
|
* @category getters
|
|
484
461
|
*/
|
|
485
|
-
export declare const readLocked: (self: TxReentrantLock) => Effect.Effect<boolean
|
|
462
|
+
export declare const readLocked: (self: TxReentrantLock) => Effect.Effect<boolean>;
|
|
486
463
|
/**
|
|
487
464
|
* Checks if any fiber holds a write lock.
|
|
488
465
|
*
|
|
@@ -500,7 +477,7 @@ export declare const readLocked: (self: TxReentrantLock) => Effect.Effect<boolea
|
|
|
500
477
|
* @since 4.0.0
|
|
501
478
|
* @category getters
|
|
502
479
|
*/
|
|
503
|
-
export declare const writeLocked: (self: TxReentrantLock) => Effect.Effect<boolean
|
|
480
|
+
export declare const writeLocked: (self: TxReentrantLock) => Effect.Effect<boolean>;
|
|
504
481
|
/**
|
|
505
482
|
* Checks if the given value is a TxReentrantLock.
|
|
506
483
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TxReentrantLock.d.ts","sourceRoot":"","sources":["../src/TxReentrantLock.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAGnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAG7C,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAA;AAGxC,QAAA,MAAM,MAAM,yCAAyC,CAAA;AAgBrD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,eAAgB,SAAQ,WAAW,EAAE,QAAQ;IAC5D,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,MAAM,CAAA;CAGjC;AAqBD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,IAAI,QAAO,MAAM,CAAC,MAAM,CAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"TxReentrantLock.d.ts","sourceRoot":"","sources":["../src/TxReentrantLock.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;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OAAO,KAAG,CAAC,IAAI,eAAyC,CAAA"}
|
package/dist/TxReentrantLock.js
CHANGED
|
@@ -60,7 +60,7 @@ export const make = () => Effect.gen(function* () {
|
|
|
60
60
|
self[TypeId] = TypeId;
|
|
61
61
|
self.stateRef = stateRef;
|
|
62
62
|
return self;
|
|
63
|
-
});
|
|
63
|
+
}).pipe(Effect.tx);
|
|
64
64
|
// =============================================================================
|
|
65
65
|
// Mutations
|
|
66
66
|
// =============================================================================
|
|
@@ -89,7 +89,7 @@ export const acquireRead = self => Effect.withFiber(fiber => Effect.gen(function
|
|
|
89
89
|
const fiberId = fiber.id;
|
|
90
90
|
// If another fiber holds the write lock, retry
|
|
91
91
|
if (Option.isSome(state.writer) && state.writer.value[0] !== fiberId) {
|
|
92
|
-
return yield* Effect.
|
|
92
|
+
return yield* Effect.txRetry;
|
|
93
93
|
}
|
|
94
94
|
// Grant read lock
|
|
95
95
|
const currentCount = Option.getOrElse(HashMap.get(state.readers, fiberId), () => 0);
|
|
@@ -99,7 +99,7 @@ export const acquireRead = self => Effect.withFiber(fiber => Effect.gen(function
|
|
|
99
99
|
readers: HashMap.set(state.readers, fiberId, newCount)
|
|
100
100
|
});
|
|
101
101
|
return newCount;
|
|
102
|
-
}));
|
|
102
|
+
}).pipe(Effect.tx));
|
|
103
103
|
/**
|
|
104
104
|
* Acquires a write lock. Blocks if any other fiber holds any lock.
|
|
105
105
|
* If the current fiber already holds the write lock, the count is incremented (reentrancy).
|
|
@@ -126,12 +126,12 @@ export const acquireWrite = self => Effect.withFiber(fiber => Effect.gen(functio
|
|
|
126
126
|
const fiberId = fiber.id;
|
|
127
127
|
// If another fiber holds the write lock, retry
|
|
128
128
|
if (Option.isSome(state.writer) && state.writer.value[0] !== fiberId) {
|
|
129
|
-
return yield* Effect.
|
|
129
|
+
return yield* Effect.txRetry;
|
|
130
130
|
}
|
|
131
131
|
// If other fibers hold read locks, retry
|
|
132
132
|
for (const [readerId] of state.readers) {
|
|
133
133
|
if (readerId !== fiberId && Option.getOrElse(HashMap.get(state.readers, readerId), () => 0) > 0) {
|
|
134
|
-
return yield* Effect.
|
|
134
|
+
return yield* Effect.txRetry;
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
// Grant write lock
|
|
@@ -150,7 +150,7 @@ export const acquireWrite = self => Effect.withFiber(fiber => Effect.gen(functio
|
|
|
150
150
|
writer: Option.some([fiberId, 1])
|
|
151
151
|
});
|
|
152
152
|
return 1;
|
|
153
|
-
}));
|
|
153
|
+
}).pipe(Effect.tx));
|
|
154
154
|
/**
|
|
155
155
|
* Releases a read lock held by the current fiber.
|
|
156
156
|
* Returns the remaining number of read locks held by this fiber.
|
|
@@ -182,7 +182,7 @@ export const releaseRead = self => Effect.withFiber(fiber => Effect.gen(function
|
|
|
182
182
|
readers: newReaders
|
|
183
183
|
});
|
|
184
184
|
return newCount;
|
|
185
|
-
}));
|
|
185
|
+
}).pipe(Effect.tx));
|
|
186
186
|
/**
|
|
187
187
|
* Releases a write lock held by the current fiber.
|
|
188
188
|
* Returns the remaining number of write locks held by this fiber.
|
|
@@ -213,7 +213,7 @@ export const releaseWrite = self => Effect.withFiber(fiber => Effect.gen(functio
|
|
|
213
213
|
writer: newWriter
|
|
214
214
|
});
|
|
215
215
|
return newCount;
|
|
216
|
-
}));
|
|
216
|
+
}).pipe(Effect.tx));
|
|
217
217
|
/**
|
|
218
218
|
* Acquires a read lock for the duration of the scope.
|
|
219
219
|
* The lock is automatically released when the scope closes.
|
|
@@ -238,7 +238,7 @@ export const releaseWrite = self => Effect.withFiber(fiber => Effect.gen(functio
|
|
|
238
238
|
* @since 4.0.0
|
|
239
239
|
* @category mutations
|
|
240
240
|
*/
|
|
241
|
-
export const readLock = self => Effect.acquireRelease(
|
|
241
|
+
export const readLock = self => Effect.acquireRelease(acquireRead(self), () => releaseRead(self));
|
|
242
242
|
/**
|
|
243
243
|
* Acquires a write lock for the duration of the scope.
|
|
244
244
|
* The lock is automatically released when the scope closes.
|
|
@@ -263,30 +263,7 @@ export const readLock = self => Effect.acquireRelease(Effect.transaction(acquire
|
|
|
263
263
|
* @since 4.0.0
|
|
264
264
|
* @category mutations
|
|
265
265
|
*/
|
|
266
|
-
export const writeLock = self => Effect.acquireRelease(
|
|
267
|
-
/**
|
|
268
|
-
* Alias for `writeLock`. Acquires a write lock for the duration of the scope.
|
|
269
|
-
*
|
|
270
|
-
* @example
|
|
271
|
-
* ```ts
|
|
272
|
-
* import { Effect, TxReentrantLock } from "effect"
|
|
273
|
-
*
|
|
274
|
-
* const program = Effect.gen(function*() {
|
|
275
|
-
* const lock = yield* TxReentrantLock.make()
|
|
276
|
-
*
|
|
277
|
-
* yield* Effect.scoped(
|
|
278
|
-
* Effect.gen(function*() {
|
|
279
|
-
* yield* TxReentrantLock.lock(lock)
|
|
280
|
-
* // exclusive lock is held
|
|
281
|
-
* })
|
|
282
|
-
* )
|
|
283
|
-
* })
|
|
284
|
-
* ```
|
|
285
|
-
*
|
|
286
|
-
* @since 4.0.0
|
|
287
|
-
* @category mutations
|
|
288
|
-
*/
|
|
289
|
-
export const lock = writeLock;
|
|
266
|
+
export const writeLock = self => Effect.acquireRelease(acquireWrite(self), () => releaseWrite(self));
|
|
290
267
|
/**
|
|
291
268
|
* Runs the provided effect while holding a read lock. The lock is automatically
|
|
292
269
|
* released after the effect completes, fails, or is interrupted.
|
|
@@ -311,10 +288,10 @@ export const lock = writeLock;
|
|
|
311
288
|
export const withReadLock = (...args) => {
|
|
312
289
|
if (args.length === 1) {
|
|
313
290
|
const [effect] = args;
|
|
314
|
-
return self => Effect.acquireUseRelease(
|
|
291
|
+
return self => Effect.acquireUseRelease(acquireRead(self), () => effect, () => releaseRead(self));
|
|
315
292
|
}
|
|
316
293
|
const [self, effect] = args;
|
|
317
|
-
return Effect.acquireUseRelease(
|
|
294
|
+
return Effect.acquireUseRelease(acquireRead(self), () => effect, () => releaseRead(self));
|
|
318
295
|
};
|
|
319
296
|
/**
|
|
320
297
|
* Runs the provided effect while holding a write lock. The lock is automatically
|
|
@@ -340,10 +317,10 @@ export const withReadLock = (...args) => {
|
|
|
340
317
|
export const withWriteLock = (...args) => {
|
|
341
318
|
if (args.length === 1) {
|
|
342
319
|
const [effect] = args;
|
|
343
|
-
return self => Effect.acquireUseRelease(
|
|
320
|
+
return self => Effect.acquireUseRelease(acquireWrite(self), () => effect, () => releaseWrite(self));
|
|
344
321
|
}
|
|
345
322
|
const [self, effect] = args;
|
|
346
|
-
return Effect.acquireUseRelease(
|
|
323
|
+
return Effect.acquireUseRelease(acquireWrite(self), () => effect, () => releaseWrite(self));
|
|
347
324
|
};
|
|
348
325
|
/**
|
|
349
326
|
* Alias for `withWriteLock`. Runs the provided effect while holding a write lock.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TxReentrantLock.js","names":["Effect","HashMap","NodeInspectSymbol","toJson","Option","pipeArguments","hasProperty","TxRef","TypeId","emptyState","readers","empty","writer","none","TxReentrantLockProto","toJSON","_id","toString","pipe","arguments","make","gen","stateRef","self","Object","create","acquireRead","withFiber","fiber","state","get","fiberId","id","isSome","value","
|
|
1
|
+
{"version":3,"file":"TxReentrantLock.js","names":["Effect","HashMap","NodeInspectSymbol","toJson","Option","pipeArguments","hasProperty","TxRef","TypeId","emptyState","readers","empty","writer","none","TxReentrantLockProto","toJSON","_id","toString","pipe","arguments","make","gen","stateRef","self","Object","create","tx","acquireRead","withFiber","fiber","state","get","fiberId","id","isSome","value","txRetry","currentCount","getOrElse","newCount","set","acquireWrite","readerId","some","releaseRead","newReaders","remove","releaseWrite","isNone","newWriter","readLock","acquireRelease","writeLock","withReadLock","args","length","effect","acquireUseRelease","withWriteLock","withLock","readLocks","total","count","writeLocks","locked","size","readLocked","writeLocked","isTxReentrantLock","u"],"sources":["../src/TxReentrantLock.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;AAQA,OAAO,KAAKA,MAAM,MAAM,aAAa;AACrC,OAAO,KAAKC,OAAO,MAAM,cAAc;AAEvC,SA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CAAU,IAA2B/D,WAAW,CAAC+D,CAAC,EAAE7D,MAAM,CAAC","ignoreList":[]}
|
package/dist/TxRef.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Accessed values are tracked by the transaction in order to detect conflicts and in order to
|
|
5
5
|
* track changes, a transaction will retry whenever a conflict is detected or whenever the
|
|
6
|
-
* transaction explicitely calls to `Effect.
|
|
6
|
+
* transaction explicitely calls to `Effect.txRetry` and any of the accessed TxRef values
|
|
7
7
|
* change.
|
|
8
8
|
*
|
|
9
9
|
* @since 4.0.0
|
|
@@ -17,7 +17,7 @@ declare const TypeId = "~effect/transactions/TxRef";
|
|
|
17
17
|
*
|
|
18
18
|
* Accessed values are tracked by the transaction in order to detect conflicts and in order to
|
|
19
19
|
* track changes, a transaction will retry whenever a conflict is detected or whenever the
|
|
20
|
-
* transaction explicitely calls to `Effect.
|
|
20
|
+
* transaction explicitely calls to `Effect.txRetry` and any of the accessed TxRef values
|
|
21
21
|
* change.
|
|
22
22
|
*
|
|
23
23
|
* @since 4.0.0
|
|
@@ -31,12 +31,12 @@ declare const TypeId = "~effect/transactions/TxRef";
|
|
|
31
31
|
* const ref: TxRef.TxRef<number> = yield* TxRef.make(0)
|
|
32
32
|
*
|
|
33
33
|
* // Use within a transaction
|
|
34
|
-
* yield* Effect.
|
|
34
|
+
* yield* Effect.tx(Effect.gen(function*() {
|
|
35
35
|
* const current = yield* TxRef.get(ref)
|
|
36
36
|
* yield* TxRef.set(ref, current + 1)
|
|
37
37
|
* }))
|
|
38
38
|
*
|
|
39
|
-
* const final = yield*
|
|
39
|
+
* const final = yield* TxRef.get(ref)
|
|
40
40
|
* console.log(final) // 1
|
|
41
41
|
* })
|
|
42
42
|
* ```
|
|
@@ -58,21 +58,21 @@ export interface TxRef<in out A> extends Pipeable {
|
|
|
58
58
|
*
|
|
59
59
|
* const program = Effect.gen(function*() {
|
|
60
60
|
* // Create a transactional reference with initial value
|
|
61
|
-
* const counter = yield*
|
|
62
|
-
* const name = yield*
|
|
61
|
+
* const counter = yield* TxRef.make(0)
|
|
62
|
+
* const name = yield* TxRef.make("Alice")
|
|
63
63
|
*
|
|
64
64
|
* // Use in transactions
|
|
65
|
-
* yield* Effect.
|
|
65
|
+
* yield* Effect.tx(Effect.gen(function*() {
|
|
66
66
|
* yield* TxRef.set(counter, 42)
|
|
67
67
|
* yield* TxRef.set(name, "Bob")
|
|
68
68
|
* }))
|
|
69
69
|
*
|
|
70
|
-
* console.log(yield*
|
|
71
|
-
* console.log(yield*
|
|
70
|
+
* console.log(yield* TxRef.get(counter)) // 42
|
|
71
|
+
* console.log(yield* TxRef.get(name)) // "Bob"
|
|
72
72
|
* })
|
|
73
73
|
* ```
|
|
74
74
|
*/
|
|
75
|
-
export declare const make: <A>(initial: A) => Effect.Effect<TxRef<A>, never,
|
|
75
|
+
export declare const make: <A>(initial: A) => Effect.Effect<TxRef<A>, never, never>;
|
|
76
76
|
/**
|
|
77
77
|
* Creates a new `TxRef` with the specified initial value.
|
|
78
78
|
*
|
|
@@ -105,12 +105,10 @@ export declare const makeUnsafe: <A>(initial: A) => TxRef<A>;
|
|
|
105
105
|
* const counter = yield* TxRef.make(0)
|
|
106
106
|
*
|
|
107
107
|
* // Modify and return both old and new value
|
|
108
|
-
* const result = yield*
|
|
109
|
-
* TxRef.modify(counter, (current) => [current * 2, current + 1])
|
|
110
|
-
* )
|
|
108
|
+
* const result = yield* TxRef.modify(counter, (current) => [current * 2, current + 1])
|
|
111
109
|
*
|
|
112
110
|
* console.log(result) // 0 (the return value: current * 2)
|
|
113
|
-
* console.log(yield*
|
|
111
|
+
* console.log(yield* TxRef.get(counter)) // 1 (the new value: current + 1)
|
|
114
112
|
* })
|
|
115
113
|
* ```
|
|
116
114
|
*/
|
|
@@ -128,16 +126,14 @@ export declare const modify: {
|
|
|
128
126
|
* const counter = yield* TxRef.make(0)
|
|
129
127
|
*
|
|
130
128
|
* // Modify and return both old and new value
|
|
131
|
-
* const result = yield*
|
|
132
|
-
* TxRef.modify(counter, (current) => [current * 2, current + 1])
|
|
133
|
-
* )
|
|
129
|
+
* const result = yield* TxRef.modify(counter, (current) => [current * 2, current + 1])
|
|
134
130
|
*
|
|
135
131
|
* console.log(result) // 0 (the return value: current * 2)
|
|
136
|
-
* console.log(yield*
|
|
132
|
+
* console.log(yield* TxRef.get(counter)) // 1 (the new value: current + 1)
|
|
137
133
|
* })
|
|
138
134
|
* ```
|
|
139
135
|
*/
|
|
140
|
-
<A, R>(f: (current: NoInfer<A>) => [returnValue: R, newValue: A]): (self: TxRef<A>) => Effect.Effect<R
|
|
136
|
+
<A, R>(f: (current: NoInfer<A>) => [returnValue: R, newValue: A]): (self: TxRef<A>) => Effect.Effect<R>;
|
|
141
137
|
/**
|
|
142
138
|
* Modifies the value of the `TxRef` using the provided function.
|
|
143
139
|
*
|
|
@@ -151,16 +147,14 @@ export declare const modify: {
|
|
|
151
147
|
* const counter = yield* TxRef.make(0)
|
|
152
148
|
*
|
|
153
149
|
* // Modify and return both old and new value
|
|
154
|
-
* const result = yield*
|
|
155
|
-
* TxRef.modify(counter, (current) => [current * 2, current + 1])
|
|
156
|
-
* )
|
|
150
|
+
* const result = yield* TxRef.modify(counter, (current) => [current * 2, current + 1])
|
|
157
151
|
*
|
|
158
152
|
* console.log(result) // 0 (the return value: current * 2)
|
|
159
|
-
* console.log(yield*
|
|
153
|
+
* console.log(yield* TxRef.get(counter)) // 1 (the new value: current + 1)
|
|
160
154
|
* })
|
|
161
155
|
* ```
|
|
162
156
|
*/
|
|
163
|
-
<A, R>(self: TxRef<A>, f: (current: A) => [returnValue: R, newValue: A]): Effect.Effect<R
|
|
157
|
+
<A, R>(self: TxRef<A>, f: (current: A) => [returnValue: R, newValue: A]): Effect.Effect<R>;
|
|
164
158
|
};
|
|
165
159
|
/**
|
|
166
160
|
* Updates the value of the `TxRef` using the provided function.
|
|
@@ -175,11 +169,11 @@ export declare const modify: {
|
|
|
175
169
|
* const counter = yield* TxRef.make(10)
|
|
176
170
|
*
|
|
177
171
|
* // Update the value using a function
|
|
178
|
-
* yield* Effect.
|
|
172
|
+
* yield* Effect.tx(
|
|
179
173
|
* TxRef.update(counter, (current) => current * 2)
|
|
180
174
|
* )
|
|
181
175
|
*
|
|
182
|
-
* console.log(yield*
|
|
176
|
+
* console.log(yield* TxRef.get(counter)) // 20
|
|
183
177
|
* })
|
|
184
178
|
* ```
|
|
185
179
|
*/
|
|
@@ -197,15 +191,15 @@ export declare const update: {
|
|
|
197
191
|
* const counter = yield* TxRef.make(10)
|
|
198
192
|
*
|
|
199
193
|
* // Update the value using a function
|
|
200
|
-
* yield* Effect.
|
|
194
|
+
* yield* Effect.tx(
|
|
201
195
|
* TxRef.update(counter, (current) => current * 2)
|
|
202
196
|
* )
|
|
203
197
|
*
|
|
204
|
-
* console.log(yield*
|
|
198
|
+
* console.log(yield* TxRef.get(counter)) // 20
|
|
205
199
|
* })
|
|
206
200
|
* ```
|
|
207
201
|
*/
|
|
208
|
-
<A>(f: (current: NoInfer<A>) => A): (self: TxRef<A>) => Effect.Effect<void
|
|
202
|
+
<A>(f: (current: NoInfer<A>) => A): (self: TxRef<A>) => Effect.Effect<void>;
|
|
209
203
|
/**
|
|
210
204
|
* Updates the value of the `TxRef` using the provided function.
|
|
211
205
|
*
|
|
@@ -219,15 +213,15 @@ export declare const update: {
|
|
|
219
213
|
* const counter = yield* TxRef.make(10)
|
|
220
214
|
*
|
|
221
215
|
* // Update the value using a function
|
|
222
|
-
* yield* Effect.
|
|
216
|
+
* yield* Effect.tx(
|
|
223
217
|
* TxRef.update(counter, (current) => current * 2)
|
|
224
218
|
* )
|
|
225
219
|
*
|
|
226
|
-
* console.log(yield*
|
|
220
|
+
* console.log(yield* TxRef.get(counter)) // 20
|
|
227
221
|
* })
|
|
228
222
|
* ```
|
|
229
223
|
*/
|
|
230
|
-
<A>(self: TxRef<A>, f: (current: A) => A): Effect.Effect<void
|
|
224
|
+
<A>(self: TxRef<A>, f: (current: A) => A): Effect.Effect<void>;
|
|
231
225
|
};
|
|
232
226
|
/**
|
|
233
227
|
* Reads the current value of the `TxRef`.
|
|
@@ -242,7 +236,7 @@ export declare const update: {
|
|
|
242
236
|
* const counter = yield* TxRef.make(42)
|
|
243
237
|
*
|
|
244
238
|
* // Read the value within a transaction
|
|
245
|
-
* const value = yield* Effect.
|
|
239
|
+
* const value = yield* Effect.tx(
|
|
246
240
|
* TxRef.get(counter)
|
|
247
241
|
* )
|
|
248
242
|
*
|
|
@@ -250,7 +244,7 @@ export declare const update: {
|
|
|
250
244
|
* })
|
|
251
245
|
* ```
|
|
252
246
|
*/
|
|
253
|
-
export declare const get: <A>(self: TxRef<A>) => Effect.Effect<A
|
|
247
|
+
export declare const get: <A>(self: TxRef<A>) => Effect.Effect<A>;
|
|
254
248
|
/**
|
|
255
249
|
* Sets the value of the `TxRef`.
|
|
256
250
|
*
|
|
@@ -264,11 +258,11 @@ export declare const get: <A>(self: TxRef<A>) => Effect.Effect<A, never, Effect.
|
|
|
264
258
|
* const counter = yield* TxRef.make(0)
|
|
265
259
|
*
|
|
266
260
|
* // Set a new value within a transaction
|
|
267
|
-
* yield* Effect.
|
|
261
|
+
* yield* Effect.tx(
|
|
268
262
|
* TxRef.set(counter, 100)
|
|
269
263
|
* )
|
|
270
264
|
*
|
|
271
|
-
* console.log(yield*
|
|
265
|
+
* console.log(yield* TxRef.get(counter)) // 100
|
|
272
266
|
* })
|
|
273
267
|
* ```
|
|
274
268
|
*/
|
|
@@ -286,15 +280,15 @@ export declare const set: {
|
|
|
286
280
|
* const counter = yield* TxRef.make(0)
|
|
287
281
|
*
|
|
288
282
|
* // Set a new value within a transaction
|
|
289
|
-
* yield* Effect.
|
|
283
|
+
* yield* Effect.tx(
|
|
290
284
|
* TxRef.set(counter, 100)
|
|
291
285
|
* )
|
|
292
286
|
*
|
|
293
|
-
* console.log(yield*
|
|
287
|
+
* console.log(yield* TxRef.get(counter)) // 100
|
|
294
288
|
* })
|
|
295
289
|
* ```
|
|
296
290
|
*/
|
|
297
|
-
<A>(value: A): (self: TxRef<A>) => Effect.Effect<void
|
|
291
|
+
<A>(value: A): (self: TxRef<A>) => Effect.Effect<void>;
|
|
298
292
|
/**
|
|
299
293
|
* Sets the value of the `TxRef`.
|
|
300
294
|
*
|
|
@@ -308,15 +302,15 @@ export declare const set: {
|
|
|
308
302
|
* const counter = yield* TxRef.make(0)
|
|
309
303
|
*
|
|
310
304
|
* // Set a new value within a transaction
|
|
311
|
-
* yield* Effect.
|
|
305
|
+
* yield* Effect.tx(
|
|
312
306
|
* TxRef.set(counter, 100)
|
|
313
307
|
* )
|
|
314
308
|
*
|
|
315
|
-
* console.log(yield*
|
|
309
|
+
* console.log(yield* TxRef.get(counter)) // 100
|
|
316
310
|
* })
|
|
317
311
|
* ```
|
|
318
312
|
*/
|
|
319
|
-
<A>(self: TxRef<A>, value: A): Effect.Effect<void
|
|
313
|
+
<A>(self: TxRef<A>, value: A): Effect.Effect<void>;
|
|
320
314
|
};
|
|
321
315
|
export {};
|
|
322
316
|
//# sourceMappingURL=TxRef.d.ts.map
|
package/dist/TxRef.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TxRef.d.ts","sourceRoot":"","sources":["../src/TxRef.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAGrC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEzC,QAAA,MAAM,MAAM,+BAA+B,CAAA;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,WAAW,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAE,SAAQ,QAAQ;IAC/C,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,MAAM,CAAA;IAEhC,OAAO,EAAE,MAA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