effect 3.10.16 → 3.10.17

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 (46) hide show
  1. package/dist/cjs/Effect.js +3418 -804
  2. package/dist/cjs/Effect.js.map +1 -1
  3. package/dist/cjs/Function.js.map +1 -1
  4. package/dist/cjs/Layer.js +1 -1
  5. package/dist/cjs/internal/core-effect.js +2 -2
  6. package/dist/cjs/internal/core-effect.js.map +1 -1
  7. package/dist/cjs/internal/fiberRuntime.js +1 -0
  8. package/dist/cjs/internal/fiberRuntime.js.map +1 -1
  9. package/dist/cjs/internal/version.js +1 -1
  10. package/dist/dts/Data.d.ts.map +1 -1
  11. package/dist/dts/Effect.d.ts +8989 -1667
  12. package/dist/dts/Effect.d.ts.map +1 -1
  13. package/dist/dts/Equivalence.d.ts.map +1 -1
  14. package/dist/dts/FiberHandle.d.ts.map +1 -1
  15. package/dist/dts/FiberMap.d.ts.map +1 -1
  16. package/dist/dts/FiberSet.d.ts.map +1 -1
  17. package/dist/dts/Function.d.ts +53 -9
  18. package/dist/dts/Function.d.ts.map +1 -1
  19. package/dist/dts/Layer.d.ts +1 -1
  20. package/dist/dts/Micro.d.ts.map +1 -1
  21. package/dist/dts/Order.d.ts.map +1 -1
  22. package/dist/dts/ParseResult.d.ts +3 -5
  23. package/dist/dts/ParseResult.d.ts.map +1 -1
  24. package/dist/dts/Record.d.ts.map +1 -1
  25. package/dist/dts/RequestResolver.d.ts.map +1 -1
  26. package/dist/dts/Schema.d.ts.map +1 -1
  27. package/dist/dts/Struct.d.ts.map +1 -1
  28. package/dist/dts/internal/fiberRuntime.d.ts.map +1 -1
  29. package/dist/dts/internal/stm/stm.d.ts.map +1 -1
  30. package/dist/dts/internal/stream.d.ts.map +1 -1
  31. package/dist/esm/Effect.js +3459 -790
  32. package/dist/esm/Effect.js.map +1 -1
  33. package/dist/esm/Function.js.map +1 -1
  34. package/dist/esm/Layer.js +1 -1
  35. package/dist/esm/internal/core-effect.js +2 -2
  36. package/dist/esm/internal/core-effect.js.map +1 -1
  37. package/dist/esm/internal/fiberRuntime.js +1 -0
  38. package/dist/esm/internal/fiberRuntime.js.map +1 -1
  39. package/dist/esm/internal/version.js +1 -1
  40. package/package.json +1 -1
  41. package/src/Effect.ts +8933 -1850
  42. package/src/Function.ts +53 -9
  43. package/src/Layer.ts +1 -1
  44. package/src/internal/core-effect.ts +7 -7
  45. package/src/internal/fiberRuntime.ts +1 -0
  46. package/src/internal/version.ts +1 -1
package/src/Function.ts CHANGED
@@ -516,22 +516,66 @@ export const untupled = <A extends ReadonlyArray<unknown>, B>(f: (a: A) => B): (
516
516
  /**
517
517
  * Pipes the value of an expression into a pipeline of functions.
518
518
  *
519
- * This is useful in combination with data-last functions as a simulation of methods:
519
+ * **When to Use**
520
520
  *
521
+ * This is useful in combination with data-last functions as a simulation of
522
+ * methods:
523
+ *
524
+ * ```ts
525
+ * as.map(f).filter(g)
526
+ * ```
527
+ *
528
+ * becomes:
529
+ *
530
+ * ```ts
531
+ * import { pipe, Array } from "effect"
532
+ *
533
+ * pipe(as, Array.map(f), Array.filter(g))
534
+ * ```
535
+ *
536
+ * **Details**
537
+ *
538
+ * The `pipe` function is a utility that allows us to compose functions in a
539
+ * readable and sequential manner. It takes the output of one function and
540
+ * passes it as the input to the next function in the pipeline. This enables us
541
+ * to build complex transformations by chaining multiple functions together.
542
+ *
543
+ * ```ts
544
+ * import { pipe } from "effect"
545
+ *
546
+ * const result = pipe(input, func1, func2, ..., funcN)
521
547
  * ```
522
- * as.map(f).filter(g) -> pipe(as, map(f), filter(g))
548
+ *
549
+ * In this syntax, `input` is the initial value, and `func1`, `func2`, ...,
550
+ * `funcN` are the functions to be applied in sequence. The result of each
551
+ * function becomes the input for the next function, and the final result is
552
+ * returned.
553
+ *
554
+ * Here's an illustration of how `pipe` works:
555
+ *
556
+ * ```text
557
+ * ┌───────┐ ┌───────┐ ┌───────┐ ┌───────┐ ┌───────┐ ┌────────┐
558
+ * │ input │───►│ func1 │───►│ func2 │───►│ ... │───►│ funcN │───►│ result │
559
+ * └───────┘ └───────┘ └───────┘ └───────┘ └───────┘ └────────┘
523
560
  * ```
524
561
  *
562
+ * It's important to note that functions passed to `pipe` must have a **single
563
+ * argument** because they are only called with a single argument.
564
+ *
525
565
  * @example
526
- * import { pipe } from "effect/Function"
527
- * // Alternatively, you can use the following import syntax, as `pipe` is also conveniently exported from the `effect` entry point:
528
- * // import { pipe } from "effect"
566
+ * // Example: Chaining Arithmetic Operations
567
+ * import { pipe } from "effect"
529
568
  *
530
- * const length = (s: string): number => s.length
531
- * const double = (n: number): number => n * 2
532
- * const decrement = (n: number): number => n - 1
569
+ * // Define simple arithmetic operations
570
+ * const increment = (x: number) => x + 1
571
+ * const double = (x: number) => x * 2
572
+ * const subtractTen = (x: number) => x - 10
573
+ *
574
+ * // Sequentially apply these operations using `pipe`
575
+ * const result = pipe(5, increment, double, subtractTen)
533
576
  *
534
- * assert.deepStrictEqual(pipe(length("hello"), double, decrement), 9)
577
+ * console.log(result)
578
+ * // Output: 2
535
579
  *
536
580
  * @since 2.0.0
537
581
  */
package/src/Layer.ts CHANGED
@@ -368,7 +368,7 @@ export const effect: {
368
368
  } = internal.fromEffect
369
369
 
370
370
  /**
371
- * Constructs a layer from the specified effect discarding it's output.
371
+ * Constructs a layer from the specified effect, discarding its output.
372
372
  *
373
373
  * @since 2.0.0
374
374
  * @category constructors
@@ -1028,23 +1028,23 @@ const loopDiscard = <S, X, E, R>(
1028
1028
  /* @internal */
1029
1029
  export const mapAccum: {
1030
1030
  <S, A, B, E, R, I extends Iterable<A> = Iterable<A>>(
1031
- zero: S,
1032
- f: (s: S, a: A, i: number) => Effect.Effect<readonly [S, B], E, R>
1031
+ initial: S,
1032
+ f: (state: S, a: A, i: number) => Effect.Effect<readonly [S, B], E, R>
1033
1033
  ): (elements: I) => Effect.Effect<[S, Arr.ReadonlyArray.With<I, B>], E, R>
1034
1034
  <A, S, B, E, R, I extends Iterable<A> = Iterable<A>>(
1035
1035
  elements: I,
1036
- zero: S,
1037
- f: (s: S, a: A, i: number) => Effect.Effect<readonly [S, B], E, R>
1036
+ initial: S,
1037
+ f: (state: S, a: A, i: number) => Effect.Effect<readonly [S, B], E, R>
1038
1038
  ): Effect.Effect<[S, Arr.ReadonlyArray.With<I, B>], E, R>
1039
1039
  } = dual(3, <A, S, B, E, R, I extends Iterable<A> = Iterable<A>>(
1040
1040
  elements: I,
1041
- zero: S,
1042
- f: (s: S, a: A, i: number) => Effect.Effect<readonly [S, B], E, R>
1041
+ initial: S,
1042
+ f: (state: S, a: A, i: number) => Effect.Effect<readonly [S, B], E, R>
1043
1043
  ): Effect.Effect<[S, Array<B>], E, R> =>
1044
1044
  core.suspend(() => {
1045
1045
  const iterator = elements[Symbol.iterator]()
1046
1046
  const builder: Array<B> = []
1047
- let result: Effect.Effect<S, E, R> = core.succeed(zero)
1047
+ let result: Effect.Effect<S, E, R> = core.succeed(initial)
1048
1048
  let next: IteratorResult<A, any>
1049
1049
  let i = 0
1050
1050
  while (!(next = iterator.next()).done) {
@@ -812,6 +812,7 @@ export class FiberRuntime<in out A, in out E = never> extends Effectable.Class<A
812
812
  for (let i = this._observers.length - 1; i >= 0; i--) {
813
813
  this._observers[i](exit)
814
814
  }
815
+ this._observers = []
815
816
  }
816
817
 
817
818
  getLoggers() {
@@ -1,4 +1,4 @@
1
- let moduleVersion = "3.10.16"
1
+ let moduleVersion = "3.10.17"
2
2
 
3
3
  export const getCurrentVersion = () => moduleVersion
4
4