Skip to main content
Module

x/async_channels/mod.ts>Channel#with

Inspired by Go & Clojure Channels, async_channels provides channels as an asynchronous communication method between asynchronous functions.
Latest
method Channel.prototype.with
Re-export
import { Channel } from "https://deno.land/x/async_channels@v1.0.0-rc8/mod.ts";

Applies fn on this and returns the result.

Examples

Example 1

import { Channel } from "./channel.ts";
import { map } from "./pipe.ts";
const srcCh = new Channel<number>(1);
const resCh = srcCh.with(map(n => n * 2));
await srcCh.send(5);
srcCh.close();
console.assert(await resCh.get() === [10, true]);

Type Parameters

TOut
TThis extends Receiver<T>

Parameters

this: TThis
fn: (t: TThis) => TOut