Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/easyts/mod.ts>ReadChannel

js library written with ts, use select and chan like golang in js.
Latest
interface ReadChannel
import { type ReadChannel } from "https://deno.land/x/easyts@0.1.3/mod.ts";

a read-only channel

Properties

readonly
isClosed: boolean

Returns whether the channel is closed

readonly
length: number

Returns the channel buffer size

readonly
capacity: number

Returns how much data the channel has buffered

Methods

read(): ReadReturn<T>

Read a value from the channel, block if there is no value to read, and return until there is a value or the channel is closed

readRaw(): ReadRawReturn<T>

Read a value from the channel, block if there is no value to read, and return until there is a value or the channel is closed

tryRead(): IteratorResult<T> | undefined

Attempts to read a value from the channel, returns undefined if no value is readable, returns {done:true} if the channel is closed

readCase(): ReadCase<T>

Create a case for select to read

[[Symbol.asyncIterator]](): AsyncGenerator<T>

Implement asynchronous iterators

wait(): undefined | Promise<void>

Wait for chan to close, no data will be read from chan