Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/async_channels/src/channel.ts>Channel#flatMap

Inspired by Go & Clojure Channels, async_channels provides channels as an asynchronous communication method between asynchronous functions.
Go to Latest
method Channel.prototype.flatMap
import { Channel } from "https://deno.land/x/async_channels@v1.0.0-rc5/src/channel.ts";

flatMap returns a receiver channel that contains the flattened (1 level) results of applying fn to each value of this channel.

The receiver channel will close, when the original channel closes (or if the provided signal is triggered).

Parameters

fn: (val: T) =>
| Iterable<TOut>
| AsyncIterable<TOut>
| Promise<Iterable<TOut>>
| Promise<AsyncIterable<TOut>>
optional
pipeOpts: ChannelPipeOptions