(u: unknown): u is Sink<unknown, never, unknown, unknown, unknown>Checks whether a value is a Sink.
Example (Checking for a sink)
import { Sink } from "effect"
const sink = Sink.never
const notStream = { data: [1, 2, 3] }
console.log(Sink.isSink(sink)) // true
console.log(Sink.isSink(notStream)) // falseexport const const isSink: (
u: unknown
) => u is Sink<
unknown,
never,
unknown,
unknown,
unknown
>
Checks whether a value is a Sink.
Example (Checking for a sink)
import { Sink } from "effect"
const sink = Sink.never
const notStream = { data: [1, 2, 3] }
console.log(Sink.isSink(sink)) // true
console.log(Sink.isSink(notStream)) // false
isSink = (u: unknownu: unknown): u: unknownu is interface Sink<out A, in In = unknown, out L = never, out E = never, out R = never>A Sink<A, In, L, E, R> is used to consume elements produced by a Stream.
You can think of a sink as a function that will consume a variable amount of
In elements (could be 0, 1, or many), might fail with an error of type E,
and will eventually yield a value of type A together with a remainder of
type L (i.e. any leftovers).
Example (Running a sink with a stream)
import { Effect, Sink, Stream } from "effect"
// Create a simple sink that always succeeds with a value
const sink: Sink.Sink<number> = Sink.succeed(42)
// Use the sink to consume a stream
const stream = Stream.make(1, 2, 3)
const program = Stream.run(stream, sink)
Effect.runPromise(program).then(console.log)
// Output: 42
Namespace containing types and interfaces for Sink variance and type relationships.
Sink<unknown, never, unknown, unknown, unknown> => hasProperty<"~effect/Sink">(self: unknown, property: "~effect/Sink"): self is { [K in "~effect/Sink"]: unknown; } (+1 overload)Checks whether a value has a given property key.
When to use
Use when you need a Predicate guard for property access on unknown
values with a simple structural object check.
Details
Uses the in operator and isObjectKeyword. This does not check property
value types.
Example (Guarding object properties)
import { Predicate } from "effect"
const hasName = Predicate.hasProperty("name")
const data: unknown = { name: "Ada" }
if (hasName(data)) {
console.log(data.name)
}
hasProperty(u: unknownu, const TypeId: "~effect/Sink"TypeId)