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

x/easyts/channel.ts>selectChan

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

wait for a case to complete

Examples

Example 1

const c0 = a.readCase()
const c1= b.writeCase()
const c2 = c.readCase()
switch (await selectChan(c0, c1,c2)) {
    case c0:
        break
    case c1:
        break
    case c2:
        break
}

default

const c0 = c.readCase()
switch (selectChan(0, c0)) {
    case c0:
        break
    case 0:
        break
}

Parameters

def: 0
...cases: Array<CaseLike>

wait for a case to complete

Parameters

...cases: Array<CaseLike>

returns an Promise that waits forever

Returns

Promise<any>