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
package/src/Effect.ts
CHANGED
|
@@ -22604,107 +22604,56 @@ export class Transaction extends ServiceMap.Service<
|
|
|
22604
22604
|
}
|
|
22605
22605
|
>()("effect/Effect/Transaction") {}
|
|
22606
22606
|
|
|
22607
|
-
/**
|
|
22608
|
-
* Accesses the current transaction state within an active transaction.
|
|
22609
|
-
*
|
|
22610
|
-
* This function requires `Transaction` in the context and does NOT create or strip
|
|
22611
|
-
* transaction boundaries. Use it to interact with the transaction journal (e.g. in
|
|
22612
|
-
* `TxRef` internals). To define a transaction boundary, use {@link transaction}.
|
|
22613
|
-
*
|
|
22614
|
-
* @example
|
|
22615
|
-
* ```ts
|
|
22616
|
-
* import { Effect, TxRef } from "effect"
|
|
22617
|
-
*
|
|
22618
|
-
* const program = Effect.gen(function*() {
|
|
22619
|
-
* const ref = yield* Effect.transaction(TxRef.make(0))
|
|
22620
|
-
*
|
|
22621
|
-
* yield* Effect.transaction(Effect.gen(function*() {
|
|
22622
|
-
* yield* TxRef.set(ref, 42)
|
|
22623
|
-
* return yield* TxRef.get(ref)
|
|
22624
|
-
* }))
|
|
22625
|
-
* })
|
|
22626
|
-
* ```
|
|
22627
|
-
*
|
|
22628
|
-
* @since 4.0.0
|
|
22629
|
-
* @category Transactions
|
|
22630
|
-
*/
|
|
22631
|
-
export const withTxState = <A, E, R>(
|
|
22632
|
-
f: (state: Transaction["Service"]) => Effect<A, E, R>
|
|
22633
|
-
): Effect<A, E, R | Transaction> =>
|
|
22634
|
-
flatMap(
|
|
22635
|
-
Transaction.asEffect(),
|
|
22636
|
-
(state) => internalCall(() => f(state))
|
|
22637
|
-
)
|
|
22638
|
-
|
|
22639
22607
|
/**
|
|
22640
22608
|
* Defines a transaction boundary. Transactions are "all or nothing" with respect to changes
|
|
22641
22609
|
* made to transactional values (i.e. TxRef) that occur within the transaction body.
|
|
22642
22610
|
*
|
|
22611
|
+
* If called inside an active transaction, `tx` composes with the current transaction and reuses
|
|
22612
|
+
* its journal and retry state instead of creating a nested boundary.
|
|
22613
|
+
*
|
|
22643
22614
|
* In Effect transactions are optimistic with retry, that means transactions are retried when:
|
|
22644
22615
|
*
|
|
22645
|
-
* - the body of the transaction explicitely calls to `Effect.
|
|
22616
|
+
* - the body of the transaction explicitely calls to `Effect.txRetry` and any of the
|
|
22646
22617
|
* accessed transactional values changes.
|
|
22647
22618
|
*
|
|
22648
22619
|
* - any of the accessed transactional values change during the execution of the transaction
|
|
22649
22620
|
* due to a different transaction committing before the current.
|
|
22650
22621
|
*
|
|
22651
|
-
*
|
|
22652
|
-
*
|
|
22622
|
+
* The outermost `tx` call creates the transaction boundary and commits or rolls back the full
|
|
22623
|
+
* composed transaction.
|
|
22653
22624
|
*
|
|
22654
22625
|
* @example
|
|
22655
22626
|
* ```ts
|
|
22656
22627
|
* import { Effect, TxRef } from "effect"
|
|
22657
22628
|
*
|
|
22658
22629
|
* const program = Effect.gen(function*() {
|
|
22659
|
-
* const ref1 = yield*
|
|
22660
|
-
* const ref2 = yield*
|
|
22630
|
+
* const ref1 = yield* TxRef.make(0)
|
|
22631
|
+
* const ref2 = yield* TxRef.make(0)
|
|
22661
22632
|
*
|
|
22662
|
-
* //
|
|
22663
|
-
* yield* Effect.
|
|
22633
|
+
* // Nested tx calls compose into the same transaction
|
|
22634
|
+
* yield* Effect.tx(Effect.gen(function*() {
|
|
22664
22635
|
* yield* TxRef.set(ref1, 10)
|
|
22665
|
-
* yield* TxRef.set(ref2, 20)
|
|
22636
|
+
* yield* Effect.tx(TxRef.set(ref2, 20))
|
|
22666
22637
|
* const sum = (yield* TxRef.get(ref1)) + (yield* TxRef.get(ref2))
|
|
22667
22638
|
* console.log(`Transaction sum: ${sum}`)
|
|
22668
22639
|
* }))
|
|
22669
22640
|
*
|
|
22670
|
-
* console.log(`Final ref1: ${yield*
|
|
22671
|
-
* console.log(`Final ref2: ${yield*
|
|
22641
|
+
* console.log(`Final ref1: ${yield* TxRef.get(ref1)}`) // 10
|
|
22642
|
+
* console.log(`Final ref2: ${yield* TxRef.get(ref2)}`) // 20
|
|
22672
22643
|
* })
|
|
22673
22644
|
* ```
|
|
22674
22645
|
*
|
|
22675
22646
|
* @since 4.0.0
|
|
22676
22647
|
* @category Transactions
|
|
22677
22648
|
*/
|
|
22678
|
-
export const
|
|
22649
|
+
export const tx = <A, E, R>(
|
|
22679
22650
|
effect: Effect<A, E, R>
|
|
22680
|
-
): Effect<A, E, Exclude<R, Transaction>> => transactionWith(() => effect)
|
|
22681
|
-
|
|
22682
|
-
/**
|
|
22683
|
-
* Like {@link transaction} but provides access to the transaction state.
|
|
22684
|
-
*
|
|
22685
|
-
* Always creates a new isolated transaction boundary with its own journal and retry logic.
|
|
22686
|
-
*
|
|
22687
|
-
* @example
|
|
22688
|
-
* ```ts
|
|
22689
|
-
* import { Effect, TxRef } from "effect"
|
|
22690
|
-
*
|
|
22691
|
-
* const program = Effect.transactionWith((_txState) =>
|
|
22692
|
-
* Effect.gen(function*() {
|
|
22693
|
-
* const ref = yield* TxRef.make(0)
|
|
22694
|
-
* yield* TxRef.set(ref, 42)
|
|
22695
|
-
* return yield* TxRef.get(ref)
|
|
22696
|
-
* })
|
|
22697
|
-
* )
|
|
22698
|
-
* ```
|
|
22699
|
-
*
|
|
22700
|
-
* @since 4.0.0
|
|
22701
|
-
* @category Transactions
|
|
22702
|
-
*/
|
|
22703
|
-
export const transactionWith = <A, E, R>(
|
|
22704
|
-
f: (state: Transaction["Service"]) => Effect<A, E, R>
|
|
22705
22651
|
): Effect<A, E, Exclude<R, Transaction>> =>
|
|
22706
22652
|
withFiber((fiber) => {
|
|
22707
|
-
|
|
22653
|
+
if (fiber.services.mapUnsafe.has(Transaction.key)) {
|
|
22654
|
+
return effect as Effect<A, E, Exclude<R, Transaction>>
|
|
22655
|
+
}
|
|
22656
|
+
// Create transaction state only at the outermost boundary
|
|
22708
22657
|
const state: Transaction["Service"] = { journal: new Map(), retry: false }
|
|
22709
22658
|
let result: Exit.Exit<A, E> | undefined
|
|
22710
22659
|
return uninterruptibleMask((restore) =>
|
|
@@ -22712,7 +22661,7 @@ export const transactionWith = <A, E, R>(
|
|
|
22712
22661
|
whileLoop({
|
|
22713
22662
|
while: () => !result,
|
|
22714
22663
|
body: constant(
|
|
22715
|
-
restore(
|
|
22664
|
+
restore(effect).pipe(
|
|
22716
22665
|
provideService(Transaction, state),
|
|
22717
22666
|
tapCause(() => {
|
|
22718
22667
|
if (!state.retry) return void_
|
|
@@ -22801,20 +22750,20 @@ function clearTransaction(state: Transaction["Service"]) {
|
|
|
22801
22750
|
*
|
|
22802
22751
|
* const program = Effect.gen(function*() {
|
|
22803
22752
|
* // create a transactional reference
|
|
22804
|
-
* const ref = yield*
|
|
22753
|
+
* const ref = yield* TxRef.make(0)
|
|
22805
22754
|
*
|
|
22806
22755
|
* // forks a fiber that increases the value of `ref` every 100 millis
|
|
22807
22756
|
* yield* Effect.forkChild(Effect.forever(
|
|
22808
22757
|
* // update to transactional value
|
|
22809
|
-
* Effect.
|
|
22758
|
+
* Effect.tx(TxRef.update(ref, (n) => n + 1)).pipe(Effect.delay("100 millis"))
|
|
22810
22759
|
* ))
|
|
22811
22760
|
*
|
|
22812
22761
|
* // the following will retry 10 times until the `ref` value is 10
|
|
22813
|
-
* yield* Effect.
|
|
22762
|
+
* yield* Effect.tx(Effect.gen(function*() {
|
|
22814
22763
|
* const value = yield* TxRef.get(ref)
|
|
22815
22764
|
* if (value < 10) {
|
|
22816
22765
|
* yield* Effect.log(`retry due to value: ${value}`)
|
|
22817
|
-
* return yield* Effect.
|
|
22766
|
+
* return yield* Effect.txRetry
|
|
22818
22767
|
* }
|
|
22819
22768
|
* yield* Effect.log(`transaction done with value: ${value}`)
|
|
22820
22769
|
* }))
|
|
@@ -22823,7 +22772,7 @@ function clearTransaction(state: Transaction["Service"]) {
|
|
|
22823
22772
|
* Effect.runPromise(program).catch(console.error)
|
|
22824
22773
|
* ```
|
|
22825
22774
|
*/
|
|
22826
|
-
export const
|
|
22775
|
+
export const txRetry: Effect<never, never, Transaction> = flatMap(
|
|
22827
22776
|
Transaction.asEffect(),
|
|
22828
22777
|
(state) => {
|
|
22829
22778
|
state.retry = true
|
package/src/MutableList.ts
CHANGED
|
@@ -507,6 +507,9 @@ export const appendAll = <A>(self: MutableList<A>, messages: Iterable<A>): numbe
|
|
|
507
507
|
* @category mutations
|
|
508
508
|
*/
|
|
509
509
|
export const appendAllUnsafe = <A>(self: MutableList<A>, messages: ReadonlyArray<A>, mutable = false): number => {
|
|
510
|
+
if (messages.length === 0) {
|
|
511
|
+
return 0
|
|
512
|
+
}
|
|
510
513
|
const chunk: MutableList.Bucket<A> = {
|
|
511
514
|
array: messages as Array<A>,
|
|
512
515
|
mutable,
|
package/src/Number.ts
CHANGED
|
@@ -957,15 +957,25 @@ export const remainder: {
|
|
|
957
957
|
*/
|
|
958
958
|
(self: number, divisor: number): number
|
|
959
959
|
} = dual(2, (self: number, divisor: number): number => {
|
|
960
|
-
|
|
961
|
-
const
|
|
962
|
-
const divisorDecCount = (divisor.toString().split(".")[1] || "").length
|
|
960
|
+
const selfDecCount = decimalCount(self)
|
|
961
|
+
const divisorDecCount = decimalCount(divisor)
|
|
963
962
|
const decCount = selfDecCount > divisorDecCount ? selfDecCount : divisorDecCount
|
|
964
963
|
const selfInt = parseInt(self.toFixed(decCount).replace(".", ""))
|
|
965
964
|
const divisorInt = parseInt(divisor.toFixed(decCount).replace(".", ""))
|
|
966
965
|
return (selfInt % divisorInt) / Math.pow(10, decCount)
|
|
967
966
|
})
|
|
968
967
|
|
|
968
|
+
function decimalCount(n: number): number {
|
|
969
|
+
const s = n.toString()
|
|
970
|
+
const eIndex = s.indexOf("e-")
|
|
971
|
+
if (eIndex !== -1) {
|
|
972
|
+
const exp = parseInt(s.slice(eIndex + 2))
|
|
973
|
+
const mantissaDecimals = (s.slice(0, eIndex).split(".")[1] || "").length
|
|
974
|
+
return mantissaDecimals + exp
|
|
975
|
+
}
|
|
976
|
+
return (s.split(".")[1] || "").length
|
|
977
|
+
}
|
|
978
|
+
|
|
969
979
|
/**
|
|
970
980
|
* Returns the next power of 2 from the given number.
|
|
971
981
|
*
|
|
@@ -3015,7 +3015,13 @@ export function fromJsonSchemaMultiDocument(document: JsonSchema.MultiDocument<"
|
|
|
3015
3015
|
}
|
|
3016
3016
|
|
|
3017
3017
|
if (Array.isArray(js.allOf)) {
|
|
3018
|
-
|
|
3018
|
+
out = js.allOf.reduce((acc, curr) => combine(acc, recur(curr)), out)
|
|
3019
|
+
}
|
|
3020
|
+
if (Array.isArray(js.anyOf)) {
|
|
3021
|
+
out = combine({ _tag: "Union", types: js.anyOf.map((type) => recur(type)), mode: "anyOf" }, out)
|
|
3022
|
+
}
|
|
3023
|
+
if (Array.isArray(js.oneOf)) {
|
|
3024
|
+
out = combine({ _tag: "Union", types: js.oneOf.map((type) => recur(type)), mode: "oneOf" }, out)
|
|
3019
3025
|
}
|
|
3020
3026
|
|
|
3021
3027
|
return out
|
|
@@ -3054,10 +3060,6 @@ export function fromJsonSchemaMultiDocument(document: JsonSchema.MultiDocument<"
|
|
|
3054
3060
|
} else {
|
|
3055
3061
|
return { _tag: "Union", types, mode: "anyOf" }
|
|
3056
3062
|
}
|
|
3057
|
-
} else if (Array.isArray(js.anyOf)) {
|
|
3058
|
-
return { _tag: "Union", types: js.anyOf.map((type) => recur(type)), mode: "anyOf" }
|
|
3059
|
-
} else if (Array.isArray(js.oneOf)) {
|
|
3060
|
-
return { _tag: "Union", types: js.oneOf.map((type) => recur(type)), mode: "oneOf" }
|
|
3061
3063
|
}
|
|
3062
3064
|
|
|
3063
3065
|
const type = isType(js.type) ? js.type : getType(js)
|
|
@@ -3290,7 +3292,7 @@ export function fromJsonSchemaMultiDocument(document: JsonSchema.MultiDocument<"
|
|
|
3290
3292
|
return {
|
|
3291
3293
|
_tag: "Union",
|
|
3292
3294
|
types,
|
|
3293
|
-
mode:
|
|
3295
|
+
mode: a.mode,
|
|
3294
3296
|
...makeAnnotations(a.annotations)
|
|
3295
3297
|
}
|
|
3296
3298
|
}
|
package/src/TxChunk.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Accessed values are tracked by the transaction in order to detect conflicts and to track changes.
|
|
7
7
|
* A transaction will retry whenever a conflict is detected or whenever the transaction explicitly
|
|
8
|
-
* calls `Effect.
|
|
8
|
+
* calls `Effect.txRetry` and any of the accessed TxChunk values change.
|
|
9
9
|
*
|
|
10
10
|
* @since 4.0.0
|
|
11
11
|
*/
|
|
@@ -28,7 +28,7 @@ const TypeId = "~effect/transactions/TxChunk"
|
|
|
28
28
|
*
|
|
29
29
|
* Accessed values are tracked by the transaction in order to detect conflicts and to track changes.
|
|
30
30
|
* A transaction will retry whenever a conflict is detected or whenever the transaction explicitly
|
|
31
|
-
* calls `Effect.
|
|
31
|
+
* calls `Effect.txRetry` and any of the accessed TxChunk values change.
|
|
32
32
|
*
|
|
33
33
|
* @example
|
|
34
34
|
* ```ts
|
|
@@ -48,7 +48,7 @@ const TypeId = "~effect/transactions/TxChunk"
|
|
|
48
48
|
* console.log(Chunk.toReadonlyArray(result)) // [1, 2, 3, 4]
|
|
49
49
|
*
|
|
50
50
|
* // Multi-step atomic operation - use explicit transaction
|
|
51
|
-
* yield* Effect.
|
|
51
|
+
* yield* Effect.tx(
|
|
52
52
|
* Effect.gen(function*() {
|
|
53
53
|
* yield* TxChunk.prepend(txChunk, 0)
|
|
54
54
|
* yield* TxChunk.append(txChunk, 5)
|
|
@@ -109,7 +109,7 @@ const TxChunkProto = {
|
|
|
109
109
|
* })
|
|
110
110
|
* ```
|
|
111
111
|
*/
|
|
112
|
-
export const make = <A>(initial: Chunk.Chunk<A>): Effect.Effect<TxChunk<A
|
|
112
|
+
export const make = <A>(initial: Chunk.Chunk<A>): Effect.Effect<TxChunk<A>> =>
|
|
113
113
|
Effect.map(TxRef.make(initial), (ref) => makeUnsafe(ref))
|
|
114
114
|
|
|
115
115
|
/**
|
|
@@ -140,7 +140,7 @@ export const make = <A>(initial: Chunk.Chunk<A>): Effect.Effect<TxChunk<A>, neve
|
|
|
140
140
|
* })
|
|
141
141
|
* ```
|
|
142
142
|
*/
|
|
143
|
-
export const empty = <A = never>(): Effect.Effect<TxChunk<A
|
|
143
|
+
export const empty = <A = never>(): Effect.Effect<TxChunk<A>> =>
|
|
144
144
|
Effect.map(TxRef.make(Chunk.empty<A>()), (ref) => makeUnsafe(ref))
|
|
145
145
|
|
|
146
146
|
/**
|
|
@@ -164,7 +164,7 @@ export const empty = <A = never>(): Effect.Effect<TxChunk<A>, never, Effect.Tran
|
|
|
164
164
|
* console.log(Chunk.toReadonlyArray(chunk)) // [1, 2, 3, 4, 5]
|
|
165
165
|
*
|
|
166
166
|
* // Multi-step atomic modification - use explicit transaction
|
|
167
|
-
* yield* Effect.
|
|
167
|
+
* yield* Effect.tx(
|
|
168
168
|
* Effect.gen(function*() {
|
|
169
169
|
* yield* TxChunk.append(txChunk, 6)
|
|
170
170
|
* yield* TxChunk.prepend(txChunk, 0)
|
|
@@ -176,7 +176,7 @@ export const empty = <A = never>(): Effect.Effect<TxChunk<A>, never, Effect.Tran
|
|
|
176
176
|
* })
|
|
177
177
|
* ```
|
|
178
178
|
*/
|
|
179
|
-
export const fromIterable = <A>(iterable: Iterable<A>): Effect.Effect<TxChunk<A
|
|
179
|
+
export const fromIterable = <A>(iterable: Iterable<A>): Effect.Effect<TxChunk<A>> =>
|
|
180
180
|
Effect.map(TxRef.make(Chunk.fromIterable(iterable)), (ref) => makeUnsafe(ref))
|
|
181
181
|
|
|
182
182
|
/**
|
|
@@ -263,9 +263,7 @@ export const modify: {
|
|
|
263
263
|
*/
|
|
264
264
|
<A, R>(
|
|
265
265
|
f: (current: Chunk.Chunk<NoInfer<A>>) => [returnValue: R, newValue: Chunk.Chunk<A>]
|
|
266
|
-
): (
|
|
267
|
-
self: TxChunk<A>
|
|
268
|
-
) => Effect.Effect<R, never, Effect.Transaction>
|
|
266
|
+
): (self: TxChunk<A>) => Effect.Effect<R>
|
|
269
267
|
/**
|
|
270
268
|
* Modifies the value of the `TxChunk` using the provided function.
|
|
271
269
|
*
|
|
@@ -297,13 +295,13 @@ export const modify: {
|
|
|
297
295
|
<A, R>(
|
|
298
296
|
self: TxChunk<A>,
|
|
299
297
|
f: (current: Chunk.Chunk<A>) => [returnValue: R, newValue: Chunk.Chunk<A>]
|
|
300
|
-
): Effect.Effect<R
|
|
298
|
+
): Effect.Effect<R>
|
|
301
299
|
} = dual(
|
|
302
300
|
2,
|
|
303
301
|
<A, R>(
|
|
304
302
|
self: TxChunk<A>,
|
|
305
303
|
f: (current: Chunk.Chunk<A>) => [returnValue: R, newValue: Chunk.Chunk<A>]
|
|
306
|
-
): Effect.Effect<R
|
|
304
|
+
): Effect.Effect<R> => TxRef.modify(self.ref, f)
|
|
307
305
|
)
|
|
308
306
|
|
|
309
307
|
/**
|
|
@@ -357,7 +355,7 @@ export const update: {
|
|
|
357
355
|
* @since 4.0.0
|
|
358
356
|
* @category combinators
|
|
359
357
|
*/
|
|
360
|
-
<A>(f: (current: Chunk.Chunk<NoInfer<A>>) => Chunk.Chunk<A>): (self: TxChunk<A>) => Effect.Effect<void
|
|
358
|
+
<A>(f: (current: Chunk.Chunk<NoInfer<A>>) => Chunk.Chunk<A>): (self: TxChunk<A>) => Effect.Effect<void>
|
|
361
359
|
/**
|
|
362
360
|
* Updates the value of the `TxChunk` using the provided function.
|
|
363
361
|
*
|
|
@@ -383,13 +381,13 @@ export const update: {
|
|
|
383
381
|
* @since 4.0.0
|
|
384
382
|
* @category combinators
|
|
385
383
|
*/
|
|
386
|
-
<A>(self: TxChunk<A>, f: (current: Chunk.Chunk<A>) => Chunk.Chunk<A>): Effect.Effect<void
|
|
384
|
+
<A>(self: TxChunk<A>, f: (current: Chunk.Chunk<A>) => Chunk.Chunk<A>): Effect.Effect<void>
|
|
387
385
|
} = dual(
|
|
388
386
|
2,
|
|
389
387
|
<A>(
|
|
390
388
|
self: TxChunk<A>,
|
|
391
389
|
f: (current: Chunk.Chunk<A>) => Chunk.Chunk<A>
|
|
392
|
-
): Effect.Effect<void
|
|
390
|
+
): Effect.Effect<void> => TxRef.update(self.ref, f)
|
|
393
391
|
)
|
|
394
392
|
|
|
395
393
|
/**
|
|
@@ -415,8 +413,7 @@ export const update: {
|
|
|
415
413
|
* @since 4.0.0
|
|
416
414
|
* @category combinators
|
|
417
415
|
*/
|
|
418
|
-
export const get = <A>(self: TxChunk<A>): Effect.Effect<Chunk.Chunk<A
|
|
419
|
-
TxRef.get(self.ref)
|
|
416
|
+
export const get = <A>(self: TxChunk<A>): Effect.Effect<Chunk.Chunk<A>> => TxRef.get(self.ref)
|
|
420
417
|
|
|
421
418
|
/**
|
|
422
419
|
* Sets the value of the `TxChunk`.
|
|
@@ -469,7 +466,7 @@ export const set: {
|
|
|
469
466
|
* @since 4.0.0
|
|
470
467
|
* @category combinators
|
|
471
468
|
*/
|
|
472
|
-
<A>(chunk: Chunk.Chunk<A>): (self: TxChunk<A>) => Effect.Effect<void
|
|
469
|
+
<A>(chunk: Chunk.Chunk<A>): (self: TxChunk<A>) => Effect.Effect<void>
|
|
473
470
|
/**
|
|
474
471
|
* Sets the value of the `TxChunk`.
|
|
475
472
|
*
|
|
@@ -495,11 +492,10 @@ export const set: {
|
|
|
495
492
|
* @since 4.0.0
|
|
496
493
|
* @category combinators
|
|
497
494
|
*/
|
|
498
|
-
<A>(self: TxChunk<A>, chunk: Chunk.Chunk<A>): Effect.Effect<void
|
|
495
|
+
<A>(self: TxChunk<A>, chunk: Chunk.Chunk<A>): Effect.Effect<void>
|
|
499
496
|
} = dual(
|
|
500
497
|
2,
|
|
501
|
-
<A>(self: TxChunk<A>, chunk: Chunk.Chunk<A>): Effect.Effect<void
|
|
502
|
-
TxRef.set(self.ref, chunk)
|
|
498
|
+
<A>(self: TxChunk<A>, chunk: Chunk.Chunk<A>): Effect.Effect<void> => TxRef.set(self.ref, chunk)
|
|
503
499
|
)
|
|
504
500
|
|
|
505
501
|
/**
|
|
@@ -551,7 +547,7 @@ export const append: {
|
|
|
551
547
|
* @since 4.0.0
|
|
552
548
|
* @category combinators
|
|
553
549
|
*/
|
|
554
|
-
<A>(element: A): (self: TxChunk<A>) => Effect.Effect<void
|
|
550
|
+
<A>(element: A): (self: TxChunk<A>) => Effect.Effect<void>
|
|
555
551
|
/**
|
|
556
552
|
* Appends an element to the end of the `TxChunk`.
|
|
557
553
|
*
|
|
@@ -576,11 +572,10 @@ export const append: {
|
|
|
576
572
|
* @since 4.0.0
|
|
577
573
|
* @category combinators
|
|
578
574
|
*/
|
|
579
|
-
<A>(self: TxChunk<A>, element: A): Effect.Effect<void
|
|
575
|
+
<A>(self: TxChunk<A>, element: A): Effect.Effect<void>
|
|
580
576
|
} = dual(
|
|
581
577
|
2,
|
|
582
|
-
<A>(self: TxChunk<A>, element: A): Effect.Effect<void
|
|
583
|
-
update(self, (current) => Chunk.append(current, element))
|
|
578
|
+
<A>(self: TxChunk<A>, element: A): Effect.Effect<void> => update(self, (current) => Chunk.append(current, element))
|
|
584
579
|
)
|
|
585
580
|
|
|
586
581
|
/**
|
|
@@ -632,7 +627,7 @@ export const prepend: {
|
|
|
632
627
|
* @since 4.0.0
|
|
633
628
|
* @category combinators
|
|
634
629
|
*/
|
|
635
|
-
<A>(element: A): (self: TxChunk<A>) => Effect.Effect<void
|
|
630
|
+
<A>(element: A): (self: TxChunk<A>) => Effect.Effect<void>
|
|
636
631
|
/**
|
|
637
632
|
* Prepends an element to the beginning of the `TxChunk`.
|
|
638
633
|
*
|
|
@@ -657,11 +652,10 @@ export const prepend: {
|
|
|
657
652
|
* @since 4.0.0
|
|
658
653
|
* @category combinators
|
|
659
654
|
*/
|
|
660
|
-
<A>(self: TxChunk<A>, element: A): Effect.Effect<void
|
|
655
|
+
<A>(self: TxChunk<A>, element: A): Effect.Effect<void>
|
|
661
656
|
} = dual(
|
|
662
657
|
2,
|
|
663
|
-
<A>(self: TxChunk<A>, element: A): Effect.Effect<void
|
|
664
|
-
update(self, (current) => Chunk.prepend(current, element))
|
|
658
|
+
<A>(self: TxChunk<A>, element: A): Effect.Effect<void> => update(self, (current) => Chunk.prepend(current, element))
|
|
665
659
|
)
|
|
666
660
|
|
|
667
661
|
/**
|
|
@@ -688,7 +682,7 @@ export const prepend: {
|
|
|
688
682
|
* @since 4.0.0
|
|
689
683
|
* @category combinators
|
|
690
684
|
*/
|
|
691
|
-
export const size = <A>(self: TxChunk<A>): Effect.Effect<number
|
|
685
|
+
export const size = <A>(self: TxChunk<A>): Effect.Effect<number> =>
|
|
692
686
|
modify(self, (current) => [Chunk.size(current), current])
|
|
693
687
|
|
|
694
688
|
/**
|
|
@@ -714,7 +708,7 @@ export const size = <A>(self: TxChunk<A>): Effect.Effect<number, never, Effect.T
|
|
|
714
708
|
* @since 4.0.0
|
|
715
709
|
* @category combinators
|
|
716
710
|
*/
|
|
717
|
-
export const isEmpty = <A>(self: TxChunk<A>): Effect.Effect<boolean
|
|
711
|
+
export const isEmpty = <A>(self: TxChunk<A>): Effect.Effect<boolean> =>
|
|
718
712
|
modify(self, (current) => [Chunk.isEmpty(current), current])
|
|
719
713
|
|
|
720
714
|
/**
|
|
@@ -740,7 +734,7 @@ export const isEmpty = <A>(self: TxChunk<A>): Effect.Effect<boolean, never, Effe
|
|
|
740
734
|
* @since 4.0.0
|
|
741
735
|
* @category combinators
|
|
742
736
|
*/
|
|
743
|
-
export const isNonEmpty = <A>(self: TxChunk<A>): Effect.Effect<boolean
|
|
737
|
+
export const isNonEmpty = <A>(self: TxChunk<A>): Effect.Effect<boolean> =>
|
|
744
738
|
modify(self, (current) => [Chunk.isNonEmpty(current), current])
|
|
745
739
|
|
|
746
740
|
/**
|
|
@@ -792,7 +786,7 @@ export const take: {
|
|
|
792
786
|
* @since 4.0.0
|
|
793
787
|
* @category combinators
|
|
794
788
|
*/
|
|
795
|
-
(n: number): <A>(self: TxChunk<A>) => Effect.Effect<void
|
|
789
|
+
(n: number): <A>(self: TxChunk<A>) => Effect.Effect<void>
|
|
796
790
|
/**
|
|
797
791
|
* Takes the first `n` elements from the `TxChunk`.
|
|
798
792
|
*
|
|
@@ -817,11 +811,10 @@ export const take: {
|
|
|
817
811
|
* @since 4.0.0
|
|
818
812
|
* @category combinators
|
|
819
813
|
*/
|
|
820
|
-
<A>(self: TxChunk<A>, n: number): Effect.Effect<void
|
|
814
|
+
<A>(self: TxChunk<A>, n: number): Effect.Effect<void>
|
|
821
815
|
} = dual(
|
|
822
816
|
2,
|
|
823
|
-
<A>(self: TxChunk<A>, n: number): Effect.Effect<void
|
|
824
|
-
update(self, (current) => Chunk.take(current, n))
|
|
817
|
+
<A>(self: TxChunk<A>, n: number): Effect.Effect<void> => update(self, (current) => Chunk.take(current, n))
|
|
825
818
|
)
|
|
826
819
|
|
|
827
820
|
/**
|
|
@@ -873,7 +866,7 @@ export const drop: {
|
|
|
873
866
|
* @since 4.0.0
|
|
874
867
|
* @category combinators
|
|
875
868
|
*/
|
|
876
|
-
(n: number): <A>(self: TxChunk<A>) => Effect.Effect<void
|
|
869
|
+
(n: number): <A>(self: TxChunk<A>) => Effect.Effect<void>
|
|
877
870
|
/**
|
|
878
871
|
* Drops the first `n` elements from the `TxChunk`.
|
|
879
872
|
*
|
|
@@ -898,11 +891,10 @@ export const drop: {
|
|
|
898
891
|
* @since 4.0.0
|
|
899
892
|
* @category combinators
|
|
900
893
|
*/
|
|
901
|
-
<A>(self: TxChunk<A>, n: number): Effect.Effect<void
|
|
894
|
+
<A>(self: TxChunk<A>, n: number): Effect.Effect<void>
|
|
902
895
|
} = dual(
|
|
903
896
|
2,
|
|
904
|
-
<A>(self: TxChunk<A>, n: number): Effect.Effect<void
|
|
905
|
-
update(self, (current) => Chunk.drop(current, n))
|
|
897
|
+
<A>(self: TxChunk<A>, n: number): Effect.Effect<void> => update(self, (current) => Chunk.drop(current, n))
|
|
906
898
|
)
|
|
907
899
|
|
|
908
900
|
/**
|
|
@@ -954,7 +946,7 @@ export const slice: {
|
|
|
954
946
|
* @since 4.0.0
|
|
955
947
|
* @category combinators
|
|
956
948
|
*/
|
|
957
|
-
(start: number, end: number): <A>(self: TxChunk<A>) => Effect.Effect<void
|
|
949
|
+
(start: number, end: number): <A>(self: TxChunk<A>) => Effect.Effect<void>
|
|
958
950
|
/**
|
|
959
951
|
* Takes a slice of the `TxChunk` from `start` to `end` (exclusive).
|
|
960
952
|
*
|
|
@@ -979,10 +971,10 @@ export const slice: {
|
|
|
979
971
|
* @since 4.0.0
|
|
980
972
|
* @category combinators
|
|
981
973
|
*/
|
|
982
|
-
<A>(self: TxChunk<A>, start: number, end: number): Effect.Effect<void
|
|
974
|
+
<A>(self: TxChunk<A>, start: number, end: number): Effect.Effect<void>
|
|
983
975
|
} = dual(
|
|
984
976
|
3,
|
|
985
|
-
<A>(self: TxChunk<A>, start: number, end: number): Effect.Effect<void
|
|
977
|
+
<A>(self: TxChunk<A>, start: number, end: number): Effect.Effect<void> =>
|
|
986
978
|
update(self, (current) => Chunk.take(Chunk.drop(current, start), end - start))
|
|
987
979
|
)
|
|
988
980
|
|
|
@@ -1039,7 +1031,7 @@ export const map: {
|
|
|
1039
1031
|
* @since 4.0.0
|
|
1040
1032
|
* @category combinators
|
|
1041
1033
|
*/
|
|
1042
|
-
<A>(f: (a: NoInfer<A>) => A): (self: TxChunk<A>) => Effect.Effect<void
|
|
1034
|
+
<A>(f: (a: NoInfer<A>) => A): (self: TxChunk<A>) => Effect.Effect<void>
|
|
1043
1035
|
/**
|
|
1044
1036
|
* Maps each element of the `TxChunk` using the provided function.
|
|
1045
1037
|
* Note: This only works when the mapped type B is assignable to A.
|
|
@@ -1066,11 +1058,10 @@ export const map: {
|
|
|
1066
1058
|
* @since 4.0.0
|
|
1067
1059
|
* @category combinators
|
|
1068
1060
|
*/
|
|
1069
|
-
<A>(self: TxChunk<A>, f: (a: A) => A): Effect.Effect<void
|
|
1061
|
+
<A>(self: TxChunk<A>, f: (a: A) => A): Effect.Effect<void>
|
|
1070
1062
|
} = dual(
|
|
1071
1063
|
2,
|
|
1072
|
-
<A>(self: TxChunk<A>, f: (a: A) => A): Effect.Effect<void
|
|
1073
|
-
update(self, (current) => Chunk.map(current, f))
|
|
1064
|
+
<A>(self: TxChunk<A>, f: (a: A) => A): Effect.Effect<void> => update(self, (current) => Chunk.map(current, f))
|
|
1074
1065
|
)
|
|
1075
1066
|
|
|
1076
1067
|
/**
|
|
@@ -1124,7 +1115,7 @@ export const filter: {
|
|
|
1124
1115
|
* @since 4.0.0
|
|
1125
1116
|
* @category combinators
|
|
1126
1117
|
*/
|
|
1127
|
-
<A, B extends A>(refinement: (a: A) => a is B): (self: TxChunk<A>) => Effect.Effect<void
|
|
1118
|
+
<A, B extends A>(refinement: (a: A) => a is B): (self: TxChunk<A>) => Effect.Effect<void>
|
|
1128
1119
|
/**
|
|
1129
1120
|
* Filters the `TxChunk` keeping only elements that satisfy the predicate.
|
|
1130
1121
|
*
|
|
@@ -1150,7 +1141,7 @@ export const filter: {
|
|
|
1150
1141
|
* @since 4.0.0
|
|
1151
1142
|
* @category combinators
|
|
1152
1143
|
*/
|
|
1153
|
-
<A>(predicate: (a: A) => boolean): (self: TxChunk<A>) => Effect.Effect<void
|
|
1144
|
+
<A>(predicate: (a: A) => boolean): (self: TxChunk<A>) => Effect.Effect<void>
|
|
1154
1145
|
/**
|
|
1155
1146
|
* Filters the `TxChunk` keeping only elements that satisfy the predicate.
|
|
1156
1147
|
*
|
|
@@ -1176,7 +1167,7 @@ export const filter: {
|
|
|
1176
1167
|
* @since 4.0.0
|
|
1177
1168
|
* @category combinators
|
|
1178
1169
|
*/
|
|
1179
|
-
<A, B extends A>(self: TxChunk<A>, refinement: (a: A) => a is B): Effect.Effect<void
|
|
1170
|
+
<A, B extends A>(self: TxChunk<A>, refinement: (a: A) => a is B): Effect.Effect<void>
|
|
1180
1171
|
/**
|
|
1181
1172
|
* Filters the `TxChunk` keeping only elements that satisfy the predicate.
|
|
1182
1173
|
*
|
|
@@ -1202,10 +1193,10 @@ export const filter: {
|
|
|
1202
1193
|
* @since 4.0.0
|
|
1203
1194
|
* @category combinators
|
|
1204
1195
|
*/
|
|
1205
|
-
<A>(self: TxChunk<A>, predicate: (a: A) => boolean): Effect.Effect<void
|
|
1196
|
+
<A>(self: TxChunk<A>, predicate: (a: A) => boolean): Effect.Effect<void>
|
|
1206
1197
|
} = dual(
|
|
1207
1198
|
2,
|
|
1208
|
-
<A>(self: TxChunk<A>, predicate: (a: A) => boolean): Effect.Effect<void
|
|
1199
|
+
<A>(self: TxChunk<A>, predicate: (a: A) => boolean): Effect.Effect<void> =>
|
|
1209
1200
|
update(self, (current) => Chunk.filter(current, predicate))
|
|
1210
1201
|
)
|
|
1211
1202
|
|
|
@@ -1262,7 +1253,7 @@ export const appendAll: {
|
|
|
1262
1253
|
* @since 4.0.0
|
|
1263
1254
|
* @category combinators
|
|
1264
1255
|
*/
|
|
1265
|
-
<A>(other: Chunk.Chunk<A>): (self: TxChunk<A>) => Effect.Effect<void
|
|
1256
|
+
<A>(other: Chunk.Chunk<A>): (self: TxChunk<A>) => Effect.Effect<void>
|
|
1266
1257
|
/**
|
|
1267
1258
|
* Concatenates another chunk to the end of the `TxChunk`.
|
|
1268
1259
|
*
|
|
@@ -1289,10 +1280,10 @@ export const appendAll: {
|
|
|
1289
1280
|
* @since 4.0.0
|
|
1290
1281
|
* @category combinators
|
|
1291
1282
|
*/
|
|
1292
|
-
<A>(self: TxChunk<A>, other: Chunk.Chunk<A>): Effect.Effect<void
|
|
1283
|
+
<A>(self: TxChunk<A>, other: Chunk.Chunk<A>): Effect.Effect<void>
|
|
1293
1284
|
} = dual(
|
|
1294
1285
|
2,
|
|
1295
|
-
<A>(self: TxChunk<A>, other: Chunk.Chunk<A>): Effect.Effect<void
|
|
1286
|
+
<A>(self: TxChunk<A>, other: Chunk.Chunk<A>): Effect.Effect<void> =>
|
|
1296
1287
|
update(self, (current) => Chunk.appendAll(current, other))
|
|
1297
1288
|
)
|
|
1298
1289
|
|
|
@@ -1349,7 +1340,7 @@ export const prependAll: {
|
|
|
1349
1340
|
* @since 4.0.0
|
|
1350
1341
|
* @category combinators
|
|
1351
1342
|
*/
|
|
1352
|
-
<A>(other: Chunk.Chunk<A>): (self: TxChunk<A>) => Effect.Effect<void
|
|
1343
|
+
<A>(other: Chunk.Chunk<A>): (self: TxChunk<A>) => Effect.Effect<void>
|
|
1353
1344
|
/**
|
|
1354
1345
|
* Concatenates another chunk to the beginning of the `TxChunk`.
|
|
1355
1346
|
*
|
|
@@ -1376,10 +1367,10 @@ export const prependAll: {
|
|
|
1376
1367
|
* @since 4.0.0
|
|
1377
1368
|
* @category combinators
|
|
1378
1369
|
*/
|
|
1379
|
-
<A>(self: TxChunk<A>, other: Chunk.Chunk<A>): Effect.Effect<void
|
|
1370
|
+
<A>(self: TxChunk<A>, other: Chunk.Chunk<A>): Effect.Effect<void>
|
|
1380
1371
|
} = dual(
|
|
1381
1372
|
2,
|
|
1382
|
-
<A>(self: TxChunk<A>, other: Chunk.Chunk<A>): Effect.Effect<void
|
|
1373
|
+
<A>(self: TxChunk<A>, other: Chunk.Chunk<A>): Effect.Effect<void> =>
|
|
1383
1374
|
update(self, (current) => Chunk.prependAll(current, other))
|
|
1384
1375
|
)
|
|
1385
1376
|
|
|
@@ -1440,7 +1431,7 @@ export const concat: {
|
|
|
1440
1431
|
* })
|
|
1441
1432
|
* ```
|
|
1442
1433
|
*/
|
|
1443
|
-
<A>(other: TxChunk<A>): (self: TxChunk<A>) => Effect.Effect<void
|
|
1434
|
+
<A>(other: TxChunk<A>): (self: TxChunk<A>) => Effect.Effect<void>
|
|
1444
1435
|
/**
|
|
1445
1436
|
* Concatenates another `TxChunk` to the end of this `TxChunk`.
|
|
1446
1437
|
*
|
|
@@ -1469,12 +1460,12 @@ export const concat: {
|
|
|
1469
1460
|
* })
|
|
1470
1461
|
* ```
|
|
1471
1462
|
*/
|
|
1472
|
-
<A>(self: TxChunk<A>, other: TxChunk<A>): Effect.Effect<void
|
|
1463
|
+
<A>(self: TxChunk<A>, other: TxChunk<A>): Effect.Effect<void>
|
|
1473
1464
|
} = dual(
|
|
1474
1465
|
2,
|
|
1475
|
-
<A>(self: TxChunk<A>, other: TxChunk<A>): Effect.Effect<void
|
|
1466
|
+
<A>(self: TxChunk<A>, other: TxChunk<A>): Effect.Effect<void> =>
|
|
1476
1467
|
Effect.gen(function*() {
|
|
1477
1468
|
const otherChunk = yield* get(other)
|
|
1478
1469
|
yield* appendAll(self, otherChunk)
|
|
1479
|
-
})
|
|
1470
|
+
}).pipe(Effect.tx)
|
|
1480
1471
|
)
|