effect 4.0.0-beta.20 → 4.0.0-beta.21

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 (45) hide show
  1. package/dist/Effect.d.ts +92 -1
  2. package/dist/Effect.d.ts.map +1 -1
  3. package/dist/Effect.js +30 -1
  4. package/dist/Effect.js.map +1 -1
  5. package/dist/Schedule.d.ts.map +1 -1
  6. package/dist/Schedule.js +4 -1
  7. package/dist/Schedule.js.map +1 -1
  8. package/dist/SchemaAST.js +6 -6
  9. package/dist/SchemaAST.js.map +1 -1
  10. package/dist/Stream.js +1 -1
  11. package/dist/TxPubSub.d.ts +4 -4
  12. package/dist/TxPubSub.d.ts.map +1 -1
  13. package/dist/internal/effect.js +38 -0
  14. package/dist/internal/effect.js.map +1 -1
  15. package/dist/unstable/ai/McpServer.js +2 -1
  16. package/dist/unstable/ai/McpServer.js.map +1 -1
  17. package/dist/unstable/http/HttpEffect.js +2 -2
  18. package/dist/unstable/http/HttpEffect.js.map +1 -1
  19. package/dist/unstable/http/HttpMiddleware.js +2 -2
  20. package/dist/unstable/http/HttpMiddleware.js.map +1 -1
  21. package/dist/unstable/http/HttpServerRequest.d.ts +1 -1
  22. package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
  23. package/dist/unstable/http/internal/preResponseHandler.js +2 -2
  24. package/dist/unstable/http/internal/preResponseHandler.js.map +1 -1
  25. package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
  26. package/dist/unstable/workflow/Workflow.js +1 -1
  27. package/dist/unstable/workflow/Workflow.js.map +1 -1
  28. package/dist/unstable/workflow/WorkflowEngine.d.ts +5 -1
  29. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  30. package/dist/unstable/workflow/WorkflowEngine.js +5 -1
  31. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  32. package/package.json +1 -1
  33. package/src/Effect.ts +100 -1
  34. package/src/Schedule.ts +4 -1
  35. package/src/SchemaAST.ts +6 -6
  36. package/src/Stream.ts +1 -1
  37. package/src/TxPubSub.ts +4 -4
  38. package/src/internal/effect.ts +84 -0
  39. package/src/unstable/ai/McpServer.ts +2 -1
  40. package/src/unstable/http/HttpEffect.ts +2 -2
  41. package/src/unstable/http/HttpMiddleware.ts +3 -3
  42. package/src/unstable/http/HttpServerRequest.ts +1 -1
  43. package/src/unstable/http/internal/preResponseHandler.ts +3 -3
  44. package/src/unstable/workflow/Workflow.ts +5 -1
  45. package/src/unstable/workflow/WorkflowEngine.ts +5 -1
package/dist/Effect.d.ts CHANGED
@@ -625,7 +625,6 @@ export declare namespace All {
625
625
  * ```
626
626
  *
627
627
  * @see {@link forEach} for iterating over elements and applying an effect.
628
- * @see {@link allWith} for a data-last version of this function.
629
628
  *
630
629
  * @since 2.0.0
631
630
  * @category Collecting
@@ -917,6 +916,98 @@ export declare const validate: {
917
916
  readonly discard: true;
918
917
  }): Effect<void, Arr.NonEmptyArray<E>, R>;
919
918
  };
919
+ /**
920
+ * Returns the first element that satisfies an effectful predicate.
921
+ *
922
+ * The predicate receives the element and its index. Evaluation short-circuits
923
+ * as soon as an element matches.
924
+ *
925
+ * @example
926
+ * ```ts
927
+ * import { Effect } from "effect"
928
+ *
929
+ * const program = Effect.findFirst([1, 2, 3, 4], (n) => Effect.succeed(n > 2))
930
+ *
931
+ * Effect.runPromise(program).then(console.log)
932
+ * // { _id: 'Option', _tag: 'Some', value: 3 }
933
+ * ```
934
+ *
935
+ * @since 2.0.0
936
+ * @category Collecting
937
+ */
938
+ export declare const findFirst: {
939
+ /**
940
+ * Returns the first element that satisfies an effectful predicate.
941
+ *
942
+ * The predicate receives the element and its index. Evaluation short-circuits
943
+ * as soon as an element matches.
944
+ *
945
+ * @example
946
+ * ```ts
947
+ * import { Effect } from "effect"
948
+ *
949
+ * const program = Effect.findFirst([1, 2, 3, 4], (n) => Effect.succeed(n > 2))
950
+ *
951
+ * Effect.runPromise(program).then(console.log)
952
+ * // { _id: 'Option', _tag: 'Some', value: 3 }
953
+ * ```
954
+ *
955
+ * @since 2.0.0
956
+ * @category Collecting
957
+ */
958
+ <A, E, R>(predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>): (elements: Iterable<A>) => Effect<Option<A>, E, R>;
959
+ /**
960
+ * Returns the first element that satisfies an effectful predicate.
961
+ *
962
+ * The predicate receives the element and its index. Evaluation short-circuits
963
+ * as soon as an element matches.
964
+ *
965
+ * @example
966
+ * ```ts
967
+ * import { Effect } from "effect"
968
+ *
969
+ * const program = Effect.findFirst([1, 2, 3, 4], (n) => Effect.succeed(n > 2))
970
+ *
971
+ * Effect.runPromise(program).then(console.log)
972
+ * // { _id: 'Option', _tag: 'Some', value: 3 }
973
+ * ```
974
+ *
975
+ * @since 2.0.0
976
+ * @category Collecting
977
+ */
978
+ <A, E, R>(elements: Iterable<A>, predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>): Effect<Option<A>, E, R>;
979
+ };
980
+ /**
981
+ * Returns the first value that passes an effectful `FilterEffect`.
982
+ *
983
+ * The filter receives the element and index. Evaluation short-circuits on the
984
+ * first `Result.succeed` and returns the transformed value in `Option.some`.
985
+ *
986
+ * @since 4.0.0
987
+ * @category Collecting
988
+ */
989
+ export declare const findFirstFilter: {
990
+ /**
991
+ * Returns the first value that passes an effectful `FilterEffect`.
992
+ *
993
+ * The filter receives the element and index. Evaluation short-circuits on the
994
+ * first `Result.succeed` and returns the transformed value in `Option.some`.
995
+ *
996
+ * @since 4.0.0
997
+ * @category Collecting
998
+ */
999
+ <A, B, X, E, R>(filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R, [i: number]>): (elements: Iterable<A>) => Effect<Option<B>, E, R>;
1000
+ /**
1001
+ * Returns the first value that passes an effectful `FilterEffect`.
1002
+ *
1003
+ * The filter receives the element and index. Evaluation short-circuits on the
1004
+ * first `Result.succeed` and returns the transformed value in `Option.some`.
1005
+ *
1006
+ * @since 4.0.0
1007
+ * @category Collecting
1008
+ */
1009
+ <A, B, X, E, R>(elements: Iterable<A>, filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R, [i: number]>): Effect<Option<B>, E, R>;
1010
+ };
920
1011
  /**
921
1012
  * Executes an effectful operation for each element in an `Iterable`.
922
1013
  *