From 59d95227dd9f03a47e094ea65bdf9830c9f05f6a Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 26 Aug 2024 06:28:59 +0200 Subject: [PATCH] feat(`effect/Micro)`: add isMicroCause (#3501) Co-authored-by: Tim --- .changeset/chilled-toys-share.md | 5 +++++ packages/effect/src/Micro.ts | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .changeset/chilled-toys-share.md diff --git a/.changeset/chilled-toys-share.md b/.changeset/chilled-toys-share.md new file mode 100644 index 0000000000..4fe8124432 --- /dev/null +++ b/.changeset/chilled-toys-share.md @@ -0,0 +1,5 @@ +--- +"effect": patch +--- + +add `Micro.isMicroCause` guard diff --git a/packages/effect/src/Micro.ts b/packages/effect/src/Micro.ts index 808acf4be8..74b84e95e6 100644 --- a/packages/effect/src/Micro.ts +++ b/packages/effect/src/Micro.ts @@ -19,7 +19,7 @@ import { StructuralPrototype } from "./internal/effectable.js" import { SingleShotGen } from "./internal/singleShotGen.js" import * as Option from "./Option.js" import { type Pipeable, pipeArguments } from "./Pipeable.js" -import { isIterable, isTagged, type Predicate, type Refinement } from "./Predicate.js" +import { hasProperty, isIterable, isTagged, type Predicate, type Refinement } from "./Predicate.js" import type { ReadonlyRecord } from "./Record.js" import type { Sink, SinkTypeId } from "./Sink.js" import type { Stream, StreamTypeId } from "./Stream.js" @@ -171,6 +171,13 @@ export type MicroCauseTypeId = typeof MicroCauseTypeId */ export type MicroCause = MicroCause.Die | MicroCause.Fail | MicroCause.Interrupt +/** + * @since 3.6.6 + * @experimental + * @category guards + */ +export const isMicroCause = (self: unknown): self is MicroCause => hasProperty(self, MicroCauseTypeId) + /** * @since 3.4.6 * @experimental