effect 4.0.0-beta.60 → 4.0.0-beta.62

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/Effect.d.ts CHANGED
@@ -7143,6 +7143,50 @@ export declare const orElseSucceed: {
7143
7143
  */
7144
7144
  <A, E, R, A2>(self: Effect<A, E, R>, evaluate: LazyArg<A2>): Effect<A | A2, never, R>;
7145
7145
  };
7146
+ /**
7147
+ * Runs a sequence of effects and returns the result of the first successful
7148
+ * one.
7149
+ *
7150
+ * **Details**
7151
+ *
7152
+ * This function executes the provided effects in sequence, stopping at the
7153
+ * first success. If an effect succeeds, its result is returned immediately and
7154
+ * no further effects in the sequence are executed.
7155
+ *
7156
+ * If all effects fail, the returned effect fails with the error from the last
7157
+ * effect. If the collection is empty, the returned effect defects with an
7158
+ * `Error` whose message is `"Received an empty collection of effects"`.
7159
+ *
7160
+ * **When to Use**
7161
+ *
7162
+ * Use `firstSuccessOf` when you have prioritized fallback strategies, such as
7163
+ * attempting multiple APIs, reading configuration from several sources, or
7164
+ * trying alternative resource locations in order.
7165
+ *
7166
+ * @example
7167
+ * ```ts
7168
+ * import { Effect } from "effect"
7169
+ *
7170
+ * const primary = Effect.fail("primary unavailable")
7171
+ * const secondary = Effect.succeed("secondary result")
7172
+ * const tertiary = Effect.sync(() => {
7173
+ * throw new Error("not evaluated")
7174
+ * })
7175
+ *
7176
+ * const program = Effect.firstSuccessOf([
7177
+ * primary,
7178
+ * secondary,
7179
+ * tertiary
7180
+ * ])
7181
+ *
7182
+ * console.log(Effect.runSync(program))
7183
+ * // Output: "secondary result"
7184
+ * ```
7185
+ *
7186
+ * @since 2.0.0
7187
+ * @category Fallback
7188
+ */
7189
+ export declare const firstSuccessOf: <Eff extends Effect<any, any, any>>(effects: Iterable<Eff>) => Effect<Success<Eff>, Error<Eff>, Services<Eff>>;
7146
7190
  /**
7147
7191
  * Adds a time limit to an effect, triggering a timeout if the effect exceeds
7148
7192
  * the duration.