Socket
Socket
Sign inDemoInstall

@effect/stream

Package Overview
Dependencies
Maintainers
3
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@effect/stream - npm Package Compare versions

Comparing version 0.24.0 to 0.25.0

3

Channel.js

@@ -775,3 +775,2 @@ "use strict";

*
* @macro traced
* @since 1.0.0

@@ -788,3 +787,2 @@ * @category destructors

*
* @macro traced
* @since 1.0.0

@@ -798,3 +796,2 @@ * @category destructors

*
* @macro traced
* @since 1.0.0

@@ -801,0 +798,0 @@ * @category destructors

@@ -28,9 +28,3 @@ /**

export interface SingleProducerAsyncInput<Err, Elem, Done> extends AsyncInputProducer<Err, Elem, Done>, AsyncInputConsumer<Err, Elem, Done> {
/**
* @macro traced
*/
close(): Effect.Effect<never, never, unknown>;
/**
* @macro traced
*/
take(): Effect.Effect<never, never, Exit.Exit<Either.Either<Err, Done>, Elem>>;

@@ -45,17 +39,5 @@ }

export interface AsyncInputProducer<Err, Elem, Done> {
/**
* @macro traced
*/
awaitRead(): Effect.Effect<never, never, unknown>;
/**
* @macro traced
*/
done(value: Done): Effect.Effect<never, never, unknown>;
/**
* @macro traced
*/
emit(element: Elem): Effect.Effect<never, never, unknown>;
/**
* @macro traced
*/
error(cause: Cause.Cause<Err>): Effect.Effect<never, never, unknown>;

@@ -70,9 +52,5 @@ }

export interface AsyncInputConsumer<Err, Elem, Done> {
/**
* @macro traced
*/
takeWith<A>(onError: (cause: Cause.Cause<Err>) => A, onElement: (element: Elem) => A, onDone: (value: Done) => A): Effect.Effect<never, never, A>;
}
/**
* @macro traced
* @since 1.0.0

@@ -79,0 +57,0 @@ * @category constructors

@@ -11,3 +11,2 @@ "use strict";

/**
* @macro traced
* @since 1.0.0

@@ -14,0 +13,0 @@ * @category constructors

209

internal/channel.js

@@ -35,3 +35,3 @@ "use strict";

/** @internal */
const acquireUseRelease = (acquire, use, release) => core.flatMap(core.fromEffect(Ref.make(() => Effect.unit())), ref => core.ensuringWith(exit => Effect.flatMap(Ref.get(ref), f => f(exit)))(core.flatMap(use)(core.fromEffect(Effect.uninterruptible(Effect.tap(acquire, a => Ref.set(ref, exit => release(a, exit))))))));
const acquireUseRelease = (acquire, use, release) => core.flatMap(core.fromEffect(Ref.make(() => Effect.unit)), ref => core.ensuringWith(exit => Effect.flatMap(Ref.get(ref), f => f(exit)))(core.flatMap(use)(core.fromEffect(Effect.uninterruptible(Effect.tap(acquire, a => Ref.set(ref, exit => release(a, exit))))))));
/** @internal */

@@ -54,3 +54,6 @@ exports.acquireUseRelease = acquireUseRelease;

exports.bufferChunk = bufferChunk;
const catchAll = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => core.catchAllCause(self, cause => Either.match(Cause.failureOrCause(cause), f, core.failCause)));
const catchAll = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => core.catchAllCause(self, cause => Either.match(Cause.failureOrCause(cause), {
onLeft: f,
onRight: core.failCause
})));
/** @internal */

@@ -62,3 +65,6 @@ exports.catchAll = catchAll;

const collect = /*#__PURE__*/(0, _Function.dual)(2, (self, pf) => {
const collector = core.readWith(out => Option.match(pf(out), () => collector, out2 => core.flatMap(core.write(out2), () => collector)), core.fail, core.succeedNow);
const collector = core.readWith(out => Option.match(pf(out), {
onNone: () => collector,
onSome: out2 => core.flatMap(core.write(out2), () => collector)
}), core.fail, core.succeedNow);
return core.pipeTo(self, collector);

@@ -160,3 +166,6 @@ });

exports.foldChannel = foldChannel;
const fromEither = either => core.suspend(() => Either.match(either, core.fail, core.succeed));
const fromEither = either => core.suspend(() => Either.match(either, {
onLeft: core.fail,
onRight: core.succeed
}));
/** @internal */

@@ -173,3 +182,6 @@ exports.fromEither = fromEither;

exports.fromHubScoped = fromHubScoped;
const fromOption = option => core.suspend(() => Option.match(option, () => core.fail(Option.none()), core.succeed));
const fromOption = option => core.suspend(() => Option.match(option, {
onNone: () => core.fail(Option.none()),
onSome: core.succeed
}));
/** @internal */

@@ -180,3 +192,9 @@ exports.fromOption = fromOption;

exports.fromQueue = fromQueue;
const fromQueueInternal = queue => core.flatMap(Either.match(Exit.match(core.failCause, core.succeedNow), elem => core.flatMap(() => fromQueueInternal(queue))(core.write(elem))))(core.fromEffect(Queue.take(queue)));
const fromQueueInternal = queue => core.flatMap(Either.match({
onLeft: Exit.match({
onFailure: core.failCause,
onSuccess: core.succeedNow
}),
onRight: elem => core.flatMap(core.write(elem), () => fromQueueInternal(queue))
}))(core.fromEffect(Queue.take(queue)));
/** @internal */

@@ -186,3 +204,3 @@ const identityChannel = () => core.readWith(input => core.flatMap(core.write(input), () => identityChannel()), core.fail, core.succeedNow);

exports.identityChannel = identityChannel;
const interruptWhen = /*#__PURE__*/(0, _Function.dual)(2, (self, effect) => mergeWith(self, core.fromEffect(effect), selfDone => mergeDecision.Done(Effect.done(selfDone)), effectDone => mergeDecision.Done(Effect.done(effectDone))));
const interruptWhen = /*#__PURE__*/(0, _Function.dual)(2, (self, effect) => mergeWith(self, core.fromEffect(effect), selfDone => mergeDecision.Done(Effect.suspend(() => selfDone)), effectDone => mergeDecision.Done(Effect.suspend(() => effectDone))));
/** @internal */

@@ -218,19 +236,36 @@ exports.interruptWhen = interruptWhen;

const mapOutEffectPar = /*#__PURE__*/(0, _Function.dual)(3, (self, f, n) => unwrapScoped(Effect.map(queue => {
const consumer = unwrap(Effect.matchCause(Effect.flatten(Queue.take(queue)), core.failCause, Either.match(core.succeedNow, outElem => core.flatMap(core.write(outElem), () => consumer))));
const consumer = unwrap(Effect.matchCause(Effect.flatten(Queue.take(queue)), {
onFailure: core.failCause,
onSuccess: Either.match({
onLeft: core.succeedNow,
onRight: outElem => core.flatMap(core.write(outElem), () => consumer)
})
}));
return consumer;
})(Effect.gen(function* ($) {
const queue = yield* $(Effect.acquireRelease(Queue.bounded(n), Queue.shutdown));
const queue = yield* $(Effect.acquireRelease({
acquire: Queue.bounded(n),
release: queue => Queue.shutdown(queue)
}));
const errorSignal = yield* $(Deferred.make());
const withPermits = n === Number.POSITIVE_INFINITY ? _ => _Function.identity : (yield* $(Effect.makeSemaphore(n))).withPermits;
const pull = yield* $(toPull(self));
yield* $(Effect.forkScoped(Effect.interruptible(Effect.forever(Effect.matchCauseEffect(pull, cause => Queue.offer(queue, Effect.failCause(cause)), either => Either.match(either, outDone => {
const lock = withPermits(n);
return Effect.zipRight(Effect.interruptible(lock(Effect.unit())), Effect.asUnit(Queue.offer(queue, Effect.succeed(Either.left(outDone)))));
}, outElem => Effect.gen(function* ($) {
const deferred = yield* $(Deferred.make());
const latch = yield* $(Deferred.make());
yield* $(Effect.asUnit(Queue.offer(queue, Effect.map(Deferred.await(deferred), Either.right))));
yield* $(Effect.forkScoped(withPermits(1)(Effect.zipRight(Effect.intoDeferred(deferred)(Effect.tapErrorCause(cause => Deferred.failCause(errorSignal, cause))(Effect.uninterruptibleMask(restore => Effect.flatMap(Effect.done)(Effect.raceFirst(Effect.exit(restore(f(outElem))))(Effect.exit(restore(Deferred.await(errorSignal)))))))))(Deferred.succeed(latch, void 0)))));
yield* $(Deferred.await(latch));
})))))));
yield* $(Effect.forkScoped(Effect.interruptible(Effect.forever(Effect.matchCauseEffect(pull, {
onFailure: cause => Queue.offer(queue, Effect.failCause(cause)),
onSuccess: either => Either.match(either, {
onLeft: outDone => {
const lock = withPermits(n);
return Effect.zipRight(Effect.interruptible(lock(Effect.unit)), Effect.asUnit(Queue.offer(queue, Effect.succeed(Either.left(outDone)))));
},
onRight: outElem => Effect.gen(function* ($) {
const deferred = yield* $(Deferred.make());
const latch = yield* $(Deferred.make());
yield* $(Effect.asUnit(Queue.offer(queue, Effect.map(Deferred.await(deferred), Either.right))));
yield* $(Effect.forkScoped(withPermits(1)(Effect.zipRight(Effect.intoDeferred(deferred)(Effect.tapErrorCause(cause => Deferred.failCause(errorSignal, cause))(Effect.uninterruptibleMask(restore =>
// TODO: remove
Effect.flatMap(exit => Effect.suspend(() => exit))(Effect.raceFirst(Effect.exit(restore(f(outElem))))(Effect.exit(restore(Deferred.await(errorSignal)))))))))(Deferred.succeed(latch, void 0)))));
yield* $(Deferred.await(latch));
})
})
})))));
return queue;

@@ -252,3 +287,9 @@ }))));

const mergeAllWith = (n, bufferSize = 16, mergeStrategy = _mergeStrategy.BackPressure()) => (channels, f) => unwrapScoped(Effect.map(([queue, input]) => {
const consumer = unwrap(Effect.matchCause(core.failCause, Either.match(core.succeedNow, outElem => core.flatMap(core.write(outElem), () => consumer)))(Effect.flatten(Queue.take(queue))));
const consumer = unwrap(Effect.matchCause({
onFailure: core.failCause,
onSuccess: Either.match({
onLeft: core.succeedNow,
onRight: outElem => core.flatMap(core.write(outElem), () => consumer)
})
})(Effect.flatten(Queue.take(queue))));
return core.embedInput(consumer, input);

@@ -258,4 +299,10 @@ })(Effect.gen(function* ($) {

const queueReader = fromInput(input);
const queue = yield* $(Effect.acquireRelease(Queue.bounded(bufferSize), Queue.shutdown));
const cancelers = yield* $(Effect.acquireRelease(Queue.unbounded(), Queue.shutdown));
const queue = yield* $(Effect.acquireRelease({
acquire: Queue.bounded(bufferSize),
release: queue => Queue.shutdown(queue)
}));
const cancelers = yield* $(Effect.acquireRelease({
acquire: Queue.unbounded(),
release: queue => Queue.shutdown(queue)
}));
const lastDone = yield* $(Ref.make(Option.none()));

@@ -265,22 +312,44 @@ const errorSignal = yield* $(Deferred.make());

const pull = yield* $(toPull(channels));
const evaluatePull = pull => Effect.catchAllCause(cause => Cause.isInterrupted(cause) ? Effect.failCause(cause) : Effect.asUnit(Effect.zipRight(Deferred.succeed(errorSignal, void 0))(Queue.offer(queue, Effect.failCause(cause)))))(Effect.flatMap(Option.match(() => Effect.unit(), outDone => Ref.update(lastDone, Option.match(() => Option.some(outDone), lastDone => Option.some(f(lastDone, outDone))))))(Effect.repeatUntil(Option.isSome)(Effect.flatMap(Either.match(done => Effect.succeed(Option.some(done)), outElem => Effect.as(Option.none())(Queue.offer(queue, Effect.succeed(Either.right(outElem))))))(pull))));
yield* $(Effect.forkScoped(Effect.repeatWhileEquals(true)(Effect.matchCauseEffect(pull, cause => Effect.zipRight(Effect.succeed(false))(Queue.offer(queue, Effect.failCause(cause))), Either.match(outDone => Effect.raceWith(withPermits(n)(Effect.unit()), (_, permitAcquisition) => Effect.as(false)(Fiber.interrupt(permitAcquisition)), (_, failureAwait) => Effect.zipRight(Effect.as(false)(Effect.flatMap(Option.match(() => Queue.offer(queue, Effect.succeed(Either.left(outDone))), lastDone => Queue.offer(queue, Effect.succeed(Either.left(f(lastDone, outDone))))))(Ref.get(lastDone))))(Fiber.interrupt(failureAwait)))(Deferred.await(errorSignal)), channel => _mergeStrategy.match(() => Effect.gen(function* ($) {
const latch = yield* $(Deferred.make());
const raceEffects = Effect.scoped(Effect.flatMap(pull => Effect.raceAwait(Deferred.await(errorSignal))(evaluatePull(pull)))(toPull(core.pipeTo(channel)(queueReader))));
yield* $(Effect.forkScoped(withPermits(1)(Effect.zipRight(raceEffects)(Deferred.succeed(latch, void 0)))));
yield* $(Deferred.await(latch));
const errored = yield* $(Deferred.isDone(errorSignal));
return !errored;
}), () => Effect.gen(function* ($) {
const canceler = yield* $(Deferred.make());
const latch = yield* $(Deferred.make());
const size = yield* $(Queue.size(cancelers));
yield* $(Effect.when(() => size >= n)(Effect.flatMap(_ => Deferred.succeed(_, void 0))(Queue.take(cancelers))));
yield* $(Queue.offer(cancelers, canceler));
const raceEffects = Effect.scoped(Effect.flatMap(pull => Effect.raceAwait(Deferred.await(canceler))(Effect.raceAwait(Deferred.await(errorSignal))(evaluatePull(pull))))(toPull(core.pipeTo(channel)(queueReader))));
yield* $(Effect.forkScoped(withPermits(1)(Effect.zipRight(raceEffects)(Deferred.succeed(latch, void 0)))));
yield* $(Deferred.await(latch));
const errored = yield* $(Deferred.isDone(errorSignal));
return !errored;
}))(mergeStrategy))))));
const evaluatePull = pull => Effect.catchAllCause(cause => Cause.isInterrupted(cause) ? Effect.failCause(cause) : Effect.asUnit(Effect.zipRight(Deferred.succeed(errorSignal, void 0))(Queue.offer(queue, Effect.failCause(cause)))))(Effect.flatMap(Option.match({
onNone: () => Effect.unit,
onSome: outDone => Ref.update(lastDone, Option.match({
onNone: () => Option.some(outDone),
onSome: lastDone => Option.some(f(lastDone, outDone))
}))
}))(Effect.repeatUntil(Option.isSome)(Effect.flatMap(pull, Either.match({
onLeft: done => Effect.succeed(Option.some(done)),
onRight: outElem => Effect.as(Queue.offer(queue, Effect.succeed(Either.right(outElem))), Option.none())
})))));
yield* $(Effect.forkScoped(Effect.repeatWhile(_Function.identity)(Effect.matchCauseEffect(pull, {
onFailure: cause => Effect.zipRight(Effect.succeed(false))(Queue.offer(queue, Effect.failCause(cause))),
onSuccess: Either.match({
onLeft: outDone => Effect.raceWith(Deferred.await(errorSignal), {
other: withPermits(n)(Effect.unit),
onSelfDone: (_, permitAcquisition) => Effect.as(false)(Fiber.interrupt(permitAcquisition)),
onOtherDone: (_, failureAwait) => Effect.zipRight(Effect.as(false)(Effect.flatMap(Option.match({
onNone: () => Queue.offer(queue, Effect.succeed(Either.left(outDone))),
onSome: lastDone => Queue.offer(queue, Effect.succeed(Either.left(f(lastDone, outDone))))
}))(Ref.get(lastDone))))(Fiber.interrupt(failureAwait))
}),
onRight: channel => _mergeStrategy.match(() => Effect.gen(function* ($) {
const latch = yield* $(Deferred.make());
const raceEffects = Effect.scoped(Effect.flatMap(pull => Effect.raceAwait(Deferred.await(errorSignal))(evaluatePull(pull)))(toPull(core.pipeTo(channel)(queueReader))));
yield* $(Effect.forkScoped(withPermits(1)(Effect.zipRight(raceEffects)(Deferred.succeed(latch, void 0)))));
yield* $(Deferred.await(latch));
const errored = yield* $(Deferred.isDone(errorSignal));
return !errored;
}), () => Effect.gen(function* ($) {
const canceler = yield* $(Deferred.make());
const latch = yield* $(Deferred.make());
const size = yield* $(Queue.size(cancelers));
yield* $(Effect.when(() => size >= n)(Effect.flatMap(_ => Deferred.succeed(_, void 0))(Queue.take(cancelers))));
yield* $(Queue.offer(cancelers, canceler));
const raceEffects = Effect.scoped(Effect.flatMap(pull => Effect.raceAwait(Deferred.await(canceler))(Effect.raceAwait(Deferred.await(errorSignal))(evaluatePull(pull))))(toPull(core.pipeTo(channel)(queueReader))));
yield* $(Effect.forkScoped(withPermits(1)(Effect.zipRight(raceEffects)(Deferred.succeed(latch, void 0)))));
yield* $(Deferred.await(latch));
const errored = yield* $(Deferred.isDone(errorSignal));
return !errored;
}))(mergeStrategy)
})
}))));
return [queue, input];

@@ -317,5 +386,17 @@ })));

}
return Effect.map(Fiber.await(fiber), Exit.match(cause => core.fromEffect(op.f(Exit.failCause(cause))), Either.match(done => core.fromEffect(op.f(Exit.succeed(done))), elem => zipRight(core.write(elem), go(single(op.f))))));
return Effect.map(Fiber.await(fiber), Exit.match({
onFailure: cause => core.fromEffect(op.f(Exit.failCause(cause))),
onSuccess: Either.match({
onLeft: done => core.fromEffect(op.f(Exit.succeed(done))),
onRight: elem => zipRight(core.write(elem), go(single(op.f)))
})
}));
};
return Exit.match(exit, cause => onDecision(done(Exit.failCause(cause))), Either.match(z => onDecision(done(Exit.succeed(z))), elem => Effect.succeed(core.flatMap(core.write(elem), () => core.flatMap(core.fromEffect(Effect.forkDaemon(pull)), leftFiber => go(both(leftFiber, fiber)))))));
return Exit.match(exit, {
onFailure: cause => onDecision(done(Exit.failCause(cause))),
onSuccess: Either.match({
onLeft: z => onDecision(done(Exit.succeed(z))),
onRight: elem => Effect.succeed(core.flatMap(core.write(elem), () => core.flatMap(core.fromEffect(Effect.forkDaemon(pull)), leftFiber => go(both(leftFiber, fiber)))))
})
});
};

@@ -328,11 +409,27 @@ const go = state => {

const rightJoin = Effect.interruptible(Fiber.join(state.right));
return unwrap(Effect.raceWith(leftJoin, rightJoin, (leftExit, rf) => Effect.zipRight(Fiber.interrupt(rf), handleSide(leftExit, state.right, pullL)(leftDone, mergeState.BothRunning, f => mergeState.LeftDone(f))), (rightExit, lf) => Effect.zipRight(Fiber.interrupt(lf), handleSide(rightExit, state.left, pullR)(rightDone, (left, right) => mergeState.BothRunning(right, left), f => mergeState.RightDone(f)))));
return unwrap(Effect.raceWith(leftJoin, {
other: rightJoin,
onSelfDone: (leftExit, rf) => Effect.zipRight(Fiber.interrupt(rf), handleSide(leftExit, state.right, pullL)(leftDone, mergeState.BothRunning, f => mergeState.LeftDone(f))),
onOtherDone: (rightExit, lf) => Effect.zipRight(Fiber.interrupt(lf), handleSide(rightExit, state.left, pullR)(rightDone, (left, right) => mergeState.BothRunning(right, left), f => mergeState.RightDone(f)))
}));
}
case MergeStateOpCodes.OP_LEFT_DONE:
{
return unwrap(Effect.map(Effect.exit(pullR), Exit.match(cause => core.fromEffect(state.f(Exit.failCause(cause))), Either.match(done => core.fromEffect(state.f(Exit.succeed(done))), elem => core.flatMap(core.write(elem), () => go(mergeState.LeftDone(state.f)))))));
return unwrap(Effect.map(Effect.exit(pullR), Exit.match({
onFailure: cause => core.fromEffect(state.f(Exit.failCause(cause))),
onSuccess: Either.match({
onLeft: done => core.fromEffect(state.f(Exit.succeed(done))),
onRight: elem => core.flatMap(core.write(elem), () => go(mergeState.LeftDone(state.f)))
})
})));
}
case MergeStateOpCodes.OP_RIGHT_DONE:
{
return unwrap(Effect.map(Effect.exit(pullL), Exit.match(cause => core.fromEffect(state.f(Exit.failCause(cause))), Either.match(done => core.fromEffect(state.f(Exit.succeed(done))), elem => core.flatMap(core.write(elem), () => go(mergeState.RightDone(state.f)))))));
return unwrap(Effect.map(Effect.exit(pullL), Exit.match({
onFailure: cause => core.fromEffect(state.f(Exit.failCause(cause))),
onSuccess: Either.match({
onLeft: done => core.fromEffect(state.f(Exit.succeed(done))),
onRight: elem => core.flatMap(core.write(elem), () => go(mergeState.RightDone(state.f)))
})
})));
}

@@ -346,3 +443,3 @@ }

exports.mergeWith = mergeWith;
const never = () => core.fromEffect(Effect.never());
const never = () => core.fromEffect(Effect.never);
/** @internal */

@@ -424,5 +521,8 @@ exports.never = never;

exports.toHub = toHub;
const toPull = self => Effect.map(Effect.acquireRelease(Effect.sync(() => new executor.ChannelExecutor(self, void 0, _Function.identity)), (exec, exit) => {
const finalize = exec.close(exit);
return finalize === undefined ? Effect.unit() : finalize;
const toPull = self => Effect.map(Effect.acquireRelease({
acquire: Effect.sync(() => new executor.ChannelExecutor(self, void 0, _Function.identity)),
release: (exec, exit) => {
const finalize = exec.close(exit);
return finalize === undefined ? Effect.unit : finalize;
}
}), exec => Effect.suspend(() => interpretToPull(exec.run(), exec)));

@@ -436,3 +536,6 @@ /** @internal */

{
return Exit.match(exec.getDone(), Effect.failCause, done => Effect.succeed(Either.left(done)));
return Exit.match(exec.getDone(), {
onFailure: Effect.failCause,
onSuccess: done => Effect.succeed(Either.left(done))
});
}

@@ -489,3 +592,3 @@ case ChannelStateOpCodes.OP_EMIT:

exports.zipRight = zipRight;
const zipPar = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => mergeWith(self, that, exit1 => mergeDecision.Await(exit2 => Effect.done(Exit.zip(exit1, exit2))), exit2 => mergeDecision.Await(exit1 => Effect.done(Exit.zip(exit1, exit2)))));
const zipPar = /*#__PURE__*/(0, _Function.dual)(2, (self, that) => mergeWith(self, that, exit1 => mergeDecision.Await(exit2 => Effect.suspend(() => Exit.zip(exit1, exit2))), exit2 => mergeDecision.Await(exit1 => Effect.suspend(() => Exit.zip(exit1, exit2)))));
/** @internal */

@@ -492,0 +595,0 @@ exports.zipPar = zipPar;

@@ -78,3 +78,6 @@ "use strict";

{
return Exit.match(inputExecutor.getDone(), cause => bridgeInput.error(cause), value => bridgeInput.done(value));
return Exit.match(inputExecutor.getDone(), {
onFailure: cause => bridgeInput.error(cause),
onSuccess: value => bridgeInput.done(value)
});
}

@@ -87,3 +90,6 @@ case ChannelStateOpCodes.OP_EMIT:

{
return Effect.matchCauseEffect(state.effect, cause => bridgeInput.error(cause), () => drainer());
return Effect.matchCauseEffect(state.effect, {
onFailure: cause => bridgeInput.error(cause),
onSuccess: () => drainer()
});
}

@@ -98,3 +104,3 @@ case ChannelStateOpCodes.OP_READ:

const effect = this.restorePipe(exit, inputExecutor);
return effect !== undefined ? effect : Effect.unit();
return effect !== undefined ? effect : Effect.unit;
}))))));

@@ -107,3 +113,3 @@ }

const executor = new ChannelExecutor(this._currentChannel.value(), this._providedEnv, effect => Effect.sync(() => {
const prevLastClose = this._closeLastSubstream === undefined ? Effect.unit() : this._closeLastSubstream;
const prevLastClose = this._closeLastSubstream === undefined ? Effect.unit : this._closeLastSubstream;
this._closeLastSubstream = Effect.zipRight(effect)(prevLastClose);

@@ -144,9 +150,12 @@ }));

const effect = this._providedEnv === undefined ? this._currentChannel.effect() : Effect.provideContext(this._providedEnv)(this._currentChannel.effect());
result = ChannelState.FromEffect(Effect.matchCauseEffect(cause => {
const state = this.doneHalt(cause);
return state !== undefined && ChannelState.isFromEffect(state) ? state.effect : Effect.unit();
}, value => {
const state = this.doneSucceed(value);
return state !== undefined && ChannelState.isFromEffect(state) ? state.effect : Effect.unit();
})(effect));
result = ChannelState.FromEffect(Effect.matchCauseEffect(effect, {
onFailure: cause => {
const state = this.doneHalt(cause);
return state !== undefined && ChannelState.isFromEffect(state) ? state.effect : Effect.unit;
},
onSuccess: value => {
const state = this.doneSucceed(value);
return state !== undefined && ChannelState.isFromEffect(state) ? state.effect : Effect.unit;
}
}));
break;

@@ -162,3 +171,3 @@ }

const effect = this.restorePipe(exit, previousInput);
return effect !== undefined ? effect : Effect.unit();
return effect !== undefined ? effect : Effect.unit;
});

@@ -251,3 +260,3 @@ this._currentChannel = this._currentChannel.right();

}
const effect = finalizers.length === 0 ? Effect.unit() : runFinalizers(finalizers, exit);
const effect = finalizers.length === 0 ? Effect.unit : runFinalizers(finalizers, exit);
this.storeInProgressFinalizer(effect);

@@ -275,3 +284,3 @@ return effect;

}
return Effect.unit();
return Effect.unit;
}

@@ -293,3 +302,6 @@ close(exit) {

}
return Effect.flatMap(Effect.done)(Effect.uninterruptible(Effect.map(([[exit1, exit2], exit3]) => Exit.zipRight(exit3)(Exit.zipRight(exit2)(exit1)))(Effect.zip(Effect.exit(ifNotNull(closeSelf)))(Effect.zip(Effect.exit(ifNotNull(runInProgressFinalizers)))(Effect.exit(ifNotNull(closeSubexecutors)))))));
return (
// TODO: remove
Effect.flatMap(exit => Effect.suspend(() => exit))(Effect.uninterruptible(Effect.map(([[exit1, exit2], exit3]) => Exit.zipRight(exit3)(Exit.zipRight(exit2)(exit1)))(Effect.zip(Effect.exit(ifNotNull(closeSelf)))(Effect.zip(Effect.exit(ifNotNull(runInProgressFinalizers)))(Effect.exit(ifNotNull(closeSubexecutors)))))))
);
}

@@ -351,8 +363,11 @@ doneSucceed(value) {

runBracketOut(bracketOut) {
const effect = Effect.uninterruptible(Effect.matchCauseEffect(cause => Effect.sync(() => {
this._currentChannel = core.failCause(cause);
}), out => Effect.sync(() => {
this.addFinalizer(exit => this.provide(bracketOut.finalizer(out, exit)));
this._currentChannel = core.write(out);
}))(this.provide(bracketOut.acquire())));
const effect = Effect.uninterruptible(Effect.matchCauseEffect(this.provide(bracketOut.acquire()), {
onFailure: cause => Effect.sync(() => {
this._currentChannel = core.failCause(cause);
}),
onSuccess: out => Effect.sync(() => {
this.addFinalizer(exit => this.provide(bracketOut.finalizer(out, exit)));
this._currentChannel = core.write(out);
})
}));
return ChannelState.FromEffect(effect);

@@ -401,9 +416,17 @@ }

finishWithExit(exit) {
const state = Exit.match(cause => this.doneHalt(cause), value => this.doneSucceed(value))(exit);
const state = Exit.match(exit, {
onFailure: cause => this.doneHalt(cause),
onSuccess: value => this.doneSucceed(value)
});
this._activeSubexecutor = undefined;
return state === undefined ? Effect.unit() : ChannelState.effect(state);
return state === undefined ? Effect.unit : ChannelState.effect(state);
}
finishSubexecutorWithCloseEffect(subexecutorDone, ...closeFuncs) {
this.addFinalizer(() => Effect.forEachDiscard(closeFunc => Effect.flatMap(closeEffect => closeEffect !== undefined ? closeEffect : Effect.unit())(Effect.sync(() => closeFunc(subexecutorDone))))(closeFuncs));
const state = Exit.match(cause => this.doneHalt(cause), value => this.doneSucceed(value))(subexecutorDone);
this.addFinalizer(() => Effect.forEach(closeFunc => Effect.flatMap(closeEffect => closeEffect !== undefined ? closeEffect : Effect.unit)(Effect.sync(() => closeFunc(subexecutorDone))), {
discard: true
})(closeFuncs));
const state = Exit.match({
onFailure: cause => this.doneHalt(cause),
onSuccess: value => this.doneSucceed(value)
})(subexecutorDone);
this._activeSubexecutor = undefined;

@@ -448,8 +471,11 @@ return state;

return undefined;
}, Exit.match(cause => {
const state = this.handleSubexecutorFailure(childExecutor, parentSubexecutor, cause);
return state === undefined ? undefined : ChannelState.effectOrUndefinedIgnored(state);
}, doneValue => {
this.finishWithDoneValue(childExecutor, parentSubexecutor, doneValue);
return undefined;
}, Exit.match({
onFailure: cause => {
const state = this.handleSubexecutorFailure(childExecutor, parentSubexecutor, cause);
return state === undefined ? undefined : ChannelState.effectOrUndefinedIgnored(state);
},
onSuccess: doneValue => {
this.finishWithDoneValue(childExecutor, parentSubexecutor, doneValue);
return undefined;
}
}));

@@ -497,3 +523,3 @@ }

return ChannelState.Read(subexecutor.upstreamExecutor, effect => {
const closeLastSubstream = this._closeLastSubstream === undefined ? Effect.unit() : this._closeLastSubstream;
const closeLastSubstream = this._closeLastSubstream === undefined ? Effect.unit : this._closeLastSubstream;
this._closeLastSubstream = undefined;

@@ -567,5 +593,5 @@ return Effect.zipRight(effect)(this._executeCloseLastSubstream(closeLastSubstream));

exports.ChannelExecutor = ChannelExecutor;
const ifNotNull = effect => effect !== undefined ? effect : Effect.unit();
const ifNotNull = effect => effect !== undefined ? effect : Effect.unit;
const runFinalizers = (finalizers, exit) => {
return Effect.flatMap(exit => Effect.done(exit))(Effect.map(exits => Option.getOrElse(() => Exit.unit())(Exit.collectAll(exits)))(Effect.forEach(finalizers, fin => Effect.exit(fin(exit)))));
return Effect.flatMap(exit => Effect.suspend(() => exit))(Effect.map(exits => Option.getOrElse(() => Exit.unit)(Exit.all(exits)))(Effect.forEach(finalizers, fin => Effect.exit(fin(exit)))));
};

@@ -591,3 +617,6 @@ /**

}
return Effect.matchCauseEffect(onFailure, onSuccess)(emitEffect);
return Effect.matchCauseEffect({
onFailure,
onSuccess
})(emitEffect);
}

@@ -597,3 +626,6 @@ if (emitEffect === undefined) {

}
return Effect.matchCauseEffect(onFailure, () => read())(emitEffect);
return Effect.matchCauseEffect({
onFailure,
onSuccess: () => read()
})(emitEffect);
}

@@ -607,3 +639,6 @@ case ChannelStateOpCodes.OP_DONE:

}
return Effect.matchCauseEffect(onFailure, () => onSuccess())(doneEffect);
return Effect.matchCauseEffect({
onFailure,
onSuccess
})(doneEffect);
}

@@ -613,3 +648,6 @@ if (doneEffect === undefined) {

}
return Effect.matchCauseEffect(onFailure, () => read())(doneEffect);
return Effect.matchCauseEffect({
onFailure,
onSuccess: () => read()
})(doneEffect);
}

@@ -619,5 +657,8 @@ case ChannelStateOpCodes.OP_FROM_EFFECT:

readStack.push(current);
return Effect.matchCauseEffect(onFailure, () => read())(Effect.catchAllCause(cause => Effect.suspend(() => {
return Effect.matchCauseEffect({
onFailure,
onSuccess: () => read()
})(Effect.catchAllCause(cause => Effect.suspend(() => {
const doneEffect = current.onDone(Exit.failCause(cause));
return doneEffect === undefined ? Effect.unit() : doneEffect;
return doneEffect === undefined ? Effect.unit : doneEffect;
}))(current.onEffect(state.effect)));

@@ -641,10 +682,14 @@ }

const runScoped = self => {
const run = (channelDeferred, scopeDeferred, scope) => Effect.acquireUseRelease(Effect.sync(() => new ChannelExecutor(self, void 0, _Function.identity)), exec => Effect.suspend(() => Effect.zipLeft(Deferred.await(scopeDeferred))(Effect.zipRight(Deferred.await(channelDeferred))(Effect.intoDeferred(channelDeferred)(runScopedInterpret(exec.run(), exec))))), (exec, exit) => {
const finalize = exec.close(exit);
if (finalize === undefined) {
return Effect.unit();
const run = (channelDeferred, scopeDeferred, scope) => Effect.acquireUseRelease({
acquire: Effect.sync(() => new ChannelExecutor(self, void 0, _Function.identity)),
use: exec => Effect.suspend(() => Effect.zipLeft(Deferred.await(scopeDeferred))(Effect.zipRight(Deferred.await(channelDeferred))(Effect.intoDeferred(channelDeferred)(runScopedInterpret(exec.run(), exec))))),
release: (exec, exit) => {
const finalize = exec.close(exit);
if (finalize === undefined) {
return Effect.unit;
}
return Effect.tapErrorCause(finalize, cause => Scope.addFinalizer(scope, Effect.failCause(cause)));
}
return Effect.tapErrorCause(finalize, cause => Scope.addFinalizer(scope, Effect.failCause(cause)));
});
return Effect.uninterruptibleMask(restore => Effect.flatMap(Effect.scope(), parent => Effect.flatMap(([child, channelDeferred, scopeDeferred]) => Effect.flatMap(fiber => Effect.zipLeft(Fiber.inheritAll(fiber))(Effect.zipRight(restore(Deferred.await(channelDeferred)))(Effect.addFinalizer(() => Deferred.succeed(scopeDeferred, void 0)))))(Effect.forkScoped(restore(run(channelDeferred, scopeDeferred, child)))))(Effect.all(Scope.fork(parent, ExecutionStrategy.sequential), Deferred.make(), Deferred.make()))));
return Effect.uninterruptibleMask(restore => Effect.flatMap(Effect.scope, parent => Effect.flatMap(([child, channelDeferred, scopeDeferred]) => Effect.flatMap(fiber => Effect.zipLeft(Fiber.inheritAll(fiber))(Effect.zipRight(restore(Deferred.await(channelDeferred)))(Effect.addFinalizer(() => Deferred.succeed(scopeDeferred, void 0)))))(Effect.forkScoped(restore(run(channelDeferred, scopeDeferred, child)))))(Effect.all(Scope.fork(parent, ExecutionStrategy.sequential), Deferred.make(), Deferred.make()))));
};

@@ -667,3 +712,3 @@ /** @internal */

{
return Effect.done(exec.getDone());
return Effect.suspend(() => exec.getDone());
}

@@ -670,0 +715,0 @@ case ChannelStateOpCodes.OP_READ:

@@ -72,3 +72,3 @@ "use strict";

exports.isRead = isRead;
const effect = self => isFromEffect(self) ? self.effect : Effect.unit();
const effect = self => isFromEffect(self) ? self.effect : Effect.unit;
/** @internal */

@@ -75,0 +75,0 @@ exports.effect = effect;

@@ -7,3 +7,2 @@ "use strict";

exports.make = void 0;
var _Debug = /*#__PURE__*/require("@effect/data/Debug");
var Either = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Either"));

@@ -51,121 +50,123 @@ var Cause = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Cause"));

awaitRead() {
return (0, _Debug.bodyWithTrace)(trace => {
return Effect.flatten(Ref.modify(this.ref, state => state._tag === OP_STATE_EMPTY ? [Deferred.await(state.notifyProducer), state] : [Effect.unit(), state])).traced(trace);
});
return Effect.flatten(Ref.modify(this.ref, state => state._tag === OP_STATE_EMPTY ? [Deferred.await(state.notifyProducer), state] : [Effect.unit, state]));
}
close() {
return (0, _Debug.bodyWithTrace)(trace => {
return Effect.fiberIdWith(fiberId => this.error(Cause.interrupt(fiberId))).traced(trace);
});
return Effect.fiberIdWith(fiberId => this.error(Cause.interrupt(fiberId)));
}
done(value) {
return (0, _Debug.bodyWithTrace)(trace => {
return Effect.flatten(Ref.modify(this.ref, state => {
switch (state._tag) {
case OP_STATE_EMPTY:
{
return [Deferred.await(state.notifyProducer), state];
}
case OP_STATE_EMIT:
{
return [Effect.forEachDiscard(deferred => Deferred.succeed(deferred, Either.left(value)))(state.notifyConsumers), stateDone(value)];
}
case OP_STATE_ERROR:
{
return [Effect.interrupt(), state];
}
case OP_STATE_DONE:
{
return [Effect.interrupt(), state];
}
}
})).traced(trace);
});
return Effect.flatten(Ref.modify(this.ref, state => {
switch (state._tag) {
case OP_STATE_EMPTY:
{
return [Deferred.await(state.notifyProducer), state];
}
case OP_STATE_EMIT:
{
return [Effect.forEach(state.notifyConsumers, deferred => Deferred.succeed(deferred, Either.left(value)), {
discard: true
}), stateDone(value)];
}
case OP_STATE_ERROR:
{
return [Effect.interrupt, state];
}
case OP_STATE_DONE:
{
return [Effect.interrupt, state];
}
}
}));
}
emit(element) {
return (0, _Debug.bodyWithTrace)(trace => {
return Effect.flatMap(deferred => Effect.flatten(Ref.modify(this.ref, state => {
switch (state._tag) {
case OP_STATE_EMPTY:
{
return [Deferred.await(state.notifyProducer), state];
return Effect.flatMap(Deferred.make(), deferred => Effect.flatten(Ref.modify(this.ref, state => {
switch (state._tag) {
case OP_STATE_EMPTY:
{
return [Deferred.await(state.notifyProducer), state];
}
case OP_STATE_EMIT:
{
const notifyConsumer = state.notifyConsumers[0];
const notifyConsumers = state.notifyConsumers.slice(1);
if (notifyConsumer !== undefined) {
return [Deferred.succeed(notifyConsumer, Either.right(element)), notifyConsumers.length === 0 ? stateEmpty(deferred) : stateEmit(notifyConsumers)];
}
case OP_STATE_EMIT:
{
const notifyConsumer = state.notifyConsumers[0];
const notifyConsumers = state.notifyConsumers.slice(1);
if (notifyConsumer !== undefined) {
return [Deferred.succeed(notifyConsumer, Either.right(element)), notifyConsumers.length === 0 ? stateEmpty(deferred) : stateEmit(notifyConsumers)];
}
throw new Error("Bug: Channel.SingleProducerAsyncInput.emit - Queue was empty! Please report an issue at https://github.com/Effect-TS/stream/issues");
}
case OP_STATE_ERROR:
{
return [Effect.interrupt(), state];
}
case OP_STATE_DONE:
{
return [Effect.interrupt(), state];
}
}
})))(Deferred.make()).traced(trace);
});
throw new Error("Bug: Channel.SingleProducerAsyncInput.emit - Queue was empty! Please report an issue at https://github.com/Effect-TS/stream/issues");
}
case OP_STATE_ERROR:
{
return [Effect.interrupt, state];
}
case OP_STATE_DONE:
{
return [Effect.interrupt, state];
}
}
})));
}
error(cause) {
return (0, _Debug.bodyWithTrace)(trace => {
return Effect.flatten(Ref.modify(this.ref, state => {
switch (state._tag) {
case OP_STATE_EMPTY:
{
return [Deferred.await(state.notifyProducer), state];
}
case OP_STATE_EMIT:
{
return [Effect.forEachDiscard(state.notifyConsumers, deferred => Deferred.failCause(deferred, cause)), stateError(cause)];
}
case OP_STATE_ERROR:
{
return [Effect.interrupt(), state];
}
case OP_STATE_DONE:
{
return [Effect.interrupt(), state];
}
}
})).traced(trace);
});
return Effect.flatten(Ref.modify(this.ref, state => {
switch (state._tag) {
case OP_STATE_EMPTY:
{
return [Deferred.await(state.notifyProducer), state];
}
case OP_STATE_EMIT:
{
return [Effect.forEach(state.notifyConsumers, deferred => Deferred.failCause(deferred, cause), {
discard: true
}), stateError(cause)];
}
case OP_STATE_ERROR:
{
return [Effect.interrupt, state];
}
case OP_STATE_DONE:
{
return [Effect.interrupt, state];
}
}
}));
}
take() {
return (0, _Debug.bodyWithTrace)(trace => {
return this.takeWith(cause => Exit.failCause(Cause.map(cause, Either.left)), elem => Exit.succeed(elem), done => Exit.fail(Either.right(done))).traced(trace);
});
return this.takeWith(cause => Exit.failCause(Cause.map(cause, Either.left)), elem => Exit.succeed(elem), done => Exit.fail(Either.right(done)));
}
takeWith(onError, onElement, onDone) {
return (0, _Debug.bodyWithTrace)(trace => {
return Effect.flatMap(deferred => Effect.flatten(Ref.modify(this.ref, state => {
switch (state._tag) {
case OP_STATE_EMPTY:
{
return [Effect.zipRight(Deferred.succeed(state.notifyProducer, void 0), Effect.matchCause(Deferred.await(deferred), onError, Either.match(onDone, onElement))), stateEmit([deferred])];
}
case OP_STATE_EMIT:
{
return [Effect.matchCause(Deferred.await(deferred), onError, Either.match(onDone, onElement)), stateEmit([...state.notifyConsumers, deferred])];
}
case OP_STATE_ERROR:
{
return [Effect.succeed(onError(state.cause)), state];
}
case OP_STATE_DONE:
{
return [Effect.succeed(onDone(state.done)), state];
}
}
})))(Deferred.make()).traced(trace);
});
return Effect.flatMap(Deferred.make(), deferred => Effect.flatten(Ref.modify(this.ref, state => {
switch (state._tag) {
case OP_STATE_EMPTY:
{
return [Effect.zipRight(Deferred.succeed(state.notifyProducer, void 0), Effect.matchCause(Deferred.await(deferred), {
onFailure: onError,
onSuccess: Either.match({
onLeft: onDone,
onRight: onElement
})
})), stateEmit([deferred])];
}
case OP_STATE_EMIT:
{
return [Effect.matchCause(Deferred.await(deferred), {
onFailure: onError,
onSuccess: Either.match({
onLeft: onDone,
onRight: onElement
})
}), stateEmit([...state.notifyConsumers, deferred])];
}
case OP_STATE_ERROR:
{
return [Effect.succeed(onError(state.cause)), state];
}
case OP_STATE_DONE:
{
return [Effect.succeed(onDone(state.done)), state];
}
}
})));
}
}
/** @internal */
const make = /*#__PURE__*/(0, _Debug.methodWithTrace)(trace => () => Effect.map(ref => new SingleProducerAsyncInputImpl(ref))(Effect.flatMap(deferred => Ref.make(stateEmpty(deferred)))(Deferred.make())).traced(trace));
const make = () => Effect.map(ref => new SingleProducerAsyncInputImpl(ref))(Effect.flatMap(deferred => Ref.make(stateEmpty(deferred)))(Deferred.make()));
exports.make = make;
//# sourceMappingURL=singleProducerAsyncInput.js.map

@@ -7,3 +7,2 @@ "use strict";

exports.PullFromUpstream = exports.PullFromChild = exports.OP_PULL_FROM_UPSTREAM = exports.OP_PULL_FROM_CHILD = exports.OP_EMIT = exports.OP_DRAIN_CHILD_EXECUTORS = exports.Emit = exports.DrainChildExecutors = void 0;
var _Debug = /*#__PURE__*/require("@effect/data/Debug");
var Effect = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Effect"));

@@ -39,15 +38,13 @@ var Exit = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Exit"));

close(exit) {
return (0, _Debug.bodyWithTrace)(trace => {
const fin1 = this.childExecutor.close(exit);
const fin2 = this.parentSubexecutor.close(exit);
if (fin1 !== undefined && fin2 !== undefined) {
return Effect.zipWith(Effect.exit(fin2), (exit1, exit2) => Exit.zipRight(exit2)(exit1))(Effect.exit(fin1)).traced(trace);
} else if (fin1 !== undefined) {
return fin1.traced(trace);
} else if (fin2 !== undefined) {
return fin2.traced(trace);
} else {
return undefined;
}
});
const fin1 = this.childExecutor.close(exit);
const fin2 = this.parentSubexecutor.close(exit);
if (fin1 !== undefined && fin2 !== undefined) {
return Effect.zipWith(Effect.exit(fin1), Effect.exit(fin2), (exit1, exit2) => Exit.zipRight(exit2)(exit1));
} else if (fin1 !== undefined) {
return fin1;
} else if (fin2 !== undefined) {
return fin2;
} else {
return undefined;
}
}

@@ -78,18 +75,16 @@ enqueuePullFromChild(_child) {

close(exit) {
return (0, _Debug.bodyWithTrace)(trace => {
const fin1 = this.upstreamExecutor.close(exit);
const fins = [...this.activeChildExecutors.map(child => child !== undefined ? child.childExecutor.close(exit) : undefined), fin1];
const result = fins.reduce((acc, next) => {
if (acc !== undefined && next !== undefined) {
return Effect.zipWith(Effect.exit(next), (exit1, exit2) => Exit.zipRight(exit2)(exit1))(acc);
} else if (acc !== undefined) {
return acc;
} else if (next !== undefined) {
return Effect.exit(next);
} else {
return undefined;
}
}, undefined);
return result === undefined ? result : result.traced(trace);
});
const fin1 = this.upstreamExecutor.close(exit);
const fins = [...this.activeChildExecutors.map(child => child !== undefined ? child.childExecutor.close(exit) : undefined), fin1];
const result = fins.reduce((acc, next) => {
if (acc !== undefined && next !== undefined) {
return Effect.zipWith(acc, Effect.exit(next), (exit1, exit2) => Exit.zipRight(exit1, exit2));
} else if (acc !== undefined) {
return acc;
} else if (next !== undefined) {
return Effect.exit(next);
} else {
return undefined;
}
}, undefined);
return result === undefined ? result : result;
}

@@ -119,18 +114,16 @@ enqueuePullFromChild(child) {

close(exit) {
return (0, _Debug.bodyWithTrace)(trace => {
const fin1 = this.upstreamExecutor.close(exit);
const fins = [...this.activeChildExecutors.map(child => child !== undefined ? child.childExecutor.close(exit) : undefined), fin1];
const result = fins.reduce((acc, next) => {
if (acc !== undefined && next !== undefined) {
return Effect.zipWith(Effect.exit(next), (exit1, exit2) => Exit.zipRight(exit2)(exit1))(acc);
} else if (acc !== undefined) {
return acc;
} else if (next !== undefined) {
return Effect.exit(next);
} else {
return undefined;
}
}, undefined);
return result === undefined ? result : result.traced(trace);
});
const fin1 = this.upstreamExecutor.close(exit);
const fins = [...this.activeChildExecutors.map(child => child !== undefined ? child.childExecutor.close(exit) : undefined), fin1];
const result = fins.reduce((acc, next) => {
if (acc !== undefined && next !== undefined) {
return Effect.zipWith(acc, Effect.exit(next), (exit1, exit2) => Exit.zipRight(exit1, exit2));
} else if (acc !== undefined) {
return acc;
} else if (next !== undefined) {
return Effect.exit(next);
} else {
return undefined;
}
}, undefined);
return result === undefined ? result : result;
}

@@ -150,6 +143,4 @@ enqueuePullFromChild(child) {

close(exit) {
return (0, _Debug.bodyWithTrace)(trace => {
const result = this.next.close(exit);
return result === undefined ? result : result.traced(trace);
});
const result = this.next.close(exit);
return result === undefined ? result : result;
}

@@ -156,0 +147,0 @@ enqueuePullFromChild(_child) {

@@ -200,3 +200,6 @@ "use strict";

exports.readOrFail = readOrFail;
const readWith = (input, error, done) => readWithCause(input, cause => Either.match(Cause.failureOrCause(cause), error, failCause), done);
const readWith = (input, error, done) => readWithCause(input, cause => Either.match(Cause.failureOrCause(cause), {
onLeft: error,
onRight: failCause
}), done);
/** @internal */

@@ -203,0 +206,0 @@ exports.readWith = readWith;

@@ -73,6 +73,12 @@ "use strict";

const decider = yield* $(Deferred.make());
const output = yield* $(Effect.acquireRelease(Queue.bounded(bufferSize), queue => Queue.shutdown(queue)));
const output = yield* $(Effect.acquireRelease({
acquire: Queue.bounded(bufferSize),
release: queue => Queue.shutdown(queue)
}));
const ref = yield* $(Ref.make(new Map()));
const add = yield* $(stream.distributedWithDynamicCallback(bufferSize, ([key, value]) => Effect.flatMap(f => f(key, value))(Deferred.await(decider)), exit => Queue.offer(output, exit))(stream.mapEffect(self, f)));
yield* $(Deferred.succeed(decider, (key, _) => Effect.flatMap(Option.match(() => Effect.flatMap(([index, queue]) => Effect.zipRight(Effect.as(n => n === index)(Queue.offer(output, Exit.succeed([key, mapDequeue(queue, exit => new take.TakeImpl(Exit.map(tuple => Chunk.of(tuple[1]))(exit)))]))))(Ref.update(ref, map => map.set(key, index))))(add), index => Effect.succeed(n => n === index)))(Effect.map(map => Option.fromNullable(map.get(key)))(Ref.get(ref)))));
const add = yield* $(stream.distributedWithDynamicCallback(bufferSize, ([key, value]) => Effect.flatMap(Deferred.await(decider), f => f(key, value)), exit => Queue.offer(output, exit))(stream.mapEffect(self, f)));
yield* $(Deferred.succeed(decider, (key, _) => Effect.flatMap(Option.match({
onNone: () => Effect.flatMap(add, ([index, queue]) => Effect.zipRight(Ref.update(ref, map => map.set(key, index)), Effect.as(n => n === index)(Queue.offer(output, Exit.succeed([key, mapDequeue(queue, exit => new take.TakeImpl(Exit.map(tuple => Chunk.of(tuple[1]))(exit)))]))))),
onSome: index => Effect.succeed(n => n === index)
}))(Effect.map(map => Option.fromNullable(map.get(key)))(Ref.get(ref)))));
return stream.flattenExitOption(stream.fromQueueWithShutdown(output));

@@ -99,2 +105,5 @@ }))));

}
isActive() {
return this.dequeue.isActive();
}
isShutdown() {

@@ -137,12 +146,19 @@ return Queue.isShutdown(this.dequeue);

const groupByKeyBuffer = /*#__PURE__*/(0, _Function.dual)(3, (self, f, bufferSize) => {
const loop = (map, outerQueue) => core.readWithCause(input => core.flatMap(() => loop(map, outerQueue))(core.fromEffect(Effect.forEachDiscard(([key, values]) => {
const loop = (map, outerQueue) => core.readWithCause(input => core.flatMap(() => loop(map, outerQueue))(core.fromEffect(Effect.forEach(([key, values]) => {
const innerQueue = map.get(key);
if (innerQueue === undefined) {
return Effect.flatMap(innerQueue => Effect.zipRight(Effect.catchSomeCause(cause => Cause.isInterruptedOnly(cause) ? Option.some(Effect.unit()) : Option.none())(Queue.offer(innerQueue, take.chunk(values))))(Effect.zipRight(Queue.offer(outerQueue, take.of([key, innerQueue])))(Effect.sync(() => {
return Effect.flatMap(innerQueue => Effect.zipRight(Effect.catchSomeCause(cause => Cause.isInterruptedOnly(cause) ? Option.some(Effect.unit) : Option.none())(Queue.offer(innerQueue, take.chunk(values))))(Effect.zipRight(Queue.offer(outerQueue, take.of([key, innerQueue])))(Effect.sync(() => {
map.set(key, innerQueue);
}))))(Queue.bounded(bufferSize));
}
return Effect.catchSomeCause(cause => Cause.isInterruptedOnly(cause) ? Option.some(Effect.unit()) : Option.none())(Queue.offer(innerQueue, take.chunk(values)));
})(groupByIterable(f)(input)))), cause => core.fromEffect(Queue.offer(outerQueue, take.failCause(cause))), () => core.fromEffect(Effect.zipRight(Queue.offer(outerQueue, take.end))(Effect.forEachDiscard(([_, innerQueue]) => Effect.catchSomeCause(cause => Cause.isInterruptedOnly(cause) ? Option.some(Effect.unit()) : Option.none())(Queue.offer(innerQueue, take.end)))(map.entries()))));
return make(stream.unwrapScoped(Effect.flatMap(map => Effect.flatMap(queue => Effect.as(stream.flattenTake(stream.fromQueueWithShutdown(queue)))(Effect.forkScoped(channelExecutor.runScoped(channel.drain(core.pipeTo(loop(map, queue))(stream.toChannel(self)))))))(Effect.acquireRelease(Queue.unbounded(), queue => Queue.shutdown(queue))))(Effect.sync(() => new Map()))));
return Effect.catchSomeCause(cause => Cause.isInterruptedOnly(cause) ? Option.some(Effect.unit) : Option.none())(Queue.offer(innerQueue, take.chunk(values)));
}, {
discard: true
})(groupByIterable(f)(input)))), cause => core.fromEffect(Queue.offer(outerQueue, take.failCause(cause))), () => core.fromEffect(Effect.zipRight(Queue.offer(outerQueue, take.end))(Effect.forEach(([_, innerQueue]) => Effect.catchSomeCause(cause => Cause.isInterruptedOnly(cause) ? Option.some(Effect.unit) : Option.none())(Queue.offer(innerQueue, take.end)), {
discard: true
})(map.entries()))));
return make(stream.unwrapScoped(Effect.flatMap(map => Effect.flatMap(queue => Effect.as(stream.flattenTake(stream.fromQueueWithShutdown(queue)))(Effect.forkScoped(channelExecutor.runScoped(channel.drain(core.pipeTo(loop(map, queue))(stream.toChannel(self)))))))(Effect.acquireRelease({
acquire: Queue.unbounded(),
release: queue => Queue.shutdown(queue)
})))(Effect.sync(() => new Map()))));
});

@@ -149,0 +165,0 @@ /** @internal */

@@ -6,4 +6,4 @@ "use strict";

});
exports.map = exports.logWarningCauseMessage = exports.logWarningCause = exports.logWarning = exports.logTraceCauseMessage = exports.logTraceCause = exports.logTrace = exports.logInfoCauseMessage = exports.logInfoCause = exports.logInfo = exports.logFatalCauseMessage = exports.logFatalCause = exports.logFatal = exports.logErrorCauseMessage = exports.logErrorCause = exports.logError = exports.logDebugCauseMessage = exports.logDebugCause = exports.logDebug = exports.log = exports.leftover = exports.last = exports.ignoreLeftover = exports.head = exports.fromQueueWithShutdown = exports.fromQueue = exports.fromPush = exports.fromHubWithShutdown = exports.fromHub = exports.fromEffect = exports.fromChannel = exports.forEachWhile = exports.forEachChunkWhile = exports.forEachChunk = exports.forEach = exports.foldWeightedEffect = exports.foldWeightedDecomposeEffect = exports.foldWeightedDecompose = exports.foldWeighted = exports.foldUntilEffect = exports.foldUntil = exports.foldSink = exports.foldLeftEffect = exports.foldLeftChunksEffect = exports.foldLeftChunks = exports.foldLeft = exports.foldEffect = exports.foldChunksEffect = exports.foldChunks = exports.fold = exports.flatMap = exports.findEffect = exports.filterInputEffect = exports.filterInput = exports.failSync = exports.failCauseSync = exports.failCause = exports.fail = exports.every = exports.ensuringWith = exports.ensuring = exports.dropWhileEffect = exports.dropWhile = exports.dropUntilEffect = exports.dropUntil = exports.drop = exports.drain = exports.dimapEffect = exports.dimapChunksEffect = exports.dimapChunks = exports.dimap = exports.dieSync = exports.dieMessage = exports.die = exports.count = exports.contramapEffect = exports.contramapChunksEffect = exports.contramapChunks = exports.contramap = exports.contextWithSink = exports.contextWithEffect = exports.contextWith = exports.context = exports.collectLeftover = exports.collectAllWhileWith = exports.collectAllWhileEffect = exports.collectAllWhile = exports.collectAllUntilEffect = exports.collectAllUntil = exports.collectAllToSetN = exports.collectAllToSet = exports.collectAllToMapN = exports.collectAllToMap = exports.collectAllN = exports.collectAllFrom = exports.collectAll = exports.channelToSink = exports.as = exports.SinkTypeId = exports.SinkImpl = void 0;
exports.zipWithPar = exports.zipWith = exports.zipRight = exports.zipParRight = exports.zipParLeft = exports.zipPar = exports.zipLeft = exports.zip = exports.withDuration = exports.unwrapScoped = exports.unwrap = exports.toChannel = exports.timed = exports.take = exports.sync = exports.suspend = exports.summarized = exports.sum = exports.succeed = exports.splitWhere = exports.some = exports.serviceWithSink = exports.serviceWithEffect = exports.serviceWith = exports.service = exports.refineOrDieWith = exports.refineOrDie = exports.raceWithCapacity = exports.raceWith = exports.raceBothCapacity = exports.raceBoth = exports.race = exports.provideContext = exports.orElse = exports.never = exports.mkString = exports.mapLeftover = exports.mapError = exports.mapEffect = void 0;
exports.some = exports.serviceWithSink = exports.serviceWithEffect = exports.serviceWith = exports.service = exports.refineOrDieWith = exports.refineOrDie = exports.raceWithCapacity = exports.raceWith = exports.raceBothCapacity = exports.raceBoth = exports.race = exports.provideContext = exports.orElse = exports.never = exports.mkString = exports.mapLeftover = exports.mapError = exports.mapEffect = exports.map = exports.leftover = exports.last = exports.ignoreLeftover = exports.head = exports.fromQueueWithShutdown = exports.fromQueue = exports.fromPush = exports.fromHubWithShutdown = exports.fromHub = exports.fromEffect = exports.fromChannel = exports.forEachWhile = exports.forEachChunkWhile = exports.forEachChunk = exports.forEach = exports.foldWeightedEffect = exports.foldWeightedDecomposeEffect = exports.foldWeightedDecompose = exports.foldWeighted = exports.foldUntilEffect = exports.foldUntil = exports.foldSink = exports.foldLeftEffect = exports.foldLeftChunksEffect = exports.foldLeftChunks = exports.foldLeft = exports.foldEffect = exports.foldChunksEffect = exports.foldChunks = exports.fold = exports.flatMap = exports.findEffect = exports.filterInputEffect = exports.filterInput = exports.failSync = exports.failCauseSync = exports.failCause = exports.fail = exports.every = exports.ensuringWith = exports.ensuring = exports.dropWhileEffect = exports.dropWhile = exports.dropUntilEffect = exports.dropUntil = exports.drop = exports.drain = exports.dimapEffect = exports.dimapChunksEffect = exports.dimapChunks = exports.dimap = exports.dieSync = exports.dieMessage = exports.die = exports.count = exports.contramapEffect = exports.contramapChunksEffect = exports.contramapChunks = exports.contramap = exports.contextWithSink = exports.contextWithEffect = exports.contextWith = exports.context = exports.collectLeftover = exports.collectAllWhileWith = exports.collectAllWhileEffect = exports.collectAllWhile = exports.collectAllUntilEffect = exports.collectAllUntil = exports.collectAllToSetN = exports.collectAllToSet = exports.collectAllToMapN = exports.collectAllToMap = exports.collectAllN = exports.collectAllFrom = exports.collectAll = exports.channelToSink = exports.as = exports.SinkTypeId = exports.SinkImpl = void 0;
exports.zipWithPar = exports.zipWith = exports.zipRight = exports.zipParRight = exports.zipParLeft = exports.zipPar = exports.zipLeft = exports.zip = exports.withDuration = exports.unwrapScoped = exports.unwrap = exports.toChannel = exports.timed = exports.take = exports.sync = exports.suspend = exports.summarized = exports.sum = exports.succeed = exports.splitWhere = void 0;
var Chunk = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Chunk"));

@@ -59,3 +59,3 @@ var Duration = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Duration"));

exports.collectAll = collectAll;
const collectAllLoop = acc => core.readWithCause(chunk => collectAllLoop(Chunk.concat(chunk)(acc)), core.failCause, () => core.succeed(acc));
const collectAllLoop = acc => core.readWithCause(chunk => collectAllLoop(Chunk.appendAll(chunk)(acc)), core.failCause, () => core.succeed(acc));
/** @internal */

@@ -68,8 +68,8 @@ const collectAllN = n => suspend(() => fromChannel(collectAllNLoop(n, Chunk.empty())));

if (collected.length < n) {
return collectAllNLoop(n - collected.length, Chunk.concat(acc, collected));
return collectAllNLoop(n - collected.length, Chunk.appendAll(acc, collected));
}
if (Chunk.isEmpty(leftovers)) {
return core.succeed(Chunk.concat(acc, collected));
return core.succeed(Chunk.appendAll(acc, collected));
}
return core.flatMap(core.write(leftovers), () => core.succeed(Chunk.concat(acc, collected)));
return core.flatMap(core.write(leftovers), () => core.succeed(Chunk.appendAll(acc, collected)));
}, core.failCause, () => core.succeed(acc));

@@ -120,5 +120,5 @@ /** @internal */

if (leftovers.length === 0) {
return collectAllWhileReader(predicate, Chunk.concat(Chunk.unsafeFromArray(collected))(done));
return collectAllWhileReader(predicate, Chunk.appendAll(Chunk.unsafeFromArray(collected))(done));
}
return channel.zipRight(core.succeed(Chunk.concat(Chunk.unsafeFromArray(collected))(done)))(core.write(Chunk.unsafeFromArray(leftovers)));
return channel.zipRight(core.succeed(Chunk.appendAll(Chunk.unsafeFromArray(collected))(done)))(core.write(Chunk.unsafeFromArray(leftovers)));
}, core.fail, () => core.succeed(done));

@@ -132,5 +132,5 @@ /** @internal */

if (Chunk.isEmpty(leftovers)) {
return collectAllWhileEffectReader(predicate, Chunk.concat(collected)(done));
return collectAllWhileEffectReader(predicate, Chunk.appendAll(collected)(done));
}
return channel.zipRight(core.succeed(Chunk.concat(collected)(done)))(core.write(leftovers));
return channel.zipRight(core.succeed(Chunk.appendAll(collected)(done)))(core.write(leftovers));
})(core.fromEffect(Effect.map(Chunk.unsafeFromArray)(Effect.takeWhile(predicate)(input)))), core.fail, () => core.succeed(done));

@@ -380,3 +380,6 @@ /** @internal */

}
return core.readWith(input => core.flatMap(([nextS, leftovers]) => Option.match(() => foldEffectReader(nextS, contFn, f), leftover => channel.as(nextS)(core.write(leftover)))(leftovers))(core.fromEffect(foldChunkSplitEffect(s, input, contFn, f))), core.fail, () => core.succeedNow(s));
return core.readWith(input => core.flatMap(([nextS, leftovers]) => Option.match({
onNone: () => foldEffectReader(nextS, contFn, f),
onSome: leftover => channel.as(nextS)(core.write(leftover))
})(leftovers))(core.fromEffect(foldChunkSplitEffect(s, input, contFn, f))), core.fail, () => core.succeedNow(s));
};

@@ -451,3 +454,3 @@ /** @internal */

// into the chunk we're processing and see if we can aggregate further.
const next = Chunk.concat(Chunk.drop(index + 1)(input))(decomposed);
const next = Chunk.appendAll(Chunk.drop(index + 1)(input))(decomposed);
return foldWeightedDecomposeFold(next, 0, s, cost, dirty, max, costFn, decompose, f);

@@ -495,3 +498,3 @@ };

// into the chunk we're processing and see if we can aggregate further.
const next = Chunk.concat(Chunk.drop(index + 1)(input))(decomposed);
const next = Chunk.appendAll(Chunk.drop(index + 1)(input))(decomposed);
return foldWeightedDecomposeEffectFold(s, max, costFn, decompose, f, next, dirty, cost, 0);

@@ -506,3 +509,5 @@ })(decompose(elem));

const forEach = f => {
const process = core.readWithCause(input => core.flatMap(() => process)(core.fromEffect(Effect.forEachDiscard(f)(input))), core.failCause, core.unit);
const process = core.readWithCause(input => core.flatMap(() => process)(core.fromEffect(Effect.forEach(input, f, {
discard: true
}))), core.failCause, core.unit);
return new SinkImpl(process);

@@ -551,3 +556,9 @@ };

exports.fromPush = fromPush;
const fromPushPull = push => core.readWith(input => channel.foldChannel(([either, leftovers]) => Either.match(error => channel.zipRight(core.fail(error))(core.write(leftovers)), z => channel.zipRight(core.succeedNow(z))(core.write(leftovers)))(either), () => fromPushPull(push))(core.fromEffect(push(Option.some(input)))), core.fail, () => channel.foldChannel(([either, leftovers]) => Either.match(error => channel.zipRight(core.fail(error))(core.write(leftovers)), z => channel.zipRight(core.succeedNow(z))(core.write(leftovers)))(either), () => core.fromEffect(Effect.dieMessage("BUG: Sink.fromPush - please report an issue at https://github.com/Effect-TS/stream/issues")))(core.fromEffect(push(Option.none()))));
const fromPushPull = push => core.readWith(input => channel.foldChannel(([either, leftovers]) => Either.match({
onLeft: error => channel.zipRight(core.fail(error))(core.write(leftovers)),
onRight: z => channel.zipRight(core.succeedNow(z))(core.write(leftovers))
})(either), () => fromPushPull(push))(core.fromEffect(push(Option.some(input)))), core.fail, () => channel.foldChannel(([either, leftovers]) => Either.match({
onLeft: error => channel.zipRight(core.fail(error))(core.write(leftovers)),
onRight: z => channel.zipRight(core.succeedNow(z))(core.write(leftovers))
})(either), () => core.fromEffect(Effect.dieMessage("BUG: Sink.fromPush - please report an issue at https://github.com/Effect-TS/stream/issues")))(core.fromEffect(push(Option.none()))));
/** @internal */

@@ -557,6 +568,12 @@ const fromQueue = queue => forEachChunk(input => Queue.offerAll(queue, input));

exports.fromQueue = fromQueue;
const fromQueueWithShutdown = queue => unwrapScoped(Effect.map(fromQueue)(Effect.acquireRelease(Effect.succeed(queue), Queue.shutdown)));
const fromQueueWithShutdown = queue => unwrapScoped(Effect.map(fromQueue)(Effect.acquireRelease({
acquire: Effect.succeed(queue),
release: Queue.shutdown
})));
/** @internal */
exports.fromQueueWithShutdown = fromQueueWithShutdown;
const head = () => fold(Option.none(), Option.isNone, (option, input) => Option.match(() => Option.some(input), () => option)(option));
const head = () => fold(Option.none(), Option.isNone, (option, input) => Option.match(option, {
onNone: () => Option.some(input),
onSome: () => option
}));
/** @internal */

@@ -573,59 +590,2 @@ exports.head = head;

exports.leftover = leftover;
const log = message => fromEffect(Effect.log(message));
/** @internal */
exports.log = log;
const logDebug = message => fromEffect(Effect.logDebug(message));
/** @internal */
exports.logDebug = logDebug;
const logDebugCause = cause => fromEffect(Effect.logDebugCause(cause));
/** @internal */
exports.logDebugCause = logDebugCause;
const logDebugCauseMessage = (message, cause) => fromEffect(Effect.logDebugCauseMessage(message, cause));
/** @internal */
exports.logDebugCauseMessage = logDebugCauseMessage;
const logError = message => fromEffect(Effect.logError(message));
/** @internal */
exports.logError = logError;
const logErrorCause = cause => fromEffect(Effect.logErrorCause(cause));
/** @internal */
exports.logErrorCause = logErrorCause;
const logErrorCauseMessage = (message, cause) => fromEffect(Effect.logErrorCauseMessage(message, cause));
/** @internal */
exports.logErrorCauseMessage = logErrorCauseMessage;
const logFatal = message => fromEffect(Effect.logFatal(message));
/** @internal */
exports.logFatal = logFatal;
const logFatalCause = cause => fromEffect(Effect.logFatalCause(cause));
/** @internal */
exports.logFatalCause = logFatalCause;
const logFatalCauseMessage = (message, cause) => fromEffect(Effect.logFatalCauseMessage(message, cause));
/** @internal */
exports.logFatalCauseMessage = logFatalCauseMessage;
const logInfo = message => fromEffect(Effect.logInfo(message));
/** @internal */
exports.logInfo = logInfo;
const logInfoCause = cause => fromEffect(Effect.logInfoCause(cause));
/** @internal */
exports.logInfoCause = logInfoCause;
const logInfoCauseMessage = (message, cause) => fromEffect(Effect.logInfoCauseMessage(message, cause));
/** @internal */
exports.logInfoCauseMessage = logInfoCauseMessage;
const logWarning = message => fromEffect(Effect.logWarning(message));
/** @internal */
exports.logWarning = logWarning;
const logWarningCause = cause => fromEffect(Effect.logWarningCause(cause));
/** @internal */
exports.logWarningCause = logWarningCause;
const logWarningCauseMessage = (message, cause) => fromEffect(Effect.logWarningCauseMessage(message, cause));
/** @internal */
exports.logWarningCauseMessage = logWarningCauseMessage;
const logTrace = message => fromEffect(Effect.logTrace(message));
/** @internal */
exports.logTrace = logTrace;
const logTraceCause = cause => fromEffect(Effect.logTraceCause(cause));
/** @internal */
exports.logTraceCause = logTraceCause;
const logTraceCauseMessage = (message, cause) => fromEffect(Effect.logTraceCauseMessage(message, cause));
/** @internal */
exports.logTraceCauseMessage = logTraceCauseMessage;
const map = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => {

@@ -647,3 +607,3 @@ return new SinkImpl(channel.map(f)(toChannel(self)));

const strings = [];
return map(() => strings.join(""))(foldLeftChunks(void 0, (_, elems) => Chunk.forEach(elems, elem => {
return map(() => strings.join(""))(foldLeftChunks(void 0, (_, elems) => Chunk.map(elems, elem => {
strings.push(String(elem));

@@ -654,3 +614,3 @@ })));

exports.mkString = mkString;
const never = () => fromEffect(Effect.never());
const never = () => fromEffect(Effect.never);
/** @internal */

@@ -671,3 +631,3 @@ exports.never = never;

const raceBothCapacity = /*#__PURE__*/(0, _Function.dual)(3, (self, that, capacity) => {
return raceWithCapacity(self, that, selfDone => mergeDecision.Done(Effect.map(Either.left)(Effect.done(selfDone))), thatDone => mergeDecision.Done(Effect.map(Either.right)(Effect.done(thatDone))), capacity);
return raceWithCapacity(self, that, selfDone => mergeDecision.Done(Effect.map(Either.left)(Effect.suspend(() => selfDone))), thatDone => mergeDecision.Done(Effect.map(Either.right)(Effect.suspend(() => thatDone))), capacity);
});

@@ -686,3 +646,3 @@ /** @internal */

const writer = channel.mergeWith(core.pipeTo(toChannel(that))(channel2), leftDone, rightDone)(core.pipeTo(toChannel(self))(channel1));
const racedChannel = channel.mergeWith(writer, () => mergeDecision.Await(exit => Effect.done(exit)), done => mergeDecision.Done(Effect.done(done)))(reader);
const racedChannel = channel.mergeWith(writer, () => mergeDecision.Await(exit => Effect.suspend(() => exit)), done => mergeDecision.Done(Effect.suspend(() => done)))(reader);
return new SinkImpl(racedChannel);

@@ -698,3 +658,6 @@ });

const refineOrDieWith = /*#__PURE__*/(0, _Function.dual)(3, (self, pf, f) => {
const newChannel = channel.catchAll(error => Option.match(() => core.failCauseSync(() => Cause.die(f(error))), core.fail)(pf(error)))(toChannel(self));
const newChannel = channel.catchAll(error => Option.match(pf(error), {
onNone: () => core.failCauseSync(() => Cause.die(f(error))),
onSome: core.fail
}))(toChannel(self));
return new SinkImpl(newChannel);

@@ -720,3 +683,3 @@ });

const splitWhere = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => {
const newChannel = core.flatMap(ref => core.flatMap(([leftovers, z]) => core.flatMap(leftover => channel.zipRight(core.succeed(z))(core.write(Chunk.concat(Chunk.flatten(leftovers))(leftover))))(core.fromEffect(Ref.get(ref))))(core.collectElements(channel.pipeToOrFail(toChannel(self))(splitWhereSplitter(false, ref, f)))))(core.fromEffect(Ref.make(Chunk.empty())));
const newChannel = core.flatMap(ref => core.flatMap(([leftovers, z]) => core.flatMap(leftover => channel.zipRight(core.succeed(z))(core.write(Chunk.appendAll(Chunk.flatten(leftovers))(leftover))))(core.fromEffect(Ref.get(ref))))(core.collectElements(channel.pipeToOrFail(toChannel(self))(splitWhereSplitter(false, ref, f)))))(core.fromEffect(Ref.make(Chunk.empty())));
return new SinkImpl(newChannel);

@@ -782,3 +745,3 @@ });

return new SinkImpl(channel.zipRight(core.succeedNow(taken))(core.write(leftover)));
})(foldChunks(Chunk.empty(), chunk => chunk.length < n, (acc, chunk) => Chunk.concat(chunk)(acc)));
})(foldChunks(Chunk.empty(), chunk => chunk.length < n, (acc, chunk) => Chunk.appendAll(chunk)(acc)));
/** @internal */

@@ -800,3 +763,3 @@ exports.take = take;

exports.unwrapScoped = unwrapScoped;
const withDuration = self => summarized(Clock.currentTimeMillis(), (start, end) => Duration.millis(end - start))(self);
const withDuration = self => summarized(Clock.currentTimeMillis, (start, end) => Duration.millis(end - start))(self);
/** @internal */

@@ -826,3 +789,15 @@ exports.withDuration = withDuration;

const zipWithPar = /*#__PURE__*/(0, _Function.dual)(3, (self, that, f) => {
return raceWith(that, Exit.match(cause => mergeDecision.Done(Effect.failCause(cause)), leftZ => mergeDecision.Await(Exit.match(Effect.failCause, rightZ => Effect.succeed(f(leftZ, rightZ))))), Exit.match(cause => mergeDecision.Done(Effect.failCause(cause)), rightZ => mergeDecision.Await(Exit.match(Effect.failCause, leftZ => Effect.succeed(f(leftZ, rightZ))))))(self);
return raceWith(that, Exit.match({
onFailure: cause => mergeDecision.Done(Effect.failCause(cause)),
onSuccess: leftZ => mergeDecision.Await(Exit.match({
onFailure: Effect.failCause,
onSuccess: rightZ => Effect.succeed(f(leftZ, rightZ))
}))
}), Exit.match({
onFailure: cause => mergeDecision.Done(Effect.failCause(cause)),
onSuccess: rightZ => mergeDecision.Await(Exit.match({
onFailure: Effect.failCause,
onSuccess: leftZ => Effect.succeed(f(leftZ, rightZ))
}))
}))(self);
});

@@ -829,0 +804,0 @@ // Circular with Channel

@@ -27,3 +27,6 @@ "use strict";

done(exit) {
return this(Effect.done(Exit.mapBoth(Option.some, Chunk.of)(exit)));
return this(Effect.suspend(() => Exit.mapBoth(exit, {
onFailure: Option.some,
onSuccess: Chunk.of
})));
},

@@ -37,3 +40,6 @@ end() {

fromEffect(effect) {
return this(Effect.mapBoth(Option.some, Chunk.of)(effect));
return this(Effect.mapBoth(effect, {
onFailure: Option.some,
onSuccess: Chunk.of
}));
},

@@ -40,0 +46,0 @@ fromEffectChunk(effect) {

@@ -1,7 +0,2 @@

import * as Effect from "@effect/io/Effect";
/**
* @macro traced
* @since 1.0.0
*/
export declare const take: <A>(self: Handoff<A>) => Effect.Effect<never, never, A>;
export {};
//# sourceMappingURL=handoff.d.ts.map

@@ -7,3 +7,3 @@ "use strict";

exports.take = exports.poll = exports.offer = exports.make = exports.OP_HANDOFF_STATE_FULL = exports.OP_HANDOFF_STATE_EMPTY = exports.HandoffTypeId = void 0;
var _Debug = /*#__PURE__*/require("@effect/data/Debug");
var _Function = /*#__PURE__*/require("@effect/data/Function");
var Option = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Option"));

@@ -55,27 +55,18 @@ var Deferred = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Deferred"));

/** @internal */
const make = /*#__PURE__*/(0, _Debug.methodWithTrace)(trace => () => Effect.map(ref => ({
const make = () => Effect.map(ref => ({
[HandoffTypeId]: handoffVariance,
ref
}))(Effect.flatMap(deferred => Ref.make(handoffStateEmpty(deferred)))(Deferred.make())).traced(trace));
/**
* @macro traced
* @internal
*/
}))(Effect.flatMap(deferred => Ref.make(handoffStateEmpty(deferred)))(Deferred.make()));
/** @internal */
exports.make = make;
const offer = /*#__PURE__*/(0, _Debug.dualWithTrace)(2, trace => (self, value) => {
return Effect.flatMap(deferred => Effect.flatten(Ref.modify(self.ref, state => handoffStateMatch(notifyConsumer => [Effect.zipRight(Deferred.await(deferred))(Deferred.succeed(notifyConsumer, void 0)), handoffStateFull(value, deferred)], (_, notifyProducer) => [Effect.flatMap(() => offer(value)(self))(Deferred.await(notifyProducer)), state])(state))))(Deferred.make()).traced(trace);
const offer = /*#__PURE__*/(0, _Function.dual)(2, (self, value) => {
return Effect.flatMap(Deferred.make(), deferred => Effect.flatten(Ref.modify(self.ref, state => handoffStateMatch(notifyConsumer => [Effect.zipRight(Deferred.succeed(notifyConsumer, void 0), Deferred.await(deferred)), handoffStateFull(value, deferred)], (_, notifyProducer) => [Effect.flatMap(Deferred.await(notifyProducer), () => offer(value)(self)), state])(state))));
});
/**
* @macro traced
* @since 1.0.0
*/
/** @internal */
exports.offer = offer;
const take = /*#__PURE__*/(0, _Debug.methodWithTrace)(trace => self => Effect.flatMap(deferred => Effect.flatten(Ref.modify(self.ref, state => handoffStateMatch(notifyConsumer => [Effect.flatMap(() => take(self))(Deferred.await(notifyConsumer)), state], (value, notifyProducer) => [Effect.as(value)(Deferred.succeed(notifyProducer, void 0)), handoffStateEmpty(deferred)])(state))))(Deferred.make()).traced(trace));
/**
* @macro traced
* @internal
*/
const take = self => Effect.flatMap(Deferred.make(), deferred => Effect.flatten(Ref.modify(self.ref, state => handoffStateMatch(notifyConsumer => [Effect.flatMap(Deferred.await(notifyConsumer), () => take(self)), state], (value, notifyProducer) => [Effect.as(Deferred.succeed(notifyProducer, void 0), value), handoffStateEmpty(deferred)])(state))));
/** @internal */
exports.take = take;
const poll = /*#__PURE__*/(0, _Debug.methodWithTrace)(trace => self => Effect.flatMap(deferred => Effect.flatten(Ref.modify(self.ref, state => handoffStateMatch(() => [Effect.succeed(Option.none()), state], (value, notifyProducer) => [Effect.as(Option.some(value))(Deferred.succeed(notifyProducer, void 0)), handoffStateEmpty(deferred)])(state))))(Deferred.make()).traced(trace));
const poll = self => Effect.flatMap(Deferred.make(), deferred => Effect.flatten(Ref.modify(self.ref, state => handoffStateMatch(() => [Effect.succeed(Option.none()), state], (value, notifyProducer) => [Effect.as(Deferred.succeed(notifyProducer, void 0), Option.some(value)), handoffStateEmpty(deferred)])(state))));
exports.poll = poll;
//# sourceMappingURL=handoff.js.map

@@ -8,3 +8,2 @@ "use strict";

var Chunk = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Chunk"));
var _Debug = /*#__PURE__*/require("@effect/data/Debug");
var Option = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Option"));

@@ -16,44 +15,23 @@ var Effect = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Effect"));

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/**
* @macro traced
* @internal
*/
const emit = /*#__PURE__*/(0, _Debug.methodWithTrace)(trace => value => Effect.succeed(Chunk.of(value)).traced(trace));
/**
* @macro traced
* @internal
*/
/** @internal */
const emit = value => Effect.succeed(Chunk.of(value));
/** @internal */
exports.emit = emit;
const emitChunk = /*#__PURE__*/(0, _Debug.methodWithTrace)(trace => chunk => Effect.succeed(chunk).traced(trace));
/**
* @macro traced
* @internal
*/
const emitChunk = chunk => Effect.succeed(chunk);
/** @internal */
exports.emitChunk = emitChunk;
const empty = /*#__PURE__*/(0, _Debug.methodWithTrace)(trace => () => Effect.succeed(Chunk.empty()).traced(trace));
/**
* @macro traced
* @internal
*/
const empty = () => Effect.succeed(Chunk.empty());
/** @internal */
exports.empty = empty;
const end = /*#__PURE__*/(0, _Debug.methodWithTrace)(trace => () => Effect.fail(Option.none()).traced(trace));
/**
* @macro traced
* @internal
*/
const end = () => Effect.fail(Option.none());
/** @internal */
exports.end = end;
const fail = /*#__PURE__*/(0, _Debug.methodWithTrace)(trace => error => Effect.fail(Option.some(error)).traced(trace));
/**
* @macro traced
* @internal
*/
const fail = error => Effect.fail(Option.some(error));
/** @internal */
exports.fail = fail;
const failCause = /*#__PURE__*/(0, _Debug.methodWithTrace)(trace => cause => Effect.mapError(Option.some)(Effect.failCause(cause)).traced(trace));
/**
* @macro traced
* @internal
*/
const failCause = cause => Effect.mapError(Effect.failCause(cause), Option.some);
/** @internal */
exports.failCause = failCause;
const fromDequeue = /*#__PURE__*/(0, _Debug.methodWithTrace)(trace => dequeue => Effect.flatMap(take.done)(Queue.take(dequeue)).traced(trace));
const fromDequeue = dequeue => Effect.flatMap(Queue.take(dequeue), take.done);
exports.fromDequeue = fromDequeue;
//# sourceMappingURL=pull.js.map

@@ -7,7 +7,7 @@ "use strict";

exports.set = exports.modifyEffect = exports.modify = exports.make = exports.get = exports.SubscriptionRefTypeId = void 0;
var _Debug = /*#__PURE__*/require("@effect/data/Debug");
var _Function = /*#__PURE__*/require("@effect/data/Function");
var Effect = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Effect"));
var Hub = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Hub"));
var _circular = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal_effect_untraced/effect/circular"));
var _ref = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal_effect_untraced/ref"));
var _circular = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/effect/circular"));
var _ref = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/ref"));
var Ref = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Ref"));

@@ -43,9 +43,7 @@ var Synchronized = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/Ref/Synchronized"));

}
/** @macro traced */
modify(f) {
return (0, _Debug.bodyWithTrace)(trace => this.modifyEffect(a => Effect.succeed(f(a))).traced(trace));
return this.modifyEffect(a => Effect.succeed(f(a)));
}
/** @macro traced */
modifyEffect(f) {
return (0, _Debug.bodyWithTrace)(trace => this.semaphore.withPermits(1)(Effect.flatMap(([b, a]) => Effect.zipLeft(Hub.publish(this.hub, a))(Effect.as(b)(Ref.set(this.ref, a))))(Effect.flatMap(f)(Ref.get(this.ref)))).traced(trace));
return this.semaphore.withPermits(1)(Effect.flatMap(([b, a]) => Effect.zipLeft(Hub.publish(this.hub, a))(Effect.as(b)(Ref.set(this.ref, a))))(Effect.flatMap(f)(Ref.get(this.ref))));
}

@@ -55,16 +53,16 @@ }

/** @internal */
const get = /*#__PURE__*/(0, _Debug.methodWithTrace)(trace => self => Ref.get(self.ref).traced(trace));
const get = self => Ref.get(self.ref);
/** @internal */
exports.get = get;
const make = /*#__PURE__*/(0, _Debug.methodWithTrace)(trace => value => Effect.map(([hub, ref, semaphore]) => new SubscriptionRefImpl(ref, hub, semaphore))(Effect.all(Hub.unbounded(), Ref.make(value), Effect.makeSemaphore(1))).traced(trace));
const make = value => Effect.map(([hub, ref, semaphore]) => new SubscriptionRefImpl(ref, hub, semaphore))(Effect.all(Hub.unbounded(), Ref.make(value), Effect.makeSemaphore(1)));
/** @internal */
exports.make = make;
const modify = /*#__PURE__*/(0, _Debug.dualWithTrace)(2, trace => (self, f) => self.modify(f).traced(trace));
const modify = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => self.modify(f));
/** @internal */
exports.modify = modify;
const modifyEffect = /*#__PURE__*/(0, _Debug.dualWithTrace)(2, trace => (self, f) => self.modifyEffect(f).traced(trace));
const modifyEffect = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => self.modifyEffect(f));
/** @internal */
exports.modifyEffect = modifyEffect;
const set = /*#__PURE__*/(0, _Debug.dualWithTrace)(2, trace => (self, value) => self.semaphore.withPermits(1)(Effect.zipLeft(Hub.publish(self.hub, value))(Ref.set(self.ref, value))).traced(trace));
const set = /*#__PURE__*/(0, _Function.dual)(2, (self, value) => self.semaphore.withPermits(1)(Effect.zipLeft(Hub.publish(self.hub, value))(Ref.set(self.ref, value))));
exports.set = set;
//# sourceMappingURL=subscriptionRef.js.map

@@ -8,3 +8,2 @@ "use strict";

var Chunk = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Chunk"));
var _Debug = /*#__PURE__*/require("@effect/data/Debug");
var _Function = /*#__PURE__*/require("@effect/data/Function");

@@ -47,3 +46,3 @@ var Option = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Option"));

exports.dieMessage = dieMessage;
const done = /*#__PURE__*/(0, _Debug.methodWithTrace)(trace => self => Effect.done(self.exit).traced(trace));
const done = self => Effect.suspend(() => self.exit);
/** @internal */

@@ -60,18 +59,39 @@ exports.done = done;

exports.failCause = failCause;
const fromEffect = /*#__PURE__*/(0, _Debug.methodWithTrace)(trace => effect => Effect.matchCause(failCause, of)(effect).traced(trace));
const fromEffect = effect => Effect.matchCause(effect, {
onFailure: failCause,
onSuccess: of
});
/** @internal */
exports.fromEffect = fromEffect;
const fromExit = exit => new TakeImpl(Exit.mapBoth(Option.some, Chunk.of)(exit));
const fromExit = exit => new TakeImpl(Exit.mapBoth({
onFailure: Option.some,
onSuccess: Chunk.of
})(exit));
/** @internal */
exports.fromExit = fromExit;
const fromPull = /*#__PURE__*/(0, _Debug.methodWithTrace)(trace => pull => Effect.matchCause(cause => Option.match(() => end, failCause)(Cause.flipCauseOption(cause)), chunk)(pull).traced(trace));
const fromPull = pull => Effect.matchCause(pull, {
onFailure: cause => Option.match(Cause.flipCauseOption(cause), {
onNone: () => end,
onSome: failCause
}),
onSuccess: chunk
});
/** @internal */
exports.fromPull = fromPull;
const isDone = self => Exit.match(cause => Option.isNone(Cause.flipCauseOption(cause)), _Function.constFalse)(self.exit);
const isDone = self => Exit.match(self.exit, {
onFailure: cause => Option.isNone(Cause.flipCauseOption(cause)),
onSuccess: _Function.constFalse
});
/** @internal */
exports.isDone = isDone;
const isFailure = self => Exit.match(cause => Option.isSome(Cause.flipCauseOption(cause)), _Function.constFalse)(self.exit);
const isFailure = self => Exit.match(self.exit, {
onFailure: cause => Option.isSome(Cause.flipCauseOption(cause)),
onSuccess: _Function.constFalse
});
/** @internal */
exports.isFailure = isFailure;
const isSuccess = self => Exit.match(_Function.constFalse, _Function.constTrue)(self.exit);
const isSuccess = self => Exit.match(self.exit, {
onFailure: _Function.constFalse,
onSuccess: _Function.constTrue
});
/** @internal */

@@ -82,6 +102,18 @@ exports.isSuccess = isSuccess;

exports.make = make;
const match = /*#__PURE__*/(0, _Function.dual)(4, (self, onEnd, onError, onSuccess) => Exit.match(cause => Option.match(onEnd, onError)(Cause.flipCauseOption(cause)), onSuccess)(self.exit));
const match = /*#__PURE__*/(0, _Function.dual)(4, (self, onEnd, onError, onSuccess) => Exit.match(self.exit, {
onFailure: cause => Option.match(Cause.flipCauseOption(cause), {
onNone: onEnd,
onSome: onError
}),
onSuccess
}));
/** @internal */
exports.match = match;
const matchEffect = /*#__PURE__*/(0, _Debug.dualWithTrace)(4, trace => (self, onEnd, onError, onSuccess) => Exit.matchEffect(cause => Option.match(onEnd, onError)(Cause.flipCauseOption(cause)), onSuccess)(self.exit).traced(trace));
const matchEffect = /*#__PURE__*/(0, _Function.dual)(4, (self, onEnd, onError, onSuccess) => Exit.matchEffect(self.exit, {
onFailure: cause => Option.match(Cause.flipCauseOption(cause), {
onNone: onEnd,
onSome: onError
}),
onSuccess
}));
/** @internal */

@@ -95,4 +127,4 @@ exports.matchEffect = matchEffect;

exports.of = of;
const tap = /*#__PURE__*/(0, _Debug.dualWithTrace)(2, trace => (self, f) => Effect.asUnit(Exit.forEachEffect(f)(self.exit)).traced(trace));
const tap = /*#__PURE__*/(0, _Function.dual)(2, (self, f) => Effect.asUnit(Exit.forEachEffect(f)(self.exit)));
exports.tap = tap;
//# sourceMappingURL=take.js.map
{
"name": "@effect/stream",
"version": "0.24.0",
"version": "0.25.0",
"license": "MIT",

@@ -10,4 +10,4 @@ "repository": {

"dependencies": {
"@effect/data": "~0.12.10",
"@effect/io": "~0.29.2"
"@effect/data": "~0.13.0",
"@effect/io": "~0.31.1"
},

@@ -14,0 +14,0 @@ "publishConfig": {

@@ -785,135 +785,2 @@ /**

/**
* Logs the specified message at the current log level.
*
* @since 1.0.0
* @category logging
*/
export declare const log: (message: string) => Sink<never, never, unknown, never, void>;
/**
* Logs the specified message at the debug log level.
*
* @since 1.0.0
* @category logging
*/
export declare const logDebug: (message: string) => Sink<never, never, unknown, never, void>;
/**
* Logs the specified `Cause` at the debug log level.
*
* @since 1.0.0
* @category logging
*/
export declare const logDebugCause: <E>(cause: Cause.Cause<E>) => Sink<never, never, unknown, never, void>;
/**
* Logs the specified message and `Cause` at the debug log level.
*
* @since 1.0.0
* @category logging
*/
export declare const logDebugCauseMessage: <E>(message: string, cause: Cause.Cause<E>) => Sink<never, never, unknown, never, void>;
/**
* Logs the specified message at the error log level.
*
* @since 1.0.0
* @category logging
*/
export declare const logError: (message: string) => Sink<never, never, unknown, never, void>;
/**
* Logs the specified `Cause` at the error log level.
*
* @since 1.0.0
* @category logging
*/
export declare const logErrorCause: <E>(cause: Cause.Cause<E>) => Sink<never, never, unknown, never, void>;
/**
* Logs the specified message and `Cause` at the error log level.
*
* @since 1.0.0
* @category logging
*/
export declare const logErrorCauseMessage: <E>(message: string, cause: Cause.Cause<E>) => Sink<never, never, unknown, never, void>;
/**
* Logs the specified message at the fatal log level.
*
* @since 1.0.0
* @category logging
*/
export declare const logFatal: (message: string) => Sink<never, never, unknown, never, void>;
/**
* Logs the specified `Cause` at the fatal log level.
*
* @since 1.0.0
* @category logging
*/
export declare const logFatalCause: <E>(cause: Cause.Cause<E>) => Sink<never, never, unknown, never, void>;
/**
* Logs the specified message and `Cause` at the fatal log level.
*
* @since 1.0.0
* @category logging
*/
export declare const logFatalCauseMessage: <E>(message: string, cause: Cause.Cause<E>) => Sink<never, never, unknown, never, void>;
/**
* Logs the specified message at the info log level.
*
* @since 1.0.0
* @category logging
*/
export declare const logInfo: (message: string) => Sink<never, never, unknown, never, void>;
/**
* Logs the specified `Cause` at the info log level.
*
* @since 1.0.0
* @category logging
*/
export declare const logInfoCause: <E>(cause: Cause.Cause<E>) => Sink<never, never, unknown, never, void>;
/**
* Logs the specified message and `Cause` at the info log level.
*
* @since 1.0.0
* @category logging
*/
export declare const logInfoCauseMessage: <E>(message: string, cause: Cause.Cause<E>) => Sink<never, never, unknown, never, void>;
/**
* Logs the specified message at the warning log level.
*
* @since 1.0.0
* @category logging
*/
export declare const logWarning: (message: string) => Sink<never, never, unknown, never, void>;
/**
* Logs the specified `Cause` at the warning log level.
*
* @since 1.0.0
* @category logging
*/
export declare const logWarningCause: <E>(cause: Cause.Cause<E>) => Sink<never, never, unknown, never, void>;
/**
* Logs the specified message and `Cause` at the warning log level.
*
* @since 1.0.0
* @category logging
*/
export declare const logWarningCauseMessage: <E>(message: string, cause: Cause.Cause<E>) => Sink<never, never, unknown, never, void>;
/**
* Logs the specified message at the trace log level.
*
* @since 1.0.0
* @category logging
*/
export declare const logTrace: (message: string) => Sink<never, never, unknown, never, void>;
/**
* Logs the specified `Cause` at the trace log level.
*
* @since 1.0.0
* @category logging
*/
export declare const logTraceCause: <E>(cause: Cause.Cause<E>) => Sink<never, never, unknown, never, void>;
/**
* Logs the specified message and `Cause` at the trace log level.
*
* @since 1.0.0
* @category logging
*/
export declare const logTraceCauseMessage: <E>(message: string, cause: Cause.Cause<E>) => Sink<never, never, unknown, never, void>;
/**
* Transforms this sink's result.

@@ -920,0 +787,0 @@ *

@@ -6,4 +6,4 @@ "use strict";

});
exports.mapError = exports.mapEffect = exports.map = exports.logWarningCauseMessage = exports.logWarningCause = exports.logWarning = exports.logTraceCauseMessage = exports.logTraceCause = exports.logTrace = exports.logInfoCauseMessage = exports.logInfoCause = exports.logInfo = exports.logFatalCauseMessage = exports.logFatalCause = exports.logFatal = exports.logErrorCauseMessage = exports.logErrorCause = exports.logError = exports.logDebugCauseMessage = exports.logDebugCause = exports.logDebug = exports.log = exports.leftover = exports.last = exports.ignoreLeftover = exports.head = exports.fromQueueWithShutdown = exports.fromQueue = exports.fromPush = exports.fromHubWithShutdown = exports.fromHub = exports.fromEffect = exports.fromChannel = exports.forEachWhile = exports.forEachChunkWhile = exports.forEachChunk = exports.forEach = exports.foldWeightedEffect = exports.foldWeightedDecomposeEffect = exports.foldWeightedDecompose = exports.foldWeighted = exports.foldUntilEffect = exports.foldUntil = exports.foldSink = exports.foldLeftEffect = exports.foldLeftChunksEffect = exports.foldLeftChunks = exports.foldLeft = exports.foldEffect = exports.foldChunksEffect = exports.foldChunks = exports.fold = exports.flatMap = exports.findEffect = exports.filterInputEffect = exports.filterInput = exports.failSync = exports.failCauseSync = exports.failCause = exports.fail = exports.every = exports.ensuringWith = exports.ensuring = exports.dropWhileEffect = exports.dropWhile = exports.dropUntilEffect = exports.dropUntil = exports.drop = exports.drain = exports.dimapEffect = exports.dimapChunksEffect = exports.dimapChunks = exports.dimap = exports.dieSync = exports.dieMessage = exports.die = exports.count = exports.contramapEffect = exports.contramapChunksEffect = exports.contramapChunks = exports.contramap = exports.contextWithSink = exports.contextWithEffect = exports.contextWith = exports.context = exports.collectLeftover = exports.collectAllWhileWith = exports.collectAllWhileEffect = exports.collectAllWhile = exports.collectAllUntilEffect = exports.collectAllUntil = exports.collectAllToSetN = exports.collectAllToSet = exports.collectAllToMapN = exports.collectAllToMap = exports.collectAllN = exports.collectAllFrom = exports.collectAll = exports.as = exports.SinkTypeId = void 0;
exports.zipWithPar = exports.zipWith = exports.zipRight = exports.zipParRight = exports.zipParLeft = exports.zipPar = exports.zipLeft = exports.zip = exports.withDuration = exports.unwrapScoped = exports.unwrap = exports.toChannel = exports.timed = exports.take = exports.sync = exports.suspend = exports.summarized = exports.sum = exports.succeed = exports.splitWhere = exports.some = exports.refineOrDieWith = exports.refineOrDie = exports.raceWithCapacity = exports.raceWith = exports.raceBothCapacity = exports.raceBoth = exports.race = exports.provideContext = exports.orElse = exports.never = exports.mkString = exports.mapLeftover = void 0;
exports.sync = exports.suspend = exports.summarized = exports.sum = exports.succeed = exports.splitWhere = exports.some = exports.refineOrDieWith = exports.refineOrDie = exports.raceWithCapacity = exports.raceWith = exports.raceBothCapacity = exports.raceBoth = exports.race = exports.provideContext = exports.orElse = exports.never = exports.mkString = exports.mapLeftover = exports.mapError = exports.mapEffect = exports.map = exports.leftover = exports.last = exports.ignoreLeftover = exports.head = exports.fromQueueWithShutdown = exports.fromQueue = exports.fromPush = exports.fromHubWithShutdown = exports.fromHub = exports.fromEffect = exports.fromChannel = exports.forEachWhile = exports.forEachChunkWhile = exports.forEachChunk = exports.forEach = exports.foldWeightedEffect = exports.foldWeightedDecomposeEffect = exports.foldWeightedDecompose = exports.foldWeighted = exports.foldUntilEffect = exports.foldUntil = exports.foldSink = exports.foldLeftEffect = exports.foldLeftChunksEffect = exports.foldLeftChunks = exports.foldLeft = exports.foldEffect = exports.foldChunksEffect = exports.foldChunks = exports.fold = exports.flatMap = exports.findEffect = exports.filterInputEffect = exports.filterInput = exports.failSync = exports.failCauseSync = exports.failCause = exports.fail = exports.every = exports.ensuringWith = exports.ensuring = exports.dropWhileEffect = exports.dropWhile = exports.dropUntilEffect = exports.dropUntil = exports.drop = exports.drain = exports.dimapEffect = exports.dimapChunksEffect = exports.dimapChunks = exports.dimap = exports.dieSync = exports.dieMessage = exports.die = exports.count = exports.contramapEffect = exports.contramapChunksEffect = exports.contramapChunks = exports.contramap = exports.contextWithSink = exports.contextWithEffect = exports.contextWith = exports.context = exports.collectLeftover = exports.collectAllWhileWith = exports.collectAllWhileEffect = exports.collectAllWhile = exports.collectAllUntilEffect = exports.collectAllUntil = exports.collectAllToSetN = exports.collectAllToSet = exports.collectAllToMapN = exports.collectAllToMap = exports.collectAllN = exports.collectAllFrom = exports.collectAll = exports.as = exports.SinkTypeId = void 0;
exports.zipWithPar = exports.zipWith = exports.zipRight = exports.zipParRight = exports.zipParLeft = exports.zipPar = exports.zipLeft = exports.zip = exports.withDuration = exports.unwrapScoped = exports.unwrap = exports.toChannel = exports.timed = exports.take = void 0;
var internal = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/stream/internal/sink"));

@@ -746,154 +746,2 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

/**
* Logs the specified message at the current log level.
*
* @since 1.0.0
* @category logging
*/
exports.leftover = leftover;
const log = internal.log;
/**
* Logs the specified message at the debug log level.
*
* @since 1.0.0
* @category logging
*/
exports.log = log;
const logDebug = internal.logDebug;
/**
* Logs the specified `Cause` at the debug log level.
*
* @since 1.0.0
* @category logging
*/
exports.logDebug = logDebug;
const logDebugCause = internal.logDebugCause;
/**
* Logs the specified message and `Cause` at the debug log level.
*
* @since 1.0.0
* @category logging
*/
exports.logDebugCause = logDebugCause;
const logDebugCauseMessage = internal.logDebugCauseMessage;
/**
* Logs the specified message at the error log level.
*
* @since 1.0.0
* @category logging
*/
exports.logDebugCauseMessage = logDebugCauseMessage;
const logError = internal.logError;
/**
* Logs the specified `Cause` at the error log level.
*
* @since 1.0.0
* @category logging
*/
exports.logError = logError;
const logErrorCause = internal.logErrorCause;
/**
* Logs the specified message and `Cause` at the error log level.
*
* @since 1.0.0
* @category logging
*/
exports.logErrorCause = logErrorCause;
const logErrorCauseMessage = internal.logErrorCauseMessage;
/**
* Logs the specified message at the fatal log level.
*
* @since 1.0.0
* @category logging
*/
exports.logErrorCauseMessage = logErrorCauseMessage;
const logFatal = internal.logFatal;
/**
* Logs the specified `Cause` at the fatal log level.
*
* @since 1.0.0
* @category logging
*/
exports.logFatal = logFatal;
const logFatalCause = internal.logFatalCause;
/**
* Logs the specified message and `Cause` at the fatal log level.
*
* @since 1.0.0
* @category logging
*/
exports.logFatalCause = logFatalCause;
const logFatalCauseMessage = internal.logFatalCauseMessage;
/**
* Logs the specified message at the info log level.
*
* @since 1.0.0
* @category logging
*/
exports.logFatalCauseMessage = logFatalCauseMessage;
const logInfo = internal.logInfo;
/**
* Logs the specified `Cause` at the info log level.
*
* @since 1.0.0
* @category logging
*/
exports.logInfo = logInfo;
const logInfoCause = internal.logInfoCause;
/**
* Logs the specified message and `Cause` at the info log level.
*
* @since 1.0.0
* @category logging
*/
exports.logInfoCause = logInfoCause;
const logInfoCauseMessage = internal.logInfoCauseMessage;
/**
* Logs the specified message at the warning log level.
*
* @since 1.0.0
* @category logging
*/
exports.logInfoCauseMessage = logInfoCauseMessage;
const logWarning = internal.logWarning;
/**
* Logs the specified `Cause` at the warning log level.
*
* @since 1.0.0
* @category logging
*/
exports.logWarning = logWarning;
const logWarningCause = internal.logWarningCause;
/**
* Logs the specified message and `Cause` at the warning log level.
*
* @since 1.0.0
* @category logging
*/
exports.logWarningCause = logWarningCause;
const logWarningCauseMessage = internal.logWarningCauseMessage;
/**
* Logs the specified message at the trace log level.
*
* @since 1.0.0
* @category logging
*/
exports.logWarningCauseMessage = logWarningCauseMessage;
const logTrace = internal.logTrace;
/**
* Logs the specified `Cause` at the trace log level.
*
* @since 1.0.0
* @category logging
*/
exports.logTrace = logTrace;
const logTraceCause = internal.logTraceCause;
/**
* Logs the specified message and `Cause` at the trace log level.
*
* @since 1.0.0
* @category logging
*/
exports.logTraceCause = logTraceCause;
const logTraceCauseMessage = internal.logTraceCauseMessage;
/**
* Transforms this sink's result.

@@ -904,3 +752,3 @@ *

*/
exports.logTraceCauseMessage = logTraceCauseMessage;
exports.leftover = leftover;
const map = internal.map;

@@ -907,0 +755,0 @@ /**

@@ -32,9 +32,3 @@ /**

{
/**
* @macro traced
*/
close(): Effect.Effect<never, never, unknown>
/**
* @macro traced
*/
take(): Effect.Effect<never, never, Exit.Exit<Either.Either<Err, Done>, Elem>>

@@ -50,17 +44,5 @@ }

export interface AsyncInputProducer<Err, Elem, Done> {
/**
* @macro traced
*/
awaitRead(): Effect.Effect<never, never, unknown>
/**
* @macro traced
*/
done(value: Done): Effect.Effect<never, never, unknown>
/**
* @macro traced
*/
emit(element: Elem): Effect.Effect<never, never, unknown>
/**
* @macro traced
*/
error(cause: Cause.Cause<Err>): Effect.Effect<never, never, unknown>

@@ -76,5 +58,2 @@ }

export interface AsyncInputConsumer<Err, Elem, Done> {
/**
* @macro traced
*/
takeWith<A>(

@@ -88,3 +67,2 @@ onError: (cause: Cause.Cause<Err>) => A,

/**
* @macro traced
* @since 1.0.0

@@ -91,0 +69,0 @@ * @category constructors

@@ -136,7 +136,6 @@ import type * as Context from "@effect/data/Context"

case ChannelStateOpCodes.OP_DONE: {
return Exit.match(
inputExecutor.getDone(),
(cause) => bridgeInput.error(cause),
(value) => bridgeInput.done(value)
)
return Exit.match(inputExecutor.getDone(), {
onFailure: (cause) => bridgeInput.error(cause),
onSuccess: (value) => bridgeInput.done(value)
})
}

@@ -150,7 +149,6 @@ case ChannelStateOpCodes.OP_EMIT: {

case ChannelStateOpCodes.OP_FROM_EFFECT: {
return Effect.matchCauseEffect(
state.effect,
(cause) => bridgeInput.error(cause),
() => drainer()
)
return Effect.matchCauseEffect(state.effect, {
onFailure: (cause) => bridgeInput.error(cause),
onSuccess: () => drainer()
})
}

@@ -176,3 +174,3 @@ case ChannelStateOpCodes.OP_READ: {

const effect = this.restorePipe(exit, inputExecutor)
return effect !== undefined ? effect : Effect.unit()
return effect !== undefined ? effect : Effect.unit
}))

@@ -203,3 +201,3 @@ )

const prevLastClose = this._closeLastSubstream === undefined
? Effect.unit()
? Effect.unit
: this._closeLastSubstream

@@ -263,19 +261,16 @@ this._closeLastSubstream = pipe(prevLastClose, Effect.zipRight(effect))

result = ChannelState.FromEffect(
pipe(
effect,
Effect.matchCauseEffect(
(cause) => {
const state = this.doneHalt(cause)
return state !== undefined && ChannelState.isFromEffect(state) ?
state.effect :
Effect.unit()
},
(value) => {
const state = this.doneSucceed(value)
return state !== undefined && ChannelState.isFromEffect(state) ?
state.effect :
Effect.unit()
}
)
)
Effect.matchCauseEffect(effect, {
onFailure: (cause) => {
const state = this.doneHalt(cause)
return state !== undefined && ChannelState.isFromEffect(state) ?
state.effect :
Effect.unit
},
onSuccess: (value) => {
const state = this.doneSucceed(value)
return state !== undefined && ChannelState.isFromEffect(state) ?
state.effect :
Effect.unit
}
})
) as ChannelState.ChannelState<Env, unknown> | undefined

@@ -299,3 +294,3 @@

const effect = this.restorePipe(exit, previousInput)
return effect !== undefined ? effect : Effect.unit()
return effect !== undefined ? effect : Effect.unit
})

@@ -403,3 +398,3 @@

}
const effect = (finalizers.length === 0 ? Effect.unit() : runFinalizers(finalizers, exit)) as Effect.Effect<
const effect = (finalizers.length === 0 ? Effect.unit : runFinalizers(finalizers, exit)) as Effect.Effect<
Env,

@@ -436,3 +431,3 @@ never,

}
return Effect.unit()
return Effect.unit
}

@@ -477,3 +472,4 @@

Effect.uninterruptible,
Effect.flatMap(Effect.done)
// TODO: remove
Effect.flatMap((exit) => Effect.suspend(() => exit))
)

@@ -560,10 +556,9 @@ }

runBracketOut(bracketOut: core.BracketOut): ChannelState.ChannelState<Env, unknown> {
const effect = pipe(
this.provide(bracketOut.acquire() as Effect.Effect<Env, OutErr, OutDone>),
Effect.matchCauseEffect(
(cause) =>
const effect = Effect.uninterruptible(
Effect.matchCauseEffect(this.provide(bracketOut.acquire() as Effect.Effect<Env, OutErr, OutDone>), {
onFailure: (cause) =>
Effect.sync(() => {
this._currentChannel = core.failCause(cause) as core.Primitive
}),
(out) =>
onSuccess: (out) =>
Effect.sync(() => {

@@ -575,4 +570,3 @@ this.addFinalizer((exit) =>

})
),
Effect.uninterruptible
})
)

@@ -629,12 +623,9 @@ return ChannelState.FromEffect(effect) as ChannelState.ChannelState<Env, unknown>

finishWithExit(exit: Exit.Exit<unknown, unknown>): Effect.Effect<Env, unknown, unknown> {
const state = pipe(
exit,
Exit.match(
(cause) => this.doneHalt(cause),
(value) => this.doneSucceed(value)
)
)
const state = Exit.match(exit, {
onFailure: (cause) => this.doneHalt(cause),
onSuccess: (value) => this.doneSucceed(value)
})
this._activeSubexecutor = undefined
return state === undefined ?
Effect.unit() :
Effect.unit :
ChannelState.effect(state)

@@ -650,8 +641,7 @@ }

closeFuncs,
Effect.forEachDiscard((closeFunc) =>
Effect.forEach((closeFunc) =>
pipe(
Effect.sync(() => closeFunc(subexecutorDone)),
Effect.flatMap((closeEffect) => closeEffect !== undefined ? closeEffect : Effect.unit())
)
)
Effect.flatMap((closeEffect) => closeEffect !== undefined ? closeEffect : Effect.unit)
), { discard: true })
)

@@ -661,6 +651,6 @@ )

subexecutorDone,
Exit.match(
(cause) => this.doneHalt(cause),
(value) => this.doneSucceed(value)
)
Exit.match({
onFailure: (cause) => this.doneHalt(cause),
onSuccess: (value) => this.doneSucceed(value)
})
)

@@ -716,4 +706,4 @@ this._activeSubexecutor = undefined

},
Exit.match(
(cause) => {
Exit.match({
onFailure: (cause) => {
const state = this.handleSubexecutorFailure(childExecutor, parentSubexecutor, cause)

@@ -724,7 +714,7 @@ return state === undefined ?

},
(doneValue) => {
onSuccess: (doneValue) => {
this.finishWithDoneValue(childExecutor, parentSubexecutor, doneValue)
return undefined
}
)
})
)

@@ -838,3 +828,3 @@ }

(effect) => {
const closeLastSubstream = this._closeLastSubstream === undefined ? Effect.unit() : this._closeLastSubstream
const closeLastSubstream = this._closeLastSubstream === undefined ? Effect.unit : this._closeLastSubstream
this._closeLastSubstream = undefined

@@ -1036,3 +1026,3 @@ return pipe(

const ifNotNull = <Env>(effect: Effect.Effect<Env, never, unknown> | undefined): Effect.Effect<Env, never, unknown> =>
effect !== undefined ? effect : Effect.unit()
effect !== undefined ? effect : Effect.unit

@@ -1045,4 +1035,4 @@ const runFinalizers = <Env>(

Effect.forEach(finalizers, (fin) => Effect.exit(fin(exit))),
Effect.map((exits) => pipe(Exit.collectAll(exits), Option.getOrElse(() => Exit.unit()))),
Effect.flatMap((exit) => Effect.done(exit as Exit.Exit<never, unknown>))
Effect.map((exits) => pipe(Exit.all(exits), Option.getOrElse(() => Exit.unit))),
Effect.flatMap((exit) => Effect.suspend(() => exit as Exit.Exit<never, unknown>))
)

@@ -1075,3 +1065,3 @@ }

emitEffect as Effect.Effect<never, never, void>,
Effect.matchCauseEffect(onFailure, onSuccess)
Effect.matchCauseEffect({ onFailure, onSuccess })
)

@@ -1084,3 +1074,3 @@ }

emitEffect as Effect.Effect<never, never, void>,
Effect.matchCauseEffect(onFailure, () => read())
Effect.matchCauseEffect({ onFailure, onSuccess: () => read() })
)

@@ -1097,3 +1087,3 @@ }

doneEffect as Effect.Effect<never, never, void>,
Effect.matchCauseEffect(onFailure, () => onSuccess())
Effect.matchCauseEffect({ onFailure, onSuccess })
)

@@ -1106,3 +1096,3 @@ }

doneEffect as Effect.Effect<never, never, void>,
Effect.matchCauseEffect(onFailure, () => read())
Effect.matchCauseEffect({ onFailure, onSuccess: () => read() })
)

@@ -1118,6 +1108,6 @@ }

const doneEffect = current.onDone(Exit.failCause(cause)) as Effect.Effect<never, never, void>
return doneEffect === undefined ? Effect.unit() : doneEffect
return doneEffect === undefined ? Effect.unit : doneEffect
})
),
Effect.matchCauseEffect(onFailure, () => read())
Effect.matchCauseEffect({ onFailure, onSuccess: () => read() })
)

@@ -1150,5 +1140,5 @@ }

) =>
Effect.acquireUseRelease(
Effect.sync(() => new ChannelExecutor(self, void 0, identity)),
(exec) =>
Effect.acquireUseRelease({
acquire: Effect.sync(() => new ChannelExecutor(self, void 0, identity)),
use: (exec) =>
Effect.suspend(() =>

@@ -1162,6 +1152,6 @@ pipe(

),
(exec, exit) => {
release: (exec, exit) => {
const finalize = exec.close(exit)
if (finalize === undefined) {
return Effect.unit()
return Effect.unit
}

@@ -1173,5 +1163,5 @@ return Effect.tapErrorCause(

}
)
})
return Effect.uninterruptibleMask((restore) =>
Effect.flatMap(Effect.scope(), (parent) =>
Effect.flatMap(Effect.scope, (parent) =>
pipe(

@@ -1220,3 +1210,3 @@ Effect.all(

case ChannelStateOpCodes.OP_DONE: {
return Effect.done(exec.getDone())
return Effect.suspend(() => exec.getDone())
}

@@ -1223,0 +1213,0 @@ case ChannelStateOpCodes.OP_READ: {

@@ -128,3 +128,3 @@ import * as Effect from "@effect/io/Effect"

export const effect = <R, E>(self: ChannelState<R, E>): Effect.Effect<R, E, void> =>
isFromEffect(self) ? self.effect as Effect.Effect<R, E, void> : Effect.unit()
isFromEffect(self) ? self.effect as Effect.Effect<R, E, void> : Effect.unit

@@ -131,0 +131,0 @@ /** @internal */

@@ -1,2 +0,1 @@

import { bodyWithTrace, methodWithTrace } from "@effect/data/Debug"
import * as Either from "@effect/data/Either"

@@ -100,23 +99,45 @@ import { pipe } from "@effect/data/Function"

awaitRead(): Effect.Effect<never, never, unknown> {
return bodyWithTrace((trace) => {
return Effect.flatten(
Ref.modify(this.ref, (state) =>
state._tag === OP_STATE_EMPTY ?
[Deferred.await(state.notifyProducer), state as State<Err, Elem, Done>] :
[Effect.unit(), state])
).traced(trace)
})
return Effect.flatten(
Ref.modify(this.ref, (state) =>
state._tag === OP_STATE_EMPTY ?
[Deferred.await(state.notifyProducer), state as State<Err, Elem, Done>] :
[Effect.unit, state])
)
}
close(): Effect.Effect<never, never, unknown> {
return bodyWithTrace((trace) => {
return Effect.fiberIdWith(
(fiberId) => this.error(Cause.interrupt(fiberId))
).traced(trace)
})
return Effect.fiberIdWith((fiberId) => this.error(Cause.interrupt(fiberId)))
}
done(value: Done): Effect.Effect<never, never, unknown> {
return bodyWithTrace((trace) => {
return pipe(
return Effect.flatten(
Ref.modify(this.ref, (state) => {
switch (state._tag) {
case OP_STATE_EMPTY: {
return [Deferred.await(state.notifyProducer), state]
}
case OP_STATE_EMIT: {
return [
Effect.forEach(
state.notifyConsumers,
(deferred) => Deferred.succeed(deferred, Either.left(value)),
{ discard: true }
),
stateDone(value) as State<Err, Elem, Done>
]
}
case OP_STATE_ERROR: {
return [Effect.interrupt, state]
}
case OP_STATE_DONE: {
return [Effect.interrupt, state]
}
}
})
)
}
emit(element: Elem): Effect.Effect<never, never, unknown> {
return Effect.flatMap(Deferred.make<never, void>(), (deferred) =>
Effect.flatten(
Ref.modify(this.ref, (state) => {

@@ -128,167 +149,115 @@ switch (state._tag) {

case OP_STATE_EMIT: {
return [
pipe(
state.notifyConsumers,
Effect.forEachDiscard((deferred) => Deferred.succeed(deferred, Either.left(value)))
),
stateDone(value) as State<Err, Elem, Done>
]
const notifyConsumer = state.notifyConsumers[0]
const notifyConsumers = state.notifyConsumers.slice(1)
if (notifyConsumer !== undefined) {
return [
Deferred.succeed(notifyConsumer, Either.right(element)),
(notifyConsumers.length === 0 ?
stateEmpty(deferred) :
stateEmit(notifyConsumers)) as State<Err, Elem, Done>
]
}
throw new Error(
"Bug: Channel.SingleProducerAsyncInput.emit - Queue was empty! Please report an issue at https://github.com/Effect-TS/stream/issues"
)
}
case OP_STATE_ERROR: {
return [Effect.interrupt(), state]
return [Effect.interrupt, state]
}
case OP_STATE_DONE: {
return [Effect.interrupt(), state]
return [Effect.interrupt, state]
}
}
}),
Effect.flatten
).traced(trace)
})
})
))
}
emit(element: Elem): Effect.Effect<never, never, unknown> {
return bodyWithTrace((trace) => {
return pipe(
Deferred.make<never, void>(),
Effect.flatMap((deferred) =>
pipe(
Ref.modify(this.ref, (state) => {
switch (state._tag) {
case OP_STATE_EMPTY: {
return [Deferred.await(state.notifyProducer), state]
}
case OP_STATE_EMIT: {
const notifyConsumer = state.notifyConsumers[0]
const notifyConsumers = state.notifyConsumers.slice(1)
if (notifyConsumer !== undefined) {
return [
Deferred.succeed(notifyConsumer, Either.right(element)),
(notifyConsumers.length === 0 ?
stateEmpty(deferred) :
stateEmit(notifyConsumers)) as State<Err, Elem, Done>
]
}
throw new Error(
"Bug: Channel.SingleProducerAsyncInput.emit - Queue was empty! Please report an issue at https://github.com/Effect-TS/stream/issues"
)
}
case OP_STATE_ERROR: {
return [Effect.interrupt(), state]
}
case OP_STATE_DONE: {
return [Effect.interrupt(), state]
}
}
}),
Effect.flatten
)
)
).traced(trace)
})
error(cause: Cause.Cause<Err>): Effect.Effect<never, never, unknown> {
return Effect.flatten(
Ref.modify(this.ref, (state) => {
switch (state._tag) {
case OP_STATE_EMPTY: {
return [Deferred.await(state.notifyProducer), state]
}
case OP_STATE_EMIT: {
return [
Effect.forEach(
state.notifyConsumers,
(deferred) => Deferred.failCause(deferred, cause),
{ discard: true }
),
stateError(cause) as State<Err, Elem, Done>
]
}
case OP_STATE_ERROR: {
return [Effect.interrupt, state]
}
case OP_STATE_DONE: {
return [Effect.interrupt, state]
}
}
})
)
}
error(cause: Cause.Cause<Err>): Effect.Effect<never, never, unknown> {
return bodyWithTrace((trace) => {
return pipe(
take(): Effect.Effect<never, never, Exit.Exit<Either.Either<Err, Done>, Elem>> {
return this.takeWith(
(cause) => Exit.failCause(Cause.map(cause, Either.left)),
(elem) => Exit.succeed(elem) as Exit.Exit<Either.Either<Err, Done>, Elem>,
(done) => Exit.fail(Either.right(done))
)
}
takeWith<A>(
onError: (cause: Cause.Cause<Err>) => A,
onElement: (element: Elem) => A,
onDone: (value: Done) => A
): Effect.Effect<never, never, A> {
return Effect.flatMap(Deferred.make<Err, Either.Either<Done, Elem>>(), (deferred) =>
Effect.flatten(
Ref.modify(this.ref, (state) => {
switch (state._tag) {
case OP_STATE_EMPTY: {
return [Deferred.await(state.notifyProducer), state]
return [
Effect.zipRight(
Deferred.succeed(state.notifyProducer, void 0),
Effect.matchCause(Deferred.await(deferred), {
onFailure: onError,
onSuccess: Either.match({ onLeft: onDone, onRight: onElement })
})
),
stateEmit([deferred])
]
}
case OP_STATE_EMIT: {
return [
Effect.forEachDiscard(
state.notifyConsumers,
(deferred) => Deferred.failCause(deferred, cause)
),
stateError(cause) as State<Err, Elem, Done>
Effect.matchCause(Deferred.await(deferred), {
onFailure: onError,
onSuccess: Either.match({ onLeft: onDone, onRight: onElement })
}),
stateEmit([...state.notifyConsumers, deferred])
]
}
case OP_STATE_ERROR: {
return [Effect.interrupt(), state]
return [Effect.succeed(onError(state.cause)), state]
}
case OP_STATE_DONE: {
return [Effect.interrupt(), state]
return [Effect.succeed(onDone(state.done)), state]
}
}
}),
Effect.flatten
).traced(trace)
})
})
))
}
take(): Effect.Effect<never, never, Exit.Exit<Either.Either<Err, Done>, Elem>> {
return bodyWithTrace((trace) => {
return this.takeWith(
(cause) => Exit.failCause(Cause.map(cause, Either.left)),
(elem) => Exit.succeed(elem) as Exit.Exit<Either.Either<Err, Done>, Elem>,
(done) => Exit.fail(Either.right(done))
).traced(trace)
})
}
takeWith<A>(
onError: (cause: Cause.Cause<Err>) => A,
onElement: (element: Elem) => A,
onDone: (value: Done) => A
): Effect.Effect<never, never, A> {
return bodyWithTrace((trace) => {
return pipe(
Deferred.make<Err, Either.Either<Done, Elem>>(),
Effect.flatMap((deferred) =>
pipe(
Ref.modify(this.ref, (state) => {
switch (state._tag) {
case OP_STATE_EMPTY: {
return [
Effect.zipRight(
Deferred.succeed(state.notifyProducer, void 0),
Effect.matchCause(
Deferred.await(deferred),
onError,
Either.match(onDone, onElement)
)
),
stateEmit([deferred])
]
}
case OP_STATE_EMIT: {
return [
Effect.matchCause(
Deferred.await(deferred),
onError,
Either.match(onDone, onElement)
),
stateEmit([...state.notifyConsumers, deferred])
]
}
case OP_STATE_ERROR: {
return [Effect.succeed(onError(state.cause)), state]
}
case OP_STATE_DONE: {
return [Effect.succeed(onDone(state.done)), state]
}
}
}),
Effect.flatten
)
)
).traced(trace)
})
}
}
/** @internal */
export const make = methodWithTrace((trace) =>
<Err, Elem, Done>(): Effect.Effect<
never,
never,
SingleProducerAsyncInput.SingleProducerAsyncInput<Err, Elem, Done>
> =>
pipe(
Deferred.make<never, void>(),
Effect.flatMap((deferred) => Ref.make(stateEmpty(deferred) as State<Err, Elem, Done>)),
Effect.map((ref) => new SingleProducerAsyncInputImpl(ref))
).traced(trace)
)
export const make = <Err, Elem, Done>(): Effect.Effect<
never,
never,
SingleProducerAsyncInput.SingleProducerAsyncInput<Err, Elem, Done>
> =>
pipe(
Deferred.make<never, void>(),
Effect.flatMap((deferred) => Ref.make(stateEmpty(deferred) as State<Err, Elem, Done>)),
Effect.map((ref) => new SingleProducerAsyncInputImpl(ref))
)

@@ -1,2 +0,1 @@

import { bodyWithTrace } from "@effect/data/Debug"
import { pipe } from "@effect/data/Function"

@@ -12,5 +11,2 @@ import * as Effect from "@effect/io/Effect"

export interface Subexecutor<R> {
/**
* @macro traced
*/
close(exit: Exit.Exit<unknown, unknown>): Effect.Effect<R, never, unknown> | undefined

@@ -64,18 +60,17 @@ enqueuePullFromChild(child: PullFromChild<R>): Subexecutor<R>

close(exit: Exit.Exit<unknown, unknown>): Effect.Effect<R, never, unknown> | undefined {
return bodyWithTrace((trace) => {
const fin1 = this.childExecutor.close(exit)
const fin2 = this.parentSubexecutor.close(exit)
if (fin1 !== undefined && fin2 !== undefined) {
return pipe(
Effect.exit(fin1),
Effect.zipWith(Effect.exit(fin2), (exit1, exit2) => pipe(exit1, Exit.zipRight(exit2)))
).traced(trace)
} else if (fin1 !== undefined) {
return fin1.traced(trace)
} else if (fin2 !== undefined) {
return fin2.traced(trace)
} else {
return undefined
}
})
const fin1 = this.childExecutor.close(exit)
const fin2 = this.parentSubexecutor.close(exit)
if (fin1 !== undefined && fin2 !== undefined) {
return Effect.zipWith(
Effect.exit(fin1),
Effect.exit(fin2),
(exit1, exit2) => pipe(exit1, Exit.zipRight(exit2))
)
} else if (fin1 !== undefined) {
return fin1
} else if (fin2 !== undefined) {
return fin2
} else {
return undefined
}
}

@@ -112,34 +107,30 @@

close(exit: Exit.Exit<unknown, unknown>): Effect.Effect<R, never, unknown> | undefined {
return bodyWithTrace((trace) => {
const fin1 = this.upstreamExecutor.close(exit)
const fins = [
...this.activeChildExecutors.map((child) =>
child !== undefined ?
child.childExecutor.close(exit) :
undefined
),
fin1
]
const result = fins.reduce(
(acc: Effect.Effect<R, never, Exit.Exit<unknown, unknown>> | undefined, next) => {
if (acc !== undefined && next !== undefined) {
return pipe(
acc,
Effect.zipWith(
Effect.exit(next),
(exit1, exit2) => pipe(exit1, Exit.zipRight(exit2))
)
)
} else if (acc !== undefined) {
return acc
} else if (next !== undefined) {
return Effect.exit(next)
} else {
return undefined
}
},
undefined
)
return result === undefined ? result : result.traced(trace)
})
const fin1 = this.upstreamExecutor.close(exit)
const fins = [
...this.activeChildExecutors.map((child) =>
child !== undefined ?
child.childExecutor.close(exit) :
undefined
),
fin1
]
const result = fins.reduce(
(acc: Effect.Effect<R, never, Exit.Exit<unknown, unknown>> | undefined, next) => {
if (acc !== undefined && next !== undefined) {
return Effect.zipWith(
acc,
Effect.exit(next),
(exit1, exit2) => Exit.zipRight(exit1, exit2)
)
} else if (acc !== undefined) {
return acc
} else if (next !== undefined) {
return Effect.exit(next)
} else {
return undefined
}
},
undefined
)
return result === undefined ? result : result
}

@@ -184,30 +175,29 @@

close(exit: Exit.Exit<unknown, unknown>): Effect.Effect<R, never, unknown> | undefined {
return bodyWithTrace((trace) => {
const fin1 = this.upstreamExecutor.close(exit)
const fins = [
...this.activeChildExecutors.map((child) => (child !== undefined ?
child.childExecutor.close(exit) :
undefined)
),
fin1
]
const result = fins.reduce(
(acc: Effect.Effect<R, never, Exit.Exit<unknown, unknown>> | undefined, next) => {
if (acc !== undefined && next !== undefined) {
return pipe(
acc,
Effect.zipWith(Effect.exit(next), (exit1, exit2) => pipe(exit1, Exit.zipRight(exit2)))
)
} else if (acc !== undefined) {
return acc
} else if (next !== undefined) {
return Effect.exit(next)
} else {
return undefined
}
},
undefined
)
return result === undefined ? result : result.traced(trace)
})
const fin1 = this.upstreamExecutor.close(exit)
const fins = [
...this.activeChildExecutors.map((child) => (child !== undefined ?
child.childExecutor.close(exit) :
undefined)
),
fin1
]
const result = fins.reduce(
(acc: Effect.Effect<R, never, Exit.Exit<unknown, unknown>> | undefined, next) => {
if (acc !== undefined && next !== undefined) {
return Effect.zipWith(
acc,
Effect.exit(next),
(exit1, exit2) => Exit.zipRight(exit1, exit2)
)
} else if (acc !== undefined) {
return acc
} else if (next !== undefined) {
return Effect.exit(next)
} else {
return undefined
}
},
undefined
)
return result === undefined ? result : result
}

@@ -236,6 +226,4 @@

close(exit: Exit.Exit<unknown, unknown>): Effect.Effect<R, never, unknown> | undefined {
return bodyWithTrace((trace) => {
const result = this.next.close(exit)
return result === undefined ? result : result.traced(trace)
})
const result = this.next.close(exit)
return result === undefined ? result : result
}

@@ -242,0 +230,0 @@

@@ -885,3 +885,3 @@ import * as Chunk from "@effect/data/Chunk"

input,
(cause) => Either.match(Cause.failureOrCause(cause), error, failCause),
(cause) => Either.match(Cause.failureOrCause(cause), { onLeft: error, onRight: failCause }),
done

@@ -888,0 +888,0 @@ )

@@ -171,8 +171,8 @@ import * as Chunk from "@effect/data/Chunk"

)
const output = yield* $(Effect.acquireRelease(
Queue.bounded<Exit.Exit<Option.Option<E | E2>, readonly [K, Queue.Dequeue<Take.Take<E | E2, V>>]>>(
const output = yield* $(Effect.acquireRelease({
acquire: Queue.bounded<Exit.Exit<Option.Option<E | E2>, readonly [K, Queue.Dequeue<Take.Take<E | E2, V>>]>>(
bufferSize
),
(queue) => Queue.shutdown(queue)
))
release: (queue) => Queue.shutdown(queue)
}))
const ref = yield* $(Ref.make<Map<K, number>>(new Map()))

@@ -184,3 +184,3 @@ const add = yield* $(

bufferSize,
([key, value]) => pipe(Deferred.await(decider), Effect.flatMap((f) => f(key, value))),
([key, value]) => Effect.flatMap(Deferred.await(decider), (f) => f(key, value)),
(exit) => Queue.offer(output, exit)

@@ -191,39 +191,31 @@ )

yield* $(
pipe(
Deferred.succeed(decider, (key, _) =>
pipe(
Ref.get(ref),
Effect.map((map) => Option.fromNullable(map.get(key))),
Effect.flatMap(Option.match(
() =>
pipe(
add,
Effect.flatMap(([index, queue]) =>
pipe(
Ref.update(ref, (map) => map.set(key, index)),
Effect.zipRight(
pipe(
Queue.offer(
output,
Exit.succeed(
[
key,
mapDequeue(queue, (exit) =>
new take.TakeImpl(pipe(
exit,
Exit.map((tuple) => Chunk.of(tuple[1]))
)))
] as const
)
),
Effect.as<Predicate<number>>((n: number) => n === index)
)
Deferred.succeed(decider, (key, _) =>
pipe(
Ref.get(ref),
Effect.map((map) => Option.fromNullable(map.get(key))),
Effect.flatMap(Option.match({
onNone: () =>
Effect.flatMap(add, ([index, queue]) =>
Effect.zipRight(
Ref.update(ref, (map) => map.set(key, index)),
pipe(
Queue.offer(
output,
Exit.succeed(
[
key,
mapDequeue(queue, (exit) =>
new take.TakeImpl(pipe(
exit,
Exit.map((tuple) => Chunk.of(tuple[1]))
)))
] as const
)
)
),
Effect.as<Predicate<number>>((n: number) => n === index)
)
),
(index) => Effect.succeed<Predicate<number>>((n: number) => n === index)
))
))
)
)),
onSome: (index) => Effect.succeed<Predicate<number>>((n: number) => n === index)
}))
))
)

@@ -261,2 +253,6 @@ return stream.flattenExitOption(stream.fromQueueWithShutdown(output))

isActive(): boolean {
return this.dequeue.isActive()
}
isShutdown(): Effect.Effect<never, never, boolean> {

@@ -329,3 +325,3 @@ return Queue.isShutdown(this.dequeue)

groupByIterable(f),
Effect.forEachDiscard(([key, values]) => {
Effect.forEach(([key, values]) => {
const innerQueue = map.get(key)

@@ -348,3 +344,3 @@ if (innerQueue === undefined) {

Cause.isInterruptedOnly(cause) ?
Option.some(Effect.unit()) :
Option.some(Effect.unit) :
Option.none()

@@ -362,7 +358,7 @@ )

Cause.isInterruptedOnly(cause) ?
Option.some(Effect.unit()) :
Option.some(Effect.unit) :
Option.none()
)
)
})
}, { discard: true })
)

@@ -378,3 +374,3 @@ ),

map.entries(),
Effect.forEachDiscard(([_, innerQueue]) =>
Effect.forEach(([_, innerQueue]) =>
pipe(

@@ -384,7 +380,6 @@ Queue.offer(innerQueue, take.end),

Cause.isInterruptedOnly(cause) ?
Option.some(Effect.unit()) :
Option.some(Effect.unit) :
Option.none()
)
)
),
), { discard: true }),
Effect.zipRight(Queue.offer(outerQueue, take.end))

@@ -400,6 +395,6 @@ )

pipe(
Effect.acquireRelease(
Queue.unbounded<Take.Take<E, readonly [K, Queue.Queue<Take.Take<E, A>>]>>(),
(queue) => Queue.shutdown(queue)
),
Effect.acquireRelease({
acquire: Queue.unbounded<Take.Take<E, readonly [K, Queue.Queue<Take.Take<E, A>>]>>(),
release: (queue) => Queue.shutdown(queue)
}),
Effect.flatMap((queue) =>

@@ -406,0 +401,0 @@ pipe(

@@ -24,3 +24,3 @@ import * as Chunk from "@effect/data/Chunk"

done(this: Emit.Emit<R, E, A, B>, exit: Exit.Exit<E, A>) {
return this(Effect.done(pipe(exit, Exit.mapBoth(Option.some, Chunk.of))))
return this(Effect.suspend(() => Exit.mapBoth(exit, { onFailure: Option.some, onSuccess: Chunk.of })))
},

@@ -34,3 +34,3 @@ end(this: Emit.Emit<R, E, A, B>) {

fromEffect(this: Emit.Emit<R, E, A, B>, effect: Effect.Effect<R, E, A>) {
return this(pipe(effect, Effect.mapBoth(Option.some, Chunk.of)))
return this(Effect.mapBoth(effect, { onFailure: Option.some, onSuccess: Chunk.of }))
},

@@ -37,0 +37,0 @@ fromEffectChunk(this: Emit.Emit<R, E, A, B>, effect: Effect.Effect<R, E, Chunk.Chunk<A>>) {

@@ -1,3 +0,2 @@

import { dualWithTrace, methodWithTrace } from "@effect/data/Debug"
import { pipe } from "@effect/data/Function"
import { dual, pipe } from "@effect/data/Function"
import * as Option from "@effect/data/Option"

@@ -99,111 +98,89 @@ import * as Deferred from "@effect/io/Deferred"

/** @internal */
export const make = methodWithTrace((trace) =>
<A>(): Effect.Effect<never, never, Handoff<A>> =>
pipe(
Deferred.make<never, void>(),
Effect.flatMap((deferred) => Ref.make(handoffStateEmpty(deferred))),
Effect.map((ref) => ({
[HandoffTypeId]: handoffVariance,
ref
}))
).traced(trace)
)
export const make = <A>(): Effect.Effect<never, never, Handoff<A>> =>
pipe(
Deferred.make<never, void>(),
Effect.flatMap((deferred) => Ref.make(handoffStateEmpty(deferred))),
Effect.map((ref) => ({
[HandoffTypeId]: handoffVariance,
ref
}))
)
/**
* @macro traced
* @internal
*/
export const offer = dualWithTrace<
/** @internal */
export const offer = dual<
<A>(value: A) => (self: Handoff<A>) => Effect.Effect<never, never, void>,
<A>(self: Handoff<A>, value: A) => Effect.Effect<never, never, void>
>(2, (trace) =>
(
self,
value
): Effect.Effect<never, never, void> => {
return pipe(
Deferred.make<never, void>(),
Effect.flatMap((deferred) =>
>(2, (self, value): Effect.Effect<never, never, void> => {
return Effect.flatMap(Deferred.make<never, void>(), (deferred) =>
Effect.flatten(
Ref.modify(self.ref, (state) =>
pipe(
Ref.modify(self.ref, (state) =>
pipe(
state,
handoffStateMatch(
(notifyConsumer) => [
pipe(
Deferred.succeed<never, void>(notifyConsumer, void 0),
Effect.zipRight(Deferred.await(deferred))
),
handoffStateFull(value, deferred)
],
(_, notifyProducer) => [
pipe(Deferred.await(notifyProducer), Effect.flatMap(() => pipe(self, offer(value)))),
state
]
)
)),
Effect.flatten
)
)
).traced(trace)
})
state,
handoffStateMatch(
(notifyConsumer) => [
Effect.zipRight(
Deferred.succeed<never, void>(notifyConsumer, void 0),
Deferred.await(deferred)
),
handoffStateFull(value, deferred)
],
(_, notifyProducer) => [
Effect.flatMap(
Deferred.await(notifyProducer),
() => pipe(self, offer(value))
),
state
]
)
))
))
})
/**
* @macro traced
* @since 1.0.0
*/
export const take = methodWithTrace((trace) =>
<A>(self: Handoff<A>): Effect.Effect<never, never, A> =>
pipe(
Deferred.make<never, void>(),
Effect.flatMap((deferred) =>
/** @internal */
export const take = <A>(self: Handoff<A>): Effect.Effect<never, never, A> =>
Effect.flatMap(Deferred.make<never, void>(), (deferred) =>
Effect.flatten(
Ref.modify(self.ref, (state) =>
pipe(
Ref.modify(self.ref, (state) =>
pipe(
state,
handoffStateMatch(
(notifyConsumer) => [
pipe(Deferred.await(notifyConsumer), Effect.flatMap(() => take(self))),
state
],
(value, notifyProducer) => [
pipe(Deferred.succeed<never, void>(notifyProducer, void 0), Effect.as(value)),
handoffStateEmpty(deferred)
]
)
)),
Effect.flatten
)
)
).traced(trace)
)
state,
handoffStateMatch(
(notifyConsumer) => [
Effect.flatMap(
Deferred.await(notifyConsumer),
() => take(self)
),
state
],
(value, notifyProducer) => [
Effect.as(
Deferred.succeed<never, void>(notifyProducer, void 0),
value
),
handoffStateEmpty(deferred)
]
)
))
))
/**
* @macro traced
* @internal
*/
export const poll = methodWithTrace((trace) =>
<A>(self: Handoff<A>): Effect.Effect<never, never, Option.Option<A>> =>
pipe(
Deferred.make<never, void>(),
Effect.flatMap((deferred) =>
/** @internal */
export const poll = <A>(self: Handoff<A>): Effect.Effect<never, never, Option.Option<A>> =>
Effect.flatMap(Deferred.make<never, void>(), (deferred) =>
Effect.flatten(
Ref.modify(self.ref, (state) =>
pipe(
Ref.modify(self.ref, (state) =>
pipe(
state,
handoffStateMatch(
() => [
Effect.succeed(Option.none() as Option.Option<A>),
state
],
(value, notifyProducer) => [
pipe(Deferred.succeed<never, void>(notifyProducer, void 0), Effect.as(Option.some(value))),
handoffStateEmpty(deferred)
]
)
)),
Effect.flatten
)
)
).traced(trace)
)
state,
handoffStateMatch(
() => [
Effect.succeed(Option.none<A>()),
state
],
(value, notifyProducer) => [
Effect.as(
Deferred.succeed<never, void>(notifyProducer, void 0),
Option.some(value)
),
handoffStateEmpty(deferred)
]
)
))
))
import * as Chunk from "@effect/data/Chunk"
import { methodWithTrace } from "@effect/data/Debug"
import { pipe } from "@effect/data/Function"
import * as Option from "@effect/data/Option"

@@ -14,60 +12,25 @@ import type * as Cause from "@effect/io/Cause"

/**
* @macro traced
* @internal
*/
export const emit = methodWithTrace((trace) =>
<A>(value: A): Effect.Effect<never, never, Chunk.Chunk<A>> => Effect.succeed(Chunk.of(value)).traced(trace)
)
/** @internal */
export const emit = <A>(value: A): Effect.Effect<never, never, Chunk.Chunk<A>> => Effect.succeed(Chunk.of(value))
/**
* @macro traced
* @internal
*/
export const emitChunk = methodWithTrace((trace) =>
<A>(chunk: Chunk.Chunk<A>): Effect.Effect<never, never, Chunk.Chunk<A>> => Effect.succeed(chunk).traced(trace)
)
/** @internal */
export const emitChunk = <A>(chunk: Chunk.Chunk<A>): Effect.Effect<never, never, Chunk.Chunk<A>> =>
Effect.succeed(chunk)
/**
* @macro traced
* @internal
*/
export const empty = methodWithTrace((trace) =>
<A>(): Effect.Effect<never, never, Chunk.Chunk<A>> => Effect.succeed(Chunk.empty<A>()).traced(trace)
)
/** @internal */
export const empty = <A>(): Effect.Effect<never, never, Chunk.Chunk<A>> => Effect.succeed(Chunk.empty<A>())
/**
* @macro traced
* @internal
*/
export const end = methodWithTrace((trace) =>
(): Effect.Effect<never, Option.Option<never>, never> => Effect.fail(Option.none()).traced(trace)
)
/** @internal */
export const end = (): Effect.Effect<never, Option.Option<never>, never> => Effect.fail(Option.none())
/**
* @macro traced
* @internal
*/
export const fail = methodWithTrace((trace) =>
<E>(error: E): Effect.Effect<never, Option.Option<E>, never> => Effect.fail(Option.some(error)).traced(trace)
)
/** @internal */
export const fail = <E>(error: E): Effect.Effect<never, Option.Option<E>, never> => Effect.fail(Option.some(error))
/**
* @macro traced
* @internal
*/
export const failCause = methodWithTrace((trace) =>
<E>(cause: Cause.Cause<E>): Effect.Effect<never, Option.Option<E>, never> =>
pipe(Effect.failCause(cause), Effect.mapError(Option.some)).traced(trace)
)
/** @internal */
export const failCause = <E>(cause: Cause.Cause<E>): Effect.Effect<never, Option.Option<E>, never> =>
Effect.mapError(Effect.failCause(cause), Option.some)
/**
* @macro traced
* @internal
*/
export const fromDequeue = methodWithTrace((trace) =>
<E, A>(
dequeue: Queue.Dequeue<Take.Take<E, A>>
): Effect.Effect<never, Option.Option<E>, Chunk.Chunk<A>> =>
pipe(Queue.take(dequeue), Effect.flatMap(take.done)).traced(trace)
)
/** @internal */
export const fromDequeue = <E, A>(
dequeue: Queue.Dequeue<Take.Take<E, A>>
): Effect.Effect<never, Option.Option<E>, Chunk.Chunk<A>> => Effect.flatMap(Queue.take(dequeue), take.done)

@@ -1,7 +0,6 @@

import { bodyWithTrace, dualWithTrace, methodWithTrace } from "@effect/data/Debug"
import { pipe } from "@effect/data/Function"
import { dual, pipe } from "@effect/data/Function"
import * as Effect from "@effect/io/Effect"
import * as Hub from "@effect/io/Hub"
import * as _circular from "@effect/io/internal_effect_untraced/effect/circular"
import * as _ref from "@effect/io/internal_effect_untraced/ref"
import * as _circular from "@effect/io/internal/effect/circular"
import * as _ref from "@effect/io/internal/ref"
import * as Ref from "@effect/io/Ref"

@@ -57,21 +56,17 @@ import * as Synchronized from "@effect/io/Ref/Synchronized"

}
/** @macro traced */
modify<B>(f: (a: A) => readonly [B, A]): Effect.Effect<never, never, B> {
return bodyWithTrace((trace) => this.modifyEffect((a) => Effect.succeed(f(a))).traced(trace))
return this.modifyEffect((a) => Effect.succeed(f(a)))
}
/** @macro traced */
modifyEffect<R, E, B>(f: (a: A) => Effect.Effect<R, E, readonly [B, A]>): Effect.Effect<R, E, B> {
return bodyWithTrace((trace) =>
pipe(
Ref.get(this.ref),
Effect.flatMap(f),
Effect.flatMap(([b, a]) =>
pipe(
Ref.set(this.ref, a),
Effect.as(b),
Effect.zipLeft(Hub.publish(this.hub, a))
)
),
this.semaphore.withPermits(1)
).traced(trace)
return pipe(
Ref.get(this.ref),
Effect.flatMap(f),
Effect.flatMap(([b, a]) =>
pipe(
Ref.set(this.ref, a),
Effect.as(b),
Effect.zipLeft(Hub.publish(this.hub, a))
)
),
this.semaphore.withPermits(1)
)

@@ -82,21 +77,17 @@ }

/** @internal */
export const get = methodWithTrace((trace) =>
<A>(self: SubscriptionRef.SubscriptionRef<A>): Effect.Effect<never, never, A> => Ref.get(self.ref).traced(trace)
)
export const get = <A>(self: SubscriptionRef.SubscriptionRef<A>): Effect.Effect<never, never, A> => Ref.get(self.ref)
/** @internal */
export const make = methodWithTrace((trace) =>
<A>(value: A): Effect.Effect<never, never, SubscriptionRef.SubscriptionRef<A>> =>
pipe(
Effect.all(
Hub.unbounded<A>(),
Ref.make(value),
Effect.makeSemaphore(1)
),
Effect.map(([hub, ref, semaphore]) => new SubscriptionRefImpl(ref, hub, semaphore))
).traced(trace)
)
export const make = <A>(value: A): Effect.Effect<never, never, SubscriptionRef.SubscriptionRef<A>> =>
pipe(
Effect.all(
Hub.unbounded<A>(),
Ref.make(value),
Effect.makeSemaphore(1)
),
Effect.map(([hub, ref, semaphore]) => new SubscriptionRefImpl(ref, hub, semaphore))
)
/** @internal */
export const modify = dualWithTrace<
export const modify = dual<
<A, B>(f: (a: A) => readonly [B, A]) => (self: SubscriptionRef.SubscriptionRef<A>) => Effect.Effect<never, never, B>,

@@ -107,10 +98,9 @@ <A, B>(

) => Effect.Effect<never, never, B>
>(2, (trace) =>
<A, B>(
self: SubscriptionRef.SubscriptionRef<A>,
f: (a: A) => readonly [B, A]
): Effect.Effect<never, never, B> => self.modify(f).traced(trace))
>(2, <A, B>(
self: SubscriptionRef.SubscriptionRef<A>,
f: (a: A) => readonly [B, A]
): Effect.Effect<never, never, B> => self.modify(f))
/** @internal */
export const modifyEffect = dualWithTrace<
export const modifyEffect = dual<
<A, R, E, B>(

@@ -123,10 +113,9 @@ f: (a: A) => Effect.Effect<R, E, readonly [B, A]>

) => Effect.Effect<R, E, B>
>(2, (trace) =>
<A, R, E, B>(
self: SubscriptionRef.SubscriptionRef<A>,
f: (a: A) => Effect.Effect<R, E, readonly [B, A]>
): Effect.Effect<R, E, B> => self.modifyEffect(f).traced(trace))
>(2, <A, R, E, B>(
self: SubscriptionRef.SubscriptionRef<A>,
f: (a: A) => Effect.Effect<R, E, readonly [B, A]>
): Effect.Effect<R, E, B> => self.modifyEffect(f))
/** @internal */
export const set = dualWithTrace<
export const set = dual<
<A>(value: A) => (self: SubscriptionRef.SubscriptionRef<A>) => Effect.Effect<never, never, void>,

@@ -137,11 +126,10 @@ <A>(

) => Effect.Effect<never, never, void>
>(2, (trace) =>
<A>(
self: SubscriptionRef.SubscriptionRef<A>,
value: A
): Effect.Effect<never, never, void> =>
pipe(
Ref.set(self.ref, value),
Effect.zipLeft(Hub.publish(self.hub, value)),
self.semaphore.withPermits(1)
).traced(trace))
>(2, <A>(
self: SubscriptionRef.SubscriptionRef<A>,
value: A
): Effect.Effect<never, never, void> =>
pipe(
Ref.set(self.ref, value),
Effect.zipLeft(Hub.publish(self.hub, value)),
self.semaphore.withPermits(1)
))
import * as Chunk from "@effect/data/Chunk"
import { dualWithTrace, methodWithTrace } from "@effect/data/Debug"
import { constFalse, constTrue, dual, pipe } from "@effect/data/Function"

@@ -42,6 +41,4 @@ import * as Option from "@effect/data/Option"

/** @internal */
export const done = methodWithTrace((trace) =>
<E, A>(self: Take.Take<E, A>): Effect.Effect<never, Option.Option<E>, Chunk.Chunk<A>> =>
pipe(Effect.done(self.exit)).traced(trace)
)
export const done = <E, A>(self: Take.Take<E, A>): Effect.Effect<never, Option.Option<E>, Chunk.Chunk<A>> =>
Effect.suspend(() => self.exit)

@@ -59,52 +56,42 @@ /** @internal */

/** @internal */
export const fromEffect = methodWithTrace((trace) =>
<R, E, A>(effect: Effect.Effect<R, E, A>): Effect.Effect<R, never, Take.Take<E, A>> =>
pipe(effect, Effect.matchCause(failCause, of)).traced(trace)
)
export const fromEffect = <R, E, A>(effect: Effect.Effect<R, E, A>): Effect.Effect<R, never, Take.Take<E, A>> =>
Effect.matchCause(effect, { onFailure: failCause, onSuccess: of })
/** @internal */
export const fromExit = <E, A>(exit: Exit.Exit<E, A>): Take.Take<E, A> =>
new TakeImpl(pipe(exit, Exit.mapBoth(Option.some, Chunk.of)))
new TakeImpl(pipe(exit, Exit.mapBoth({ onFailure: Option.some, onSuccess: Chunk.of })))
/** @internal */
export const fromPull = methodWithTrace((trace) =>
<R, E, A>(
pull: Effect.Effect<R, Option.Option<E>, Chunk.Chunk<A>>
): Effect.Effect<R, never, Take.Take<E, A>> =>
pipe(
pull,
Effect.matchCause((cause) =>
pipe(
Cause.flipCauseOption(cause),
Option.match(() => end, failCause)
), chunk)
).traced(trace)
)
export const fromPull = <R, E, A>(
pull: Effect.Effect<R, Option.Option<E>, Chunk.Chunk<A>>
): Effect.Effect<R, never, Take.Take<E, A>> =>
Effect.matchCause(pull, {
onFailure: (cause) =>
Option.match(Cause.flipCauseOption(cause), {
onNone: () => end,
onSome: failCause
}),
onSuccess: chunk
})
/** @internal */
export const isDone = <E, A>(self: Take.Take<E, A>): boolean =>
pipe(
self.exit,
Exit.match(
(cause) => Option.isNone(Cause.flipCauseOption(cause)),
constFalse
)
)
Exit.match(self.exit, {
onFailure: (cause) => Option.isNone(Cause.flipCauseOption(cause)),
onSuccess: constFalse
})
/** @internal */
export const isFailure = <E, A>(self: Take.Take<E, A>): boolean =>
pipe(
self.exit,
Exit.match(
(cause) => Option.isSome(Cause.flipCauseOption(cause)),
constFalse
)
)
Exit.match(self.exit, {
onFailure: (cause) => Option.isSome(Cause.flipCauseOption(cause)),
onSuccess: constFalse
})
/** @internal */
export const isSuccess = <E, A>(self: Take.Take<E, A>): boolean =>
pipe(
self.exit,
Exit.match(constFalse, constTrue)
)
Exit.match(self.exit, {
onFailure: constFalse,
onSuccess: constTrue
})

@@ -135,12 +122,13 @@ /** @internal */

): Z | Z2 | Z3 =>
pipe(
self.exit,
Exit.match<Option.Option<E>, Chunk.Chunk<A>, Z | Z2 | Z3>(
(cause) => pipe(Cause.flipCauseOption(cause), Option.match(onEnd, onError)),
onSuccess
)
))
Exit.match<Option.Option<E>, Chunk.Chunk<A>, Z | Z2 | Z3>(self.exit, {
onFailure: (cause) =>
Option.match(Cause.flipCauseOption(cause), {
onNone: onEnd,
onSome: onError
}),
onSuccess
}))
/** @internal */
export const matchEffect = dualWithTrace<
export const matchEffect = dual<
<R, E2, Z, R2, E, Z2, A, R3, E3, Z3>(

@@ -157,16 +145,16 @@ onEnd: () => Effect.Effect<R, E2, Z>,

) => Effect.Effect<R | R2 | R3, E2 | E | E3, Z | Z2 | Z3>
>(4, (trace) =>
<R, E2, Z, R2, E, Z2, A, R3, E3, Z3>(
self: Take.Take<E, A>,
onEnd: () => Effect.Effect<R, E2, Z>,
onError: (cause: Cause.Cause<E>) => Effect.Effect<R2, E2, Z2>,
onSuccess: (chunk: Chunk.Chunk<A>) => Effect.Effect<R3, E3, Z3>
): Effect.Effect<R | R2 | R3, E | E2 | E3, Z | Z2 | Z3> =>
pipe(
self.exit,
Exit.matchEffect<Option.Option<E>, Chunk.Chunk<A>, R | R2, E | E2, Z | Z2, R3, E3, Z3>(
(cause) => pipe(Cause.flipCauseOption(cause), Option.match(onEnd, onError)),
onSuccess
)
).traced(trace))
>(4, <R, E2, Z, R2, E, Z2, A, R3, E3, Z3>(
self: Take.Take<E, A>,
onEnd: () => Effect.Effect<R, E2, Z>,
onError: (cause: Cause.Cause<E>) => Effect.Effect<R2, E2, Z2>,
onSuccess: (chunk: Chunk.Chunk<A>) => Effect.Effect<R3, E3, Z3>
): Effect.Effect<R | R2 | R3, E | E2 | E3, Z | Z2 | Z3> =>
Exit.matchEffect<Option.Option<E>, Chunk.Chunk<A>, R | R2, E | E2, Z | Z2, R3, E3, Z3>(self.exit, {
onFailure: (cause) =>
Option.match(Cause.flipCauseOption(cause), {
onNone: onEnd,
onSome: onError
}),
onSuccess
}))

@@ -187,3 +175,3 @@ /** @internal */

/** @internal */
export const tap = dualWithTrace<
export const tap = dual<
<A, R, E2, _>(

@@ -196,9 +184,5 @@ f: (chunk: Chunk.Chunk<A>) => Effect.Effect<R, E2, _>

) => Effect.Effect<R, E2 | E, void>
>(
2,
(trace) =>
<E, A, R, E2, _>(
self: Take.Take<E, A>,
f: (chunk: Chunk.Chunk<A>) => Effect.Effect<R, E2, _>
): Effect.Effect<R, E | E2, void> => pipe(self.exit, Exit.forEachEffect(f), Effect.asUnit).traced(trace)
)
>(2, <E, A, R, E2, _>(
self: Take.Take<E, A>,
f: (chunk: Chunk.Chunk<A>) => Effect.Effect<R, E2, _>
): Effect.Effect<R, E | E2, void> => pipe(self.exit, Exit.forEachEffect(f), Effect.asUnit))

@@ -1046,178 +1046,2 @@ /**

/**
* Logs the specified message at the current log level.
*
* @since 1.0.0
* @category logging
*/
export const log: (message: string) => Sink<never, never, unknown, never, void> = internal.log
/**
* Logs the specified message at the debug log level.
*
* @since 1.0.0
* @category logging
*/
export const logDebug: (message: string) => Sink<never, never, unknown, never, void> = internal.logDebug
/**
* Logs the specified `Cause` at the debug log level.
*
* @since 1.0.0
* @category logging
*/
export const logDebugCause: <E>(cause: Cause.Cause<E>) => Sink<never, never, unknown, never, void> =
internal.logDebugCause
/**
* Logs the specified message and `Cause` at the debug log level.
*
* @since 1.0.0
* @category logging
*/
export const logDebugCauseMessage: <E>(
message: string,
cause: Cause.Cause<E>
) => Sink<never, never, unknown, never, void> = internal.logDebugCauseMessage
/**
* Logs the specified message at the error log level.
*
* @since 1.0.0
* @category logging
*/
export const logError: (message: string) => Sink<never, never, unknown, never, void> = internal.logError
/**
* Logs the specified `Cause` at the error log level.
*
* @since 1.0.0
* @category logging
*/
export const logErrorCause: <E>(cause: Cause.Cause<E>) => Sink<never, never, unknown, never, void> =
internal.logErrorCause
/**
* Logs the specified message and `Cause` at the error log level.
*
* @since 1.0.0
* @category logging
*/
export const logErrorCauseMessage: <E>(
message: string,
cause: Cause.Cause<E>
) => Sink<never, never, unknown, never, void> = internal.logErrorCauseMessage
/**
* Logs the specified message at the fatal log level.
*
* @since 1.0.0
* @category logging
*/
export const logFatal: (message: string) => Sink<never, never, unknown, never, void> = internal.logFatal
/**
* Logs the specified `Cause` at the fatal log level.
*
* @since 1.0.0
* @category logging
*/
export const logFatalCause: <E>(cause: Cause.Cause<E>) => Sink<never, never, unknown, never, void> =
internal.logFatalCause
/**
* Logs the specified message and `Cause` at the fatal log level.
*
* @since 1.0.0
* @category logging
*/
export const logFatalCauseMessage: <E>(
message: string,
cause: Cause.Cause<E>
) => Sink<never, never, unknown, never, void> = internal.logFatalCauseMessage
/**
* Logs the specified message at the info log level.
*
* @since 1.0.0
* @category logging
*/
export const logInfo: (message: string) => Sink<never, never, unknown, never, void> = internal.logInfo
/**
* Logs the specified `Cause` at the info log level.
*
* @since 1.0.0
* @category logging
*/
export const logInfoCause: <E>(cause: Cause.Cause<E>) => Sink<never, never, unknown, never, void> =
internal.logInfoCause
/**
* Logs the specified message and `Cause` at the info log level.
*
* @since 1.0.0
* @category logging
*/
export const logInfoCauseMessage: <E>(
message: string,
cause: Cause.Cause<E>
) => Sink<never, never, unknown, never, void> = internal.logInfoCauseMessage
/**
* Logs the specified message at the warning log level.
*
* @since 1.0.0
* @category logging
*/
export const logWarning: (message: string) => Sink<never, never, unknown, never, void> = internal.logWarning
/**
* Logs the specified `Cause` at the warning log level.
*
* @since 1.0.0
* @category logging
*/
export const logWarningCause: <E>(cause: Cause.Cause<E>) => Sink<never, never, unknown, never, void> =
internal.logWarningCause
/**
* Logs the specified message and `Cause` at the warning log level.
*
* @since 1.0.0
* @category logging
*/
export const logWarningCauseMessage: <E>(
message: string,
cause: Cause.Cause<E>
) => Sink<never, never, unknown, never, void> = internal.logWarningCauseMessage
/**
* Logs the specified message at the trace log level.
*
* @since 1.0.0
* @category logging
*/
export const logTrace: (message: string) => Sink<never, never, unknown, never, void> = internal.logTrace
/**
* Logs the specified `Cause` at the trace log level.
*
* @since 1.0.0
* @category logging
*/
export const logTraceCause: <E>(cause: Cause.Cause<E>) => Sink<never, never, unknown, never, void> =
internal.logTraceCause
/**
* Logs the specified message and `Cause` at the trace log level.
*
* @since 1.0.0
* @category logging
*/
export const logTraceCauseMessage: <E>(
message: string,
cause: Cause.Cause<E>
) => Sink<never, never, unknown, never, void> = internal.logTraceCauseMessage
/**
* Transforms this sink's result.

@@ -1224,0 +1048,0 @@ *

/**
* @since 1.0.0
*/
import type * as Option from "@effect/data/Option"
import type * as Effect from "@effect/io/Effect"

@@ -10,3 +11,2 @@ import type * as Hub from "@effect/io/Hub"

import type * as Stream from "@effect/stream/Stream"
import type * as Option from "@effect/data/Option"

@@ -62,3 +62,2 @@ /**

/**
* @macro traced
* @since 1.0.0

@@ -70,3 +69,2 @@ * @category getters

/**
* @macro traced
* @since 1.0.0

@@ -81,3 +79,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -92,3 +89,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -103,3 +99,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -114,3 +109,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -132,3 +126,2 @@ * @category utils

*
* @macro traced
* @since 1.0.0

@@ -140,3 +133,2 @@ * @category constructors

/**
* @macro traced
* @since 1.0.0

@@ -151,3 +143,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -162,3 +153,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -180,3 +170,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -198,3 +187,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -209,3 +197,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -220,3 +207,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -231,3 +217,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -242,3 +227,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -253,3 +237,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -264,3 +247,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -275,3 +257,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -291,3 +272,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -302,3 +282,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -305,0 +284,0 @@ * @category utils

@@ -79,3 +79,2 @@ /**

*
* @macro traced
* @since 1.0.0

@@ -115,3 +114,2 @@ * @category destructors

*
* @macro traced
* @since 1.0.0

@@ -136,3 +134,2 @@ * @category constructors

*
* @macro traced
* @since 1.0.0

@@ -215,3 +212,2 @@ * @category constructors

*
* @macro traced
* @since 1.0.0

@@ -245,3 +241,2 @@ * @category destructors

*
* @macro traced
* @since 1.0.0

@@ -248,0 +243,0 @@ * @category sequencing

/**
* @since 1.0.0
*/
import type * as Option from "@effect/data/Option";
import type * as Effect from "@effect/io/Effect";
import * as Synchronized from "@effect/io/Ref/Synchronized";
import type * as Stream from "@effect/stream/Stream";
import type * as Option from "@effect/data/Option";
/**

@@ -47,3 +47,2 @@ * @since 1.0.0

/**
* @macro traced
* @since 1.0.0

@@ -54,3 +53,2 @@ * @category getters

/**
* @macro traced
* @since 1.0.0

@@ -64,3 +62,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -74,3 +71,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -84,3 +80,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -94,3 +89,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -106,3 +100,2 @@ * @category utils

*
* @macro traced
* @since 1.0.0

@@ -113,3 +106,2 @@ * @category constructors

/**
* @macro traced
* @since 1.0.0

@@ -123,3 +115,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -133,3 +124,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -143,3 +133,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -153,3 +142,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -163,3 +151,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -173,3 +160,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -183,3 +169,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -193,3 +178,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -203,3 +187,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -213,3 +196,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -223,3 +205,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -233,3 +214,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -243,3 +223,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -246,0 +225,0 @@ * @category utils

@@ -18,3 +18,2 @@ "use strict";

/**
* @macro traced
* @since 1.0.0

@@ -26,3 +25,2 @@ * @category getters

/**
* @macro traced
* @since 1.0.0

@@ -34,3 +32,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -42,3 +39,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -50,3 +46,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -58,3 +53,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -68,3 +62,2 @@ * @category utils

*
* @macro traced
* @since 1.0.0

@@ -76,3 +69,2 @@ * @category constructors

/**
* @macro traced
* @since 1.0.0

@@ -84,3 +76,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -92,3 +83,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -100,3 +90,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -108,3 +97,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -116,3 +104,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -124,3 +111,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -132,3 +118,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -140,3 +125,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -148,3 +132,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -156,3 +139,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -164,3 +146,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -172,3 +153,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -180,3 +160,2 @@ * @category utils

/**
* @macro traced
* @since 1.0.0

@@ -183,0 +162,0 @@ * @category utils

@@ -68,3 +68,2 @@ /**

*
* @macro traced
* @since 1.0.0

@@ -100,3 +99,2 @@ * @category destructors

*
* @macro traced
* @since 1.0.0

@@ -118,3 +116,2 @@ * @category constructors

*
* @macro traced
* @since 1.0.0

@@ -179,3 +176,2 @@ * @category constructors

*
* @macro traced
* @since 1.0.0

@@ -198,3 +194,2 @@ * @category destructors

*
* @macro traced
* @since 1.0.0

@@ -201,0 +196,0 @@ * @category sequencing

@@ -42,3 +42,2 @@ "use strict";

*
* @macro traced
* @since 1.0.0

@@ -78,3 +77,2 @@ * @category destructors

*
* @macro traced
* @since 1.0.0

@@ -98,3 +96,2 @@ * @category constructors

*
* @macro traced
* @since 1.0.0

@@ -160,3 +157,2 @@ * @category constructors

*
* @macro traced
* @since 1.0.0

@@ -178,3 +174,2 @@ * @category destructors

*
* @macro traced
* @since 1.0.0

@@ -181,0 +176,0 @@ * @category sequencing

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc