effect 3.11.0 → 3.11.2

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/src/Stream.ts CHANGED
@@ -6161,16 +6161,26 @@ export const paginateEffect: <S, A, E, R>(
6161
6161
  ) => Stream<A, E, R> = internal.paginateEffect
6162
6162
 
6163
6163
  /**
6164
- * Partition a stream using a predicate. The first stream will contain all
6165
- * element evaluated to false and the second one will contain all element
6166
- * evaluated to true. The faster stream may advance by up to buffer elements
6167
- * further than the slower one.
6164
+ * Splits a stream into two substreams based on a predicate.
6165
+ *
6166
+ * **Details**
6167
+ *
6168
+ * The `Stream.partition` function splits a stream into two parts: one for
6169
+ * elements that satisfy the predicate (evaluated to `true`) and another for
6170
+ * those that do not (evaluated to `false`).
6171
+ *
6172
+ * The faster stream may advance up to `bufferSize` elements ahead of the slower
6173
+ * one.
6174
+ *
6175
+ * @see {@link partitionEither} for partitioning a stream based on effectful
6176
+ * conditions.
6168
6177
  *
6169
6178
  * @example
6170
6179
  * ```ts
6180
+ * // Title: Partitioning a Stream into Even and Odd Numbers
6171
6181
  * import { Effect, Stream } from "effect"
6172
6182
  *
6173
- * const partition = Stream.range(1, 10).pipe(
6183
+ * const partition = Stream.range(1, 9).pipe(
6174
6184
  * Stream.partition((n) => n % 2 === 0, { bufferSize: 5 })
6175
6185
  * )
6176
6186
  *
@@ -6184,7 +6194,7 @@ export const paginateEffect: <S, A, E, R>(
6184
6194
  *
6185
6195
  * // Effect.runPromise(program)
6186
6196
  * // { _id: 'Chunk', values: [ 1, 3, 5, 7, 9 ] }
6187
- * // { _id: 'Chunk', values: [ 2, 4, 6, 8, 10 ] }
6197
+ * // { _id: 'Chunk', values: [ 2, 4, 6, 8 ] }
6188
6198
  * ```
6189
6199
  *
6190
6200
  * @since 2.0.0
@@ -6192,16 +6202,26 @@ export const paginateEffect: <S, A, E, R>(
6192
6202
  */
6193
6203
  export const partition: {
6194
6204
  /**
6195
- * Partition a stream using a predicate. The first stream will contain all
6196
- * element evaluated to false and the second one will contain all element
6197
- * evaluated to true. The faster stream may advance by up to buffer elements
6198
- * further than the slower one.
6205
+ * Splits a stream into two substreams based on a predicate.
6206
+ *
6207
+ * **Details**
6208
+ *
6209
+ * The `Stream.partition` function splits a stream into two parts: one for
6210
+ * elements that satisfy the predicate (evaluated to `true`) and another for
6211
+ * those that do not (evaluated to `false`).
6212
+ *
6213
+ * The faster stream may advance up to `bufferSize` elements ahead of the slower
6214
+ * one.
6215
+ *
6216
+ * @see {@link partitionEither} for partitioning a stream based on effectful
6217
+ * conditions.
6199
6218
  *
6200
6219
  * @example
6201
6220
  * ```ts
6221
+ * // Title: Partitioning a Stream into Even and Odd Numbers
6202
6222
  * import { Effect, Stream } from "effect"
6203
6223
  *
6204
- * const partition = Stream.range(1, 10).pipe(
6224
+ * const partition = Stream.range(1, 9).pipe(
6205
6225
  * Stream.partition((n) => n % 2 === 0, { bufferSize: 5 })
6206
6226
  * )
6207
6227
  *
@@ -6215,7 +6235,7 @@ export const partition: {
6215
6235
  *
6216
6236
  * // Effect.runPromise(program)
6217
6237
  * // { _id: 'Chunk', values: [ 1, 3, 5, 7, 9 ] }
6218
- * // { _id: 'Chunk', values: [ 2, 4, 6, 8, 10 ] }
6238
+ * // { _id: 'Chunk', values: [ 2, 4, 6, 8 ] }
6219
6239
  * ```
6220
6240
  *
6221
6241
  * @since 2.0.0
@@ -6228,16 +6248,26 @@ export const partition: {
6228
6248
  self: Stream<C, E, R>
6229
6249
  ) => Effect.Effect<[excluded: Stream<Exclude<C, B>, E, never>, satisfying: Stream<B, E, never>], E, R | Scope.Scope>
6230
6250
  /**
6231
- * Partition a stream using a predicate. The first stream will contain all
6232
- * element evaluated to false and the second one will contain all element
6233
- * evaluated to true. The faster stream may advance by up to buffer elements
6234
- * further than the slower one.
6251
+ * Splits a stream into two substreams based on a predicate.
6252
+ *
6253
+ * **Details**
6254
+ *
6255
+ * The `Stream.partition` function splits a stream into two parts: one for
6256
+ * elements that satisfy the predicate (evaluated to `true`) and another for
6257
+ * those that do not (evaluated to `false`).
6258
+ *
6259
+ * The faster stream may advance up to `bufferSize` elements ahead of the slower
6260
+ * one.
6261
+ *
6262
+ * @see {@link partitionEither} for partitioning a stream based on effectful
6263
+ * conditions.
6235
6264
  *
6236
6265
  * @example
6237
6266
  * ```ts
6267
+ * // Title: Partitioning a Stream into Even and Odd Numbers
6238
6268
  * import { Effect, Stream } from "effect"
6239
6269
  *
6240
- * const partition = Stream.range(1, 10).pipe(
6270
+ * const partition = Stream.range(1, 9).pipe(
6241
6271
  * Stream.partition((n) => n % 2 === 0, { bufferSize: 5 })
6242
6272
  * )
6243
6273
  *
@@ -6251,7 +6281,7 @@ export const partition: {
6251
6281
  *
6252
6282
  * // Effect.runPromise(program)
6253
6283
  * // { _id: 'Chunk', values: [ 1, 3, 5, 7, 9 ] }
6254
- * // { _id: 'Chunk', values: [ 2, 4, 6, 8, 10 ] }
6284
+ * // { _id: 'Chunk', values: [ 2, 4, 6, 8 ] }
6255
6285
  * ```
6256
6286
  *
6257
6287
  * @since 2.0.0
@@ -6264,16 +6294,26 @@ export const partition: {
6264
6294
  self: Stream<A, E, R>
6265
6295
  ) => Effect.Effect<[excluded: Stream<A, E, never>, satisfying: Stream<A, E, never>], E, Scope.Scope | R>
6266
6296
  /**
6267
- * Partition a stream using a predicate. The first stream will contain all
6268
- * element evaluated to false and the second one will contain all element
6269
- * evaluated to true. The faster stream may advance by up to buffer elements
6270
- * further than the slower one.
6297
+ * Splits a stream into two substreams based on a predicate.
6298
+ *
6299
+ * **Details**
6300
+ *
6301
+ * The `Stream.partition` function splits a stream into two parts: one for
6302
+ * elements that satisfy the predicate (evaluated to `true`) and another for
6303
+ * those that do not (evaluated to `false`).
6304
+ *
6305
+ * The faster stream may advance up to `bufferSize` elements ahead of the slower
6306
+ * one.
6307
+ *
6308
+ * @see {@link partitionEither} for partitioning a stream based on effectful
6309
+ * conditions.
6271
6310
  *
6272
6311
  * @example
6273
6312
  * ```ts
6313
+ * // Title: Partitioning a Stream into Even and Odd Numbers
6274
6314
  * import { Effect, Stream } from "effect"
6275
6315
  *
6276
- * const partition = Stream.range(1, 10).pipe(
6316
+ * const partition = Stream.range(1, 9).pipe(
6277
6317
  * Stream.partition((n) => n % 2 === 0, { bufferSize: 5 })
6278
6318
  * )
6279
6319
  *
@@ -6287,7 +6327,7 @@ export const partition: {
6287
6327
  *
6288
6328
  * // Effect.runPromise(program)
6289
6329
  * // { _id: 'Chunk', values: [ 1, 3, 5, 7, 9 ] }
6290
- * // { _id: 'Chunk', values: [ 2, 4, 6, 8, 10 ] }
6330
+ * // { _id: 'Chunk', values: [ 2, 4, 6, 8 ] }
6291
6331
  * ```
6292
6332
  *
6293
6333
  * @since 2.0.0
@@ -6299,16 +6339,26 @@ export const partition: {
6299
6339
  options?: { bufferSize?: number | undefined } | undefined
6300
6340
  ): Effect.Effect<[excluded: Stream<Exclude<C, B>, E, never>, satisfying: Stream<B, E, never>], E, R | Scope.Scope>
6301
6341
  /**
6302
- * Partition a stream using a predicate. The first stream will contain all
6303
- * element evaluated to false and the second one will contain all element
6304
- * evaluated to true. The faster stream may advance by up to buffer elements
6305
- * further than the slower one.
6342
+ * Splits a stream into two substreams based on a predicate.
6343
+ *
6344
+ * **Details**
6345
+ *
6346
+ * The `Stream.partition` function splits a stream into two parts: one for
6347
+ * elements that satisfy the predicate (evaluated to `true`) and another for
6348
+ * those that do not (evaluated to `false`).
6349
+ *
6350
+ * The faster stream may advance up to `bufferSize` elements ahead of the slower
6351
+ * one.
6352
+ *
6353
+ * @see {@link partitionEither} for partitioning a stream based on effectful
6354
+ * conditions.
6306
6355
  *
6307
6356
  * @example
6308
6357
  * ```ts
6358
+ * // Title: Partitioning a Stream into Even and Odd Numbers
6309
6359
  * import { Effect, Stream } from "effect"
6310
6360
  *
6311
- * const partition = Stream.range(1, 10).pipe(
6361
+ * const partition = Stream.range(1, 9).pipe(
6312
6362
  * Stream.partition((n) => n % 2 === 0, { bufferSize: 5 })
6313
6363
  * )
6314
6364
  *
@@ -6322,7 +6372,7 @@ export const partition: {
6322
6372
  *
6323
6373
  * // Effect.runPromise(program)
6324
6374
  * // { _id: 'Chunk', values: [ 1, 3, 5, 7, 9 ] }
6325
- * // { _id: 'Chunk', values: [ 2, 4, 6, 8, 10 ] }
6375
+ * // { _id: 'Chunk', values: [ 2, 4, 6, 8 ] }
6326
6376
  * ```
6327
6377
  *
6328
6378
  * @since 2.0.0
@@ -6336,16 +6386,29 @@ export const partition: {
6336
6386
  } = internal.partition
6337
6387
 
6338
6388
  /**
6339
- * Split a stream by an effectful predicate. The faster stream may advance by
6340
- * up to buffer elements further than the slower one.
6389
+ * Splits a stream into two substreams based on an effectful condition.
6390
+ *
6391
+ * **Details**
6392
+ *
6393
+ * The `Stream.partitionEither` function is used to divide a stream into two
6394
+ * parts: one for elements that satisfy a condition producing `Either.left`
6395
+ * values, and another for those that produce `Either.right` values. This
6396
+ * function applies an effectful predicate to each element in the stream to
6397
+ * determine which substream it belongs to.
6398
+ *
6399
+ * The faster stream may advance up to `bufferSize` elements ahead of the slower
6400
+ * one.
6401
+ *
6402
+ * @see {@link partition} for partitioning a stream based on simple conditions.
6341
6403
  *
6342
6404
  * @example
6343
6405
  * ```ts
6406
+ * // Title: Partitioning a Stream with an Effectful Predicate
6344
6407
  * import { Effect, Either, Stream } from "effect"
6345
6408
  *
6346
6409
  * const partition = Stream.range(1, 9).pipe(
6347
6410
  * Stream.partitionEither(
6348
- * (n) => Effect.succeed(n % 2 === 0 ? Either.left(n) : Either.right(n)),
6411
+ * (n) => Effect.succeed(n % 2 === 0 ? Either.right(n) : Either.left(n)),
6349
6412
  * { bufferSize: 5 }
6350
6413
  * )
6351
6414
  * )
@@ -6359,8 +6422,8 @@ export const partition: {
6359
6422
  * )
6360
6423
  *
6361
6424
  * // Effect.runPromise(program)
6362
- * // { _id: 'Chunk', values: [ 2, 4, 6, 8 ] }
6363
6425
  * // { _id: 'Chunk', values: [ 1, 3, 5, 7, 9 ] }
6426
+ * // { _id: 'Chunk', values: [ 2, 4, 6, 8 ] }
6364
6427
  * ```
6365
6428
  *
6366
6429
  * @since 2.0.0
@@ -6368,16 +6431,29 @@ export const partition: {
6368
6431
  */
6369
6432
  export const partitionEither: {
6370
6433
  /**
6371
- * Split a stream by an effectful predicate. The faster stream may advance by
6372
- * up to buffer elements further than the slower one.
6434
+ * Splits a stream into two substreams based on an effectful condition.
6435
+ *
6436
+ * **Details**
6437
+ *
6438
+ * The `Stream.partitionEither` function is used to divide a stream into two
6439
+ * parts: one for elements that satisfy a condition producing `Either.left`
6440
+ * values, and another for those that produce `Either.right` values. This
6441
+ * function applies an effectful predicate to each element in the stream to
6442
+ * determine which substream it belongs to.
6443
+ *
6444
+ * The faster stream may advance up to `bufferSize` elements ahead of the slower
6445
+ * one.
6446
+ *
6447
+ * @see {@link partition} for partitioning a stream based on simple conditions.
6373
6448
  *
6374
6449
  * @example
6375
6450
  * ```ts
6451
+ * // Title: Partitioning a Stream with an Effectful Predicate
6376
6452
  * import { Effect, Either, Stream } from "effect"
6377
6453
  *
6378
6454
  * const partition = Stream.range(1, 9).pipe(
6379
6455
  * Stream.partitionEither(
6380
- * (n) => Effect.succeed(n % 2 === 0 ? Either.left(n) : Either.right(n)),
6456
+ * (n) => Effect.succeed(n % 2 === 0 ? Either.right(n) : Either.left(n)),
6381
6457
  * { bufferSize: 5 }
6382
6458
  * )
6383
6459
  * )
@@ -6391,8 +6467,8 @@ export const partitionEither: {
6391
6467
  * )
6392
6468
  *
6393
6469
  * // Effect.runPromise(program)
6394
- * // { _id: 'Chunk', values: [ 2, 4, 6, 8 ] }
6395
6470
  * // { _id: 'Chunk', values: [ 1, 3, 5, 7, 9 ] }
6471
+ * // { _id: 'Chunk', values: [ 2, 4, 6, 8 ] }
6396
6472
  * ```
6397
6473
  *
6398
6474
  * @since 2.0.0
@@ -6405,16 +6481,29 @@ export const partitionEither: {
6405
6481
  self: Stream<A, E, R>
6406
6482
  ) => Effect.Effect<[left: Stream<A2, E2 | E, never>, right: Stream<A3, E2 | E, never>], E2 | E, Scope.Scope | R2 | R>
6407
6483
  /**
6408
- * Split a stream by an effectful predicate. The faster stream may advance by
6409
- * up to buffer elements further than the slower one.
6484
+ * Splits a stream into two substreams based on an effectful condition.
6485
+ *
6486
+ * **Details**
6487
+ *
6488
+ * The `Stream.partitionEither` function is used to divide a stream into two
6489
+ * parts: one for elements that satisfy a condition producing `Either.left`
6490
+ * values, and another for those that produce `Either.right` values. This
6491
+ * function applies an effectful predicate to each element in the stream to
6492
+ * determine which substream it belongs to.
6493
+ *
6494
+ * The faster stream may advance up to `bufferSize` elements ahead of the slower
6495
+ * one.
6496
+ *
6497
+ * @see {@link partition} for partitioning a stream based on simple conditions.
6410
6498
  *
6411
6499
  * @example
6412
6500
  * ```ts
6501
+ * // Title: Partitioning a Stream with an Effectful Predicate
6413
6502
  * import { Effect, Either, Stream } from "effect"
6414
6503
  *
6415
6504
  * const partition = Stream.range(1, 9).pipe(
6416
6505
  * Stream.partitionEither(
6417
- * (n) => Effect.succeed(n % 2 === 0 ? Either.left(n) : Either.right(n)),
6506
+ * (n) => Effect.succeed(n % 2 === 0 ? Either.right(n) : Either.left(n)),
6418
6507
  * { bufferSize: 5 }
6419
6508
  * )
6420
6509
  * )
@@ -6428,8 +6517,8 @@ export const partitionEither: {
6428
6517
  * )
6429
6518
  *
6430
6519
  * // Effect.runPromise(program)
6431
- * // { _id: 'Chunk', values: [ 2, 4, 6, 8 ] }
6432
6520
  * // { _id: 'Chunk', values: [ 1, 3, 5, 7, 9 ] }
6521
+ * // { _id: 'Chunk', values: [ 2, 4, 6, 8 ] }
6433
6522
  * ```
6434
6523
  *
6435
6524
  * @since 2.0.0
@@ -226,7 +226,9 @@ class PoolImpl<A, E> extends Effectable.Class<A, E, Scope> implements Pool<A, E>
226
226
  circular.forkIn(core.interruptible(this.resize), this.scope)
227
227
  ),
228
228
  function loop(): Effect<PoolItem<A, E>> {
229
- if (self.available.size > 0) {
229
+ if (self.isShuttingDown) {
230
+ return core.interrupt
231
+ } else if (self.available.size > 0) {
230
232
  return core.succeed(Iterable.unsafeHead(self.available))
231
233
  }
232
234
  self.availableLatch.unsafeClose()
@@ -328,6 +330,7 @@ class PoolImpl<A, E> extends Effectable.Class<A, E, Scope> implements Pool<A, E>
328
330
  return item.finalizer
329
331
  }).pipe(
330
332
  core.zipRight(this.semaphore.releaseAll),
333
+ core.zipRight(this.availableLatch.open),
331
334
  core.zipRight(semaphore.take(size))
332
335
  )
333
336
  })
@@ -1,4 +1,4 @@
1
- let moduleVersion = "3.11.0"
1
+ let moduleVersion = "3.11.2"
2
2
 
3
3
  export const getCurrentVersion = () => moduleVersion
4
4