import * as tsplus_module_1 from "@effect/core/io/Effect/operations/unit";
import * as tsplus_module_2 from "@tsplus/stdlib/data/Either/fromMaybe";
import * as tsplus_module_3 from "@effect/core/stream/Stream/operations/asyncInterrupt";
/**
 * Creates a stream from an asynchronous callback that can be called multiple
 * times. The registration of the callback can possibly return the stream
 * synchronously. The optionality of the error type `E` can be used to signal
 * the end of the stream, by setting it to `None`.
 *
 * @tsplus static ets/Stream/Ops asyncMaybe
 */

export function asyncMaybe(register, outputBuffer = 16, __tsplusTrace) {
  return tsplus_module_3.asyncInterrupt(emit => tsplus_module_2.fromMaybe(register(emit), () => tsplus_module_1.unit), outputBuffer, __tsplusTrace);
}
//# sourceMappingURL=asyncMaybe.mjs.map