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.
- package/dist/cjs/Effect.js +3418 -804
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/Function.js.map +1 -1
- package/dist/cjs/Layer.js +1 -1
- package/dist/cjs/internal/core-effect.js +2 -2
- package/dist/cjs/internal/core-effect.js.map +1 -1
- package/dist/cjs/internal/fiberRuntime.js +1 -0
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/Data.d.ts.map +1 -1
- package/dist/dts/Effect.d.ts +8989 -1667
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/Equivalence.d.ts.map +1 -1
- package/dist/dts/FiberHandle.d.ts.map +1 -1
- package/dist/dts/FiberMap.d.ts.map +1 -1
- package/dist/dts/FiberSet.d.ts.map +1 -1
- package/dist/dts/Function.d.ts +53 -9
- package/dist/dts/Function.d.ts.map +1 -1
- package/dist/dts/Layer.d.ts +1 -1
- package/dist/dts/Micro.d.ts.map +1 -1
- package/dist/dts/Order.d.ts.map +1 -1
- package/dist/dts/ParseResult.d.ts +3 -5
- package/dist/dts/ParseResult.d.ts.map +1 -1
- package/dist/dts/Record.d.ts.map +1 -1
- package/dist/dts/RequestResolver.d.ts.map +1 -1
- package/dist/dts/Schema.d.ts.map +1 -1
- package/dist/dts/Struct.d.ts.map +1 -1
- package/dist/dts/internal/fiberRuntime.d.ts.map +1 -1
- package/dist/dts/internal/stm/stm.d.ts.map +1 -1
- package/dist/dts/internal/stream.d.ts.map +1 -1
- package/dist/esm/Effect.js +3459 -790
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/Function.js.map +1 -1
- package/dist/esm/Layer.js +1 -1
- package/dist/esm/internal/core-effect.js +2 -2
- package/dist/esm/internal/core-effect.js.map +1 -1
- package/dist/esm/internal/fiberRuntime.js +1 -0
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/Effect.ts +8933 -1850
- package/src/Function.ts +53 -9
- package/src/Layer.ts +1 -1
- package/src/internal/core-effect.ts +7 -7
- package/src/internal/fiberRuntime.ts +1 -0
- 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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
527
|
-
*
|
|
528
|
-
* // import { pipe } from "effect"
|
|
566
|
+
* // Example: Chaining Arithmetic Operations
|
|
567
|
+
* import { pipe } from "effect"
|
|
529
568
|
*
|
|
530
|
-
*
|
|
531
|
-
* const
|
|
532
|
-
* const
|
|
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
|
-
*
|
|
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
|
|
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
|
-
|
|
1032
|
-
f: (
|
|
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
|
-
|
|
1037
|
-
f: (
|
|
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
|
-
|
|
1042
|
-
f: (
|
|
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(
|
|
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) {
|
package/src/internal/version.ts
CHANGED