effect 4.0.0-beta.17 → 4.0.0-beta.19

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 (164) hide show
  1. package/dist/Array.d.ts +127 -299
  2. package/dist/Array.d.ts.map +1 -1
  3. package/dist/Array.js +102 -62
  4. package/dist/Array.js.map +1 -1
  5. package/dist/Cache.d.ts.map +1 -1
  6. package/dist/Cache.js +5 -4
  7. package/dist/Cache.js.map +1 -1
  8. package/dist/Channel.d.ts +97 -11
  9. package/dist/Channel.d.ts.map +1 -1
  10. package/dist/Channel.js +72 -29
  11. package/dist/Channel.js.map +1 -1
  12. package/dist/Chunk.d.ts +54 -247
  13. package/dist/Chunk.d.ts.map +1 -1
  14. package/dist/Chunk.js +36 -67
  15. package/dist/Chunk.js.map +1 -1
  16. package/dist/Effect.d.ts +337 -437
  17. package/dist/Effect.d.ts.map +1 -1
  18. package/dist/Effect.js +118 -134
  19. package/dist/Effect.js.map +1 -1
  20. package/dist/Filter.d.ts +0 -33
  21. package/dist/Filter.d.ts.map +1 -1
  22. package/dist/Filter.js +0 -13
  23. package/dist/Filter.js.map +1 -1
  24. package/dist/HashMap.d.ts +15 -14
  25. package/dist/HashMap.d.ts.map +1 -1
  26. package/dist/HashMap.js +4 -4
  27. package/dist/HashMap.js.map +1 -1
  28. package/dist/Iterable.d.ts +40 -39
  29. package/dist/Iterable.d.ts.map +1 -1
  30. package/dist/Iterable.js +94 -22
  31. package/dist/Iterable.js.map +1 -1
  32. package/dist/Option.d.ts +22 -15
  33. package/dist/Option.d.ts.map +1 -1
  34. package/dist/Option.js +14 -7
  35. package/dist/Option.js.map +1 -1
  36. package/dist/Pull.d.ts.map +1 -1
  37. package/dist/Pull.js +1 -1
  38. package/dist/Pull.js.map +1 -1
  39. package/dist/Record.d.ts +24 -120
  40. package/dist/Record.d.ts.map +1 -1
  41. package/dist/Record.js +21 -41
  42. package/dist/Record.js.map +1 -1
  43. package/dist/Sink.d.ts +11 -11
  44. package/dist/Sink.d.ts.map +1 -1
  45. package/dist/Sink.js +53 -6
  46. package/dist/Sink.js.map +1 -1
  47. package/dist/Stream.d.ts +198 -386
  48. package/dist/Stream.d.ts.map +1 -1
  49. package/dist/Stream.js +103 -59
  50. package/dist/Stream.js.map +1 -1
  51. package/dist/Trie.d.ts +18 -17
  52. package/dist/Trie.d.ts.map +1 -1
  53. package/dist/Trie.js +5 -5
  54. package/dist/Trie.js.map +1 -1
  55. package/dist/TxChunk.d.ts +37 -37
  56. package/dist/TxChunk.d.ts.map +1 -1
  57. package/dist/TxChunk.js +3 -3
  58. package/dist/TxChunk.js.map +1 -1
  59. package/dist/TxDeferred.d.ts +328 -0
  60. package/dist/TxDeferred.d.ts.map +1 -0
  61. package/dist/TxDeferred.js +196 -0
  62. package/dist/TxDeferred.js.map +1 -0
  63. package/dist/TxHashMap.d.ts +84 -83
  64. package/dist/TxHashMap.d.ts.map +1 -1
  65. package/dist/TxHashMap.js +24 -24
  66. package/dist/TxHashMap.js.map +1 -1
  67. package/dist/TxHashSet.d.ts +35 -35
  68. package/dist/TxHashSet.d.ts.map +1 -1
  69. package/dist/TxHashSet.js +14 -14
  70. package/dist/TxHashSet.js.map +1 -1
  71. package/dist/TxPriorityQueue.d.ts +609 -0
  72. package/dist/TxPriorityQueue.d.ts.map +1 -0
  73. package/dist/TxPriorityQueue.js +415 -0
  74. package/dist/TxPriorityQueue.js.map +1 -0
  75. package/dist/TxPubSub.d.ts +585 -0
  76. package/dist/TxPubSub.d.ts.map +1 -0
  77. package/dist/TxPubSub.js +521 -0
  78. package/dist/TxPubSub.js.map +1 -0
  79. package/dist/TxQueue.d.ts +32 -32
  80. package/dist/TxQueue.d.ts.map +1 -1
  81. package/dist/TxQueue.js +26 -26
  82. package/dist/TxQueue.js.map +1 -1
  83. package/dist/TxReentrantLock.d.ts +523 -0
  84. package/dist/TxReentrantLock.d.ts.map +1 -0
  85. package/dist/TxReentrantLock.js +504 -0
  86. package/dist/TxReentrantLock.js.map +1 -0
  87. package/dist/TxRef.d.ts +34 -34
  88. package/dist/TxRef.d.ts.map +1 -1
  89. package/dist/TxRef.js +21 -14
  90. package/dist/TxRef.js.map +1 -1
  91. package/dist/TxSemaphore.d.ts +8 -8
  92. package/dist/TxSemaphore.d.ts.map +1 -1
  93. package/dist/TxSemaphore.js +7 -7
  94. package/dist/TxSemaphore.js.map +1 -1
  95. package/dist/TxSubscriptionRef.d.ts +508 -0
  96. package/dist/TxSubscriptionRef.d.ts.map +1 -0
  97. package/dist/TxSubscriptionRef.js +293 -0
  98. package/dist/TxSubscriptionRef.js.map +1 -0
  99. package/dist/index.d.ts +40 -0
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +40 -0
  102. package/dist/index.js.map +1 -1
  103. package/dist/internal/effect.js +99 -42
  104. package/dist/internal/effect.js.map +1 -1
  105. package/dist/internal/hashMap.js +3 -2
  106. package/dist/internal/hashMap.js.map +1 -1
  107. package/dist/internal/trie.js +5 -4
  108. package/dist/internal/trie.js.map +1 -1
  109. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  110. package/dist/unstable/ai/Tool.js +0 -9
  111. package/dist/unstable/ai/Tool.js.map +1 -1
  112. package/dist/unstable/cli/Command.d.ts +1 -1
  113. package/dist/unstable/cli/Command.d.ts.map +1 -1
  114. package/dist/unstable/cli/Command.js +1 -1
  115. package/dist/unstable/cli/Command.js.map +1 -1
  116. package/dist/unstable/cluster/K8sHttpClient.js +4 -4
  117. package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
  118. package/dist/unstable/cluster/Sharding.js +1 -1
  119. package/dist/unstable/cluster/Sharding.js.map +1 -1
  120. package/dist/unstable/encoding/Sse.js +1 -1
  121. package/dist/unstable/encoding/Sse.js.map +1 -1
  122. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  123. package/dist/unstable/rpc/RpcServer.js +1 -2
  124. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  125. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  126. package/dist/unstable/socket/Socket.js +3 -3
  127. package/dist/unstable/socket/Socket.js.map +1 -1
  128. package/package.json +1 -1
  129. package/src/Array.ts +190 -342
  130. package/src/Cache.ts +6 -5
  131. package/src/Channel.ts +506 -102
  132. package/src/Chunk.ts +81 -268
  133. package/src/Effect.ts +437 -518
  134. package/src/Filter.ts +0 -57
  135. package/src/HashMap.ts +15 -14
  136. package/src/Iterable.ts +105 -50
  137. package/src/Option.ts +30 -20
  138. package/src/Pull.ts +1 -1
  139. package/src/Record.ts +43 -152
  140. package/src/Sink.ts +75 -23
  141. package/src/Stream.ts +442 -502
  142. package/src/Trie.ts +18 -17
  143. package/src/TxChunk.ts +72 -53
  144. package/src/TxDeferred.ts +394 -0
  145. package/src/TxHashMap.ts +332 -285
  146. package/src/TxHashSet.ts +111 -116
  147. package/src/TxPriorityQueue.ts +767 -0
  148. package/src/TxPubSub.ts +789 -0
  149. package/src/TxQueue.ts +241 -251
  150. package/src/TxReentrantLock.ts +753 -0
  151. package/src/TxRef.ts +50 -38
  152. package/src/TxSemaphore.ts +29 -32
  153. package/src/TxSubscriptionRef.ts +639 -0
  154. package/src/index.ts +45 -0
  155. package/src/internal/effect.ts +368 -163
  156. package/src/internal/hashMap.ts +7 -5
  157. package/src/internal/trie.ts +16 -9
  158. package/src/unstable/ai/Tool.ts +0 -9
  159. package/src/unstable/cli/Command.ts +6 -4
  160. package/src/unstable/cluster/K8sHttpClient.ts +4 -4
  161. package/src/unstable/cluster/Sharding.ts +1 -1
  162. package/src/unstable/encoding/Sse.ts +1 -1
  163. package/src/unstable/rpc/RpcServer.ts +1 -7
  164. package/src/unstable/socket/Socket.ts +9 -11
@@ -0,0 +1,609 @@
1
+ /**
2
+ * A transactional priority queue. Elements are dequeued in order determined by the
3
+ * provided `Order` instance. All operations participate in the STM transaction system.
4
+ *
5
+ * @since 4.0.0
6
+ */
7
+ import type { Chunk } from "./Chunk.ts";
8
+ import * as Effect from "./Effect.ts";
9
+ import type { Inspectable } from "./Inspectable.ts";
10
+ import type { Option } from "./Option.ts";
11
+ import type { Order } from "./Order.ts";
12
+ import type { Pipeable } from "./Pipeable.ts";
13
+ import type { Predicate } from "./Predicate.ts";
14
+ import * as TxRef from "./TxRef.ts";
15
+ declare const TypeId = "~effect/transactions/TxPriorityQueue";
16
+ /**
17
+ * A transactional priority queue backed by a sorted `Chunk`.
18
+ *
19
+ * Elements are stored in ascending order according to the `Order` provided at
20
+ * construction time. `take` returns the smallest element, `peek` observes it
21
+ * without removing.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * import { Effect, Order, TxPriorityQueue } from "effect"
26
+ *
27
+ * const program = Effect.gen(function*() {
28
+ * const pq = yield* TxPriorityQueue.empty<number>(Order.Number)
29
+ * yield* TxPriorityQueue.offer(pq, 3)
30
+ * yield* TxPriorityQueue.offer(pq, 1)
31
+ * yield* TxPriorityQueue.offer(pq, 2)
32
+ * const first = yield* TxPriorityQueue.take(pq)
33
+ * console.log(first) // 1
34
+ * })
35
+ * ```
36
+ *
37
+ * @since 4.0.0
38
+ * @category models
39
+ */
40
+ export interface TxPriorityQueue<in out A> extends Inspectable, Pipeable {
41
+ readonly [TypeId]: typeof TypeId;
42
+ readonly ref: TxRef.TxRef<Chunk<A>>;
43
+ readonly ord: Order<A>;
44
+ }
45
+ /**
46
+ * Creates an empty `TxPriorityQueue` with the given ordering.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * import { Effect, Order, TxPriorityQueue } from "effect"
51
+ *
52
+ * const program = Effect.gen(function*() {
53
+ * const pq = yield* TxPriorityQueue.empty<number>(Order.Number)
54
+ * const empty = yield* TxPriorityQueue.isEmpty(pq)
55
+ * console.log(empty) // true
56
+ * })
57
+ * ```
58
+ *
59
+ * @since 4.0.0
60
+ * @category constructors
61
+ */
62
+ export declare const empty: <A>(order: Order<A>) => Effect.Effect<TxPriorityQueue<A>, never, Effect.Transaction>;
63
+ /**
64
+ * Creates a `TxPriorityQueue` from an iterable of elements.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * import { Effect, Order, TxPriorityQueue } from "effect"
69
+ *
70
+ * const program = Effect.gen(function*() {
71
+ * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [3, 1, 2])
72
+ * const first = yield* TxPriorityQueue.take(pq)
73
+ * console.log(first) // 1
74
+ * })
75
+ * ```
76
+ *
77
+ * @since 4.0.0
78
+ * @category constructors
79
+ */
80
+ export declare const fromIterable: {
81
+ /**
82
+ * Creates a `TxPriorityQueue` from an iterable of elements.
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * import { Effect, Order, TxPriorityQueue } from "effect"
87
+ *
88
+ * const program = Effect.gen(function*() {
89
+ * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [3, 1, 2])
90
+ * const first = yield* TxPriorityQueue.take(pq)
91
+ * console.log(first) // 1
92
+ * })
93
+ * ```
94
+ *
95
+ * @since 4.0.0
96
+ * @category constructors
97
+ */
98
+ <A>(order: Order<A>): (iterable: Iterable<A>) => Effect.Effect<TxPriorityQueue<A>, never, Effect.Transaction>;
99
+ /**
100
+ * Creates a `TxPriorityQueue` from an iterable of elements.
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * import { Effect, Order, TxPriorityQueue } from "effect"
105
+ *
106
+ * const program = Effect.gen(function*() {
107
+ * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [3, 1, 2])
108
+ * const first = yield* TxPriorityQueue.take(pq)
109
+ * console.log(first) // 1
110
+ * })
111
+ * ```
112
+ *
113
+ * @since 4.0.0
114
+ * @category constructors
115
+ */
116
+ <A>(order: Order<A>, iterable: Iterable<A>): Effect.Effect<TxPriorityQueue<A>, never, Effect.Transaction>;
117
+ };
118
+ /**
119
+ * Creates a `TxPriorityQueue` from variadic elements.
120
+ *
121
+ * @example
122
+ * ```ts
123
+ * import { Effect, Order, TxPriorityQueue } from "effect"
124
+ *
125
+ * const program = Effect.gen(function*() {
126
+ * const pq = yield* TxPriorityQueue.make(Order.Number)(3, 1, 2)
127
+ * const first = yield* TxPriorityQueue.take(pq)
128
+ * console.log(first) // 1
129
+ * })
130
+ * ```
131
+ *
132
+ * @since 4.0.0
133
+ * @category constructors
134
+ */
135
+ export declare const make: <A>(order: Order<A>) => (...elements: Array<A>) => Effect.Effect<TxPriorityQueue<A>, never, Effect.Transaction>;
136
+ /**
137
+ * Returns the number of elements in the queue.
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * import { Effect, Order, TxPriorityQueue } from "effect"
142
+ *
143
+ * const program = Effect.gen(function*() {
144
+ * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [1, 2, 3])
145
+ * const s = yield* TxPriorityQueue.size(pq)
146
+ * console.log(s) // 3
147
+ * })
148
+ * ```
149
+ *
150
+ * @since 4.0.0
151
+ * @category getters
152
+ */
153
+ export declare const size: <A>(self: TxPriorityQueue<A>) => Effect.Effect<number, never, Effect.Transaction>;
154
+ /**
155
+ * Returns `true` if the queue is empty.
156
+ *
157
+ * @example
158
+ * ```ts
159
+ * import { Effect, Order, TxPriorityQueue } from "effect"
160
+ *
161
+ * const program = Effect.gen(function*() {
162
+ * const pq = yield* TxPriorityQueue.empty<number>(Order.Number)
163
+ * const empty = yield* TxPriorityQueue.isEmpty(pq)
164
+ * console.log(empty) // true
165
+ * })
166
+ * ```
167
+ *
168
+ * @since 4.0.0
169
+ * @category getters
170
+ */
171
+ export declare const isEmpty: <A>(self: TxPriorityQueue<A>) => Effect.Effect<boolean, never, Effect.Transaction>;
172
+ /**
173
+ * Returns `true` if the queue has at least one element.
174
+ *
175
+ * @example
176
+ * ```ts
177
+ * import { Effect, Order, TxPriorityQueue } from "effect"
178
+ *
179
+ * const program = Effect.gen(function*() {
180
+ * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [1])
181
+ * const nonEmpty = yield* TxPriorityQueue.isNonEmpty(pq)
182
+ * console.log(nonEmpty) // true
183
+ * })
184
+ * ```
185
+ *
186
+ * @since 4.0.0
187
+ * @category getters
188
+ */
189
+ export declare const isNonEmpty: <A>(self: TxPriorityQueue<A>) => Effect.Effect<boolean, never, Effect.Transaction>;
190
+ /**
191
+ * Observes the smallest element without removing it. Retries if the queue is
192
+ * empty.
193
+ *
194
+ * @example
195
+ * ```ts
196
+ * import { Effect, Order, TxPriorityQueue } from "effect"
197
+ *
198
+ * const program = Effect.gen(function*() {
199
+ * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [3, 1, 2])
200
+ * const top = yield* TxPriorityQueue.peek(pq)
201
+ * console.log(top) // 1
202
+ * })
203
+ * ```
204
+ *
205
+ * @since 4.0.0
206
+ * @category getters
207
+ */
208
+ export declare const peek: <A>(self: TxPriorityQueue<A>) => Effect.Effect<A, never, Effect.Transaction>;
209
+ /**
210
+ * Observes the smallest element without removing it. Returns `None` if the
211
+ * queue is empty.
212
+ *
213
+ * @example
214
+ * ```ts
215
+ * import { Effect, Option, Order, TxPriorityQueue } from "effect"
216
+ *
217
+ * const program = Effect.gen(function*() {
218
+ * const pq = yield* TxPriorityQueue.empty<number>(Order.Number)
219
+ * const result = yield* TxPriorityQueue.peekOption(pq)
220
+ * console.log(Option.isNone(result)) // true
221
+ * })
222
+ * ```
223
+ *
224
+ * @since 4.0.0
225
+ * @category getters
226
+ */
227
+ export declare const peekOption: <A>(self: TxPriorityQueue<A>) => Effect.Effect<Option<A>, never, Effect.Transaction>;
228
+ /**
229
+ * Inserts an element into the queue in sorted position.
230
+ *
231
+ * @example
232
+ * ```ts
233
+ * import { Effect, Order, TxPriorityQueue } from "effect"
234
+ *
235
+ * const program = Effect.gen(function*() {
236
+ * const pq = yield* TxPriorityQueue.empty<number>(Order.Number)
237
+ * yield* TxPriorityQueue.offer(pq, 2)
238
+ * yield* TxPriorityQueue.offer(pq, 1)
239
+ * const first = yield* TxPriorityQueue.take(pq)
240
+ * console.log(first) // 1
241
+ * })
242
+ * ```
243
+ *
244
+ * @since 4.0.0
245
+ * @category mutations
246
+ */
247
+ export declare const offer: {
248
+ /**
249
+ * Inserts an element into the queue in sorted position.
250
+ *
251
+ * @example
252
+ * ```ts
253
+ * import { Effect, Order, TxPriorityQueue } from "effect"
254
+ *
255
+ * const program = Effect.gen(function*() {
256
+ * const pq = yield* TxPriorityQueue.empty<number>(Order.Number)
257
+ * yield* TxPriorityQueue.offer(pq, 2)
258
+ * yield* TxPriorityQueue.offer(pq, 1)
259
+ * const first = yield* TxPriorityQueue.take(pq)
260
+ * console.log(first) // 1
261
+ * })
262
+ * ```
263
+ *
264
+ * @since 4.0.0
265
+ * @category mutations
266
+ */
267
+ <A>(value: A): (self: TxPriorityQueue<A>) => Effect.Effect<void, never, Effect.Transaction>;
268
+ /**
269
+ * Inserts an element into the queue in sorted position.
270
+ *
271
+ * @example
272
+ * ```ts
273
+ * import { Effect, Order, TxPriorityQueue } from "effect"
274
+ *
275
+ * const program = Effect.gen(function*() {
276
+ * const pq = yield* TxPriorityQueue.empty<number>(Order.Number)
277
+ * yield* TxPriorityQueue.offer(pq, 2)
278
+ * yield* TxPriorityQueue.offer(pq, 1)
279
+ * const first = yield* TxPriorityQueue.take(pq)
280
+ * console.log(first) // 1
281
+ * })
282
+ * ```
283
+ *
284
+ * @since 4.0.0
285
+ * @category mutations
286
+ */
287
+ <A>(self: TxPriorityQueue<A>, value: A): Effect.Effect<void, never, Effect.Transaction>;
288
+ };
289
+ /**
290
+ * Inserts all elements from an iterable into the queue.
291
+ *
292
+ * @example
293
+ * ```ts
294
+ * import { Effect, Order, TxPriorityQueue } from "effect"
295
+ *
296
+ * const program = Effect.gen(function*() {
297
+ * const pq = yield* TxPriorityQueue.empty<number>(Order.Number)
298
+ * yield* TxPriorityQueue.offerAll(pq, [3, 1, 2])
299
+ * const first = yield* TxPriorityQueue.take(pq)
300
+ * console.log(first) // 1
301
+ * })
302
+ * ```
303
+ *
304
+ * @since 4.0.0
305
+ * @category mutations
306
+ */
307
+ export declare const offerAll: {
308
+ /**
309
+ * Inserts all elements from an iterable into the queue.
310
+ *
311
+ * @example
312
+ * ```ts
313
+ * import { Effect, Order, TxPriorityQueue } from "effect"
314
+ *
315
+ * const program = Effect.gen(function*() {
316
+ * const pq = yield* TxPriorityQueue.empty<number>(Order.Number)
317
+ * yield* TxPriorityQueue.offerAll(pq, [3, 1, 2])
318
+ * const first = yield* TxPriorityQueue.take(pq)
319
+ * console.log(first) // 1
320
+ * })
321
+ * ```
322
+ *
323
+ * @since 4.0.0
324
+ * @category mutations
325
+ */
326
+ <A>(values: Iterable<A>): (self: TxPriorityQueue<A>) => Effect.Effect<void, never, Effect.Transaction>;
327
+ /**
328
+ * Inserts all elements from an iterable into the queue.
329
+ *
330
+ * @example
331
+ * ```ts
332
+ * import { Effect, Order, TxPriorityQueue } from "effect"
333
+ *
334
+ * const program = Effect.gen(function*() {
335
+ * const pq = yield* TxPriorityQueue.empty<number>(Order.Number)
336
+ * yield* TxPriorityQueue.offerAll(pq, [3, 1, 2])
337
+ * const first = yield* TxPriorityQueue.take(pq)
338
+ * console.log(first) // 1
339
+ * })
340
+ * ```
341
+ *
342
+ * @since 4.0.0
343
+ * @category mutations
344
+ */
345
+ <A>(self: TxPriorityQueue<A>, values: Iterable<A>): Effect.Effect<void, never, Effect.Transaction>;
346
+ };
347
+ /**
348
+ * Takes the smallest element from the queue. Retries if the queue is empty.
349
+ *
350
+ * @example
351
+ * ```ts
352
+ * import { Effect, Order, TxPriorityQueue } from "effect"
353
+ *
354
+ * const program = Effect.gen(function*() {
355
+ * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [3, 1, 2])
356
+ * const first = yield* TxPriorityQueue.take(pq)
357
+ * console.log(first) // 1
358
+ * })
359
+ * ```
360
+ *
361
+ * @since 4.0.0
362
+ * @category mutations
363
+ */
364
+ export declare const take: <A>(self: TxPriorityQueue<A>) => Effect.Effect<A, never, Effect.Transaction>;
365
+ /**
366
+ * Takes all elements from the queue, returning them in priority order.
367
+ *
368
+ * @example
369
+ * ```ts
370
+ * import { Effect, Order, TxPriorityQueue } from "effect"
371
+ *
372
+ * const program = Effect.gen(function*() {
373
+ * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [3, 1, 2])
374
+ * const all = yield* TxPriorityQueue.takeAll(pq)
375
+ * console.log(all) // [1, 2, 3]
376
+ * })
377
+ * ```
378
+ *
379
+ * @since 4.0.0
380
+ * @category mutations
381
+ */
382
+ export declare const takeAll: <A>(self: TxPriorityQueue<A>) => Effect.Effect<Array<A>, never, Effect.Transaction>;
383
+ /**
384
+ * Tries to take the smallest element. Returns `None` if the queue is empty.
385
+ *
386
+ * @example
387
+ * ```ts
388
+ * import { Effect, Option, Order, TxPriorityQueue } from "effect"
389
+ *
390
+ * const program = Effect.gen(function*() {
391
+ * const pq = yield* TxPriorityQueue.empty<number>(Order.Number)
392
+ * const result = yield* TxPriorityQueue.takeOption(pq)
393
+ * console.log(Option.isNone(result)) // true
394
+ * })
395
+ * ```
396
+ *
397
+ * @since 4.0.0
398
+ * @category mutations
399
+ */
400
+ export declare const takeOption: <A>(self: TxPriorityQueue<A>) => Effect.Effect<Option<A>, never, Effect.Transaction>;
401
+ /**
402
+ * Takes up to `n` elements from the queue in priority order.
403
+ *
404
+ * @example
405
+ * ```ts
406
+ * import { Effect, Order, TxPriorityQueue } from "effect"
407
+ *
408
+ * const program = Effect.gen(function*() {
409
+ * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [5, 3, 1, 4, 2])
410
+ * const top2 = yield* TxPriorityQueue.takeUpTo(pq, 2)
411
+ * console.log(top2) // [1, 2]
412
+ * })
413
+ * ```
414
+ *
415
+ * @since 4.0.0
416
+ * @category mutations
417
+ */
418
+ export declare const takeUpTo: {
419
+ /**
420
+ * Takes up to `n` elements from the queue in priority order.
421
+ *
422
+ * @example
423
+ * ```ts
424
+ * import { Effect, Order, TxPriorityQueue } from "effect"
425
+ *
426
+ * const program = Effect.gen(function*() {
427
+ * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [5, 3, 1, 4, 2])
428
+ * const top2 = yield* TxPriorityQueue.takeUpTo(pq, 2)
429
+ * console.log(top2) // [1, 2]
430
+ * })
431
+ * ```
432
+ *
433
+ * @since 4.0.0
434
+ * @category mutations
435
+ */
436
+ (n: number): <A>(self: TxPriorityQueue<A>) => Effect.Effect<Array<A>, never, Effect.Transaction>;
437
+ /**
438
+ * Takes up to `n` elements from the queue in priority order.
439
+ *
440
+ * @example
441
+ * ```ts
442
+ * import { Effect, Order, TxPriorityQueue } from "effect"
443
+ *
444
+ * const program = Effect.gen(function*() {
445
+ * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [5, 3, 1, 4, 2])
446
+ * const top2 = yield* TxPriorityQueue.takeUpTo(pq, 2)
447
+ * console.log(top2) // [1, 2]
448
+ * })
449
+ * ```
450
+ *
451
+ * @since 4.0.0
452
+ * @category mutations
453
+ */
454
+ <A>(self: TxPriorityQueue<A>, n: number): Effect.Effect<Array<A>, never, Effect.Transaction>;
455
+ };
456
+ /**
457
+ * Removes elements matching the predicate.
458
+ *
459
+ * @example
460
+ * ```ts
461
+ * import { Effect, Order, TxPriorityQueue } from "effect"
462
+ *
463
+ * const program = Effect.gen(function*() {
464
+ * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [1, 2, 3, 4, 5])
465
+ * yield* TxPriorityQueue.removeIf(pq, (n) => n % 2 === 0)
466
+ * const all = yield* TxPriorityQueue.takeAll(pq)
467
+ * console.log(all) // [1, 3, 5]
468
+ * })
469
+ * ```
470
+ *
471
+ * @since 4.0.0
472
+ * @category filtering
473
+ */
474
+ export declare const removeIf: {
475
+ /**
476
+ * Removes elements matching the predicate.
477
+ *
478
+ * @example
479
+ * ```ts
480
+ * import { Effect, Order, TxPriorityQueue } from "effect"
481
+ *
482
+ * const program = Effect.gen(function*() {
483
+ * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [1, 2, 3, 4, 5])
484
+ * yield* TxPriorityQueue.removeIf(pq, (n) => n % 2 === 0)
485
+ * const all = yield* TxPriorityQueue.takeAll(pq)
486
+ * console.log(all) // [1, 3, 5]
487
+ * })
488
+ * ```
489
+ *
490
+ * @since 4.0.0
491
+ * @category filtering
492
+ */
493
+ <A>(predicate: Predicate<A>): (self: TxPriorityQueue<A>) => Effect.Effect<void, never, Effect.Transaction>;
494
+ /**
495
+ * Removes elements matching the predicate.
496
+ *
497
+ * @example
498
+ * ```ts
499
+ * import { Effect, Order, TxPriorityQueue } from "effect"
500
+ *
501
+ * const program = Effect.gen(function*() {
502
+ * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [1, 2, 3, 4, 5])
503
+ * yield* TxPriorityQueue.removeIf(pq, (n) => n % 2 === 0)
504
+ * const all = yield* TxPriorityQueue.takeAll(pq)
505
+ * console.log(all) // [1, 3, 5]
506
+ * })
507
+ * ```
508
+ *
509
+ * @since 4.0.0
510
+ * @category filtering
511
+ */
512
+ <A>(self: TxPriorityQueue<A>, predicate: Predicate<A>): Effect.Effect<void, never, Effect.Transaction>;
513
+ };
514
+ /**
515
+ * Retains only elements matching the predicate.
516
+ *
517
+ * @example
518
+ * ```ts
519
+ * import { Effect, Order, TxPriorityQueue } from "effect"
520
+ *
521
+ * const program = Effect.gen(function*() {
522
+ * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [1, 2, 3, 4, 5])
523
+ * yield* TxPriorityQueue.retainIf(pq, (n) => n % 2 === 0)
524
+ * const all = yield* TxPriorityQueue.takeAll(pq)
525
+ * console.log(all) // [2, 4]
526
+ * })
527
+ * ```
528
+ *
529
+ * @since 4.0.0
530
+ * @category filtering
531
+ */
532
+ export declare const retainIf: {
533
+ /**
534
+ * Retains only elements matching the predicate.
535
+ *
536
+ * @example
537
+ * ```ts
538
+ * import { Effect, Order, TxPriorityQueue } from "effect"
539
+ *
540
+ * const program = Effect.gen(function*() {
541
+ * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [1, 2, 3, 4, 5])
542
+ * yield* TxPriorityQueue.retainIf(pq, (n) => n % 2 === 0)
543
+ * const all = yield* TxPriorityQueue.takeAll(pq)
544
+ * console.log(all) // [2, 4]
545
+ * })
546
+ * ```
547
+ *
548
+ * @since 4.0.0
549
+ * @category filtering
550
+ */
551
+ <A>(predicate: Predicate<A>): (self: TxPriorityQueue<A>) => Effect.Effect<void, never, Effect.Transaction>;
552
+ /**
553
+ * Retains only elements matching the predicate.
554
+ *
555
+ * @example
556
+ * ```ts
557
+ * import { Effect, Order, TxPriorityQueue } from "effect"
558
+ *
559
+ * const program = Effect.gen(function*() {
560
+ * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [1, 2, 3, 4, 5])
561
+ * yield* TxPriorityQueue.retainIf(pq, (n) => n % 2 === 0)
562
+ * const all = yield* TxPriorityQueue.takeAll(pq)
563
+ * console.log(all) // [2, 4]
564
+ * })
565
+ * ```
566
+ *
567
+ * @since 4.0.0
568
+ * @category filtering
569
+ */
570
+ <A>(self: TxPriorityQueue<A>, predicate: Predicate<A>): Effect.Effect<void, never, Effect.Transaction>;
571
+ };
572
+ /**
573
+ * Returns all elements in priority order without removing them.
574
+ *
575
+ * @example
576
+ * ```ts
577
+ * import { Effect, Order, TxPriorityQueue } from "effect"
578
+ *
579
+ * const program = Effect.gen(function*() {
580
+ * const pq = yield* TxPriorityQueue.fromIterable(Order.Number, [3, 1, 2])
581
+ * const all = yield* TxPriorityQueue.toArray(pq)
582
+ * console.log(all) // [1, 2, 3]
583
+ * })
584
+ * ```
585
+ *
586
+ * @since 4.0.0
587
+ * @category conversions
588
+ */
589
+ export declare const toArray: <A>(self: TxPriorityQueue<A>) => Effect.Effect<Array<A>, never, Effect.Transaction>;
590
+ /**
591
+ * Determines if the provided value is a `TxPriorityQueue`.
592
+ *
593
+ * @example
594
+ * ```ts
595
+ * import { Effect, Order, TxPriorityQueue } from "effect"
596
+ *
597
+ * const program = Effect.gen(function*() {
598
+ * const pq = yield* TxPriorityQueue.empty<number>(Order.Number)
599
+ * console.log(TxPriorityQueue.isTxPriorityQueue(pq)) // true
600
+ * console.log(TxPriorityQueue.isTxPriorityQueue("nope")) // false
601
+ * })
602
+ * ```
603
+ *
604
+ * @since 4.0.0
605
+ * @category guards
606
+ */
607
+ export declare const isTxPriorityQueue: (u: unknown) => u is TxPriorityQueue<unknown>;
608
+ export {};
609
+ //# sourceMappingURL=TxPriorityQueue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TxPriorityQueue.d.ts","sourceRoot":"","sources":["../src/TxPriorityQueue.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAEvC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AAEnC,QAAA,MAAM,MAAM,yCAAyC,CAAA;AAErD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,WAAW,eAAe,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAE,SAAQ,WAAW,EAAE,QAAQ;IACtE,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,MAAM,CAAA;IAChC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IACnC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,CAAA;CACvB;AA2CD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,KAAK,GAAI,CAAC,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC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