Skip to main content

Built and signed on GitHub Actions

This package works with Node.js, DenoIt is unknown whether this package works with Cloudflare Workers, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
94%
Published
3 days ago (0.1.0)
function map
map<
Tin = unknown,
Tout = Tin,
>
(
readable: ReadableStream<Tin>,
...transformers: ITransformer<any, any>[],
): ReadableStream<Tout>

Creates a new stream by applying one or more transform functions to each chunk of the input stream. When many functions are provided, they are applied in order.

Examples

Example 1

const asInt = map<string, number>(readable, parseInt);

Example 2

const asUpperCase = map<string, string>(readable, item => item.toUpperCase());

Example 3

const asDouble = map<number, number>(readable, item => item * 2);

Example 4

const asLength = map<string, number>(readable, item => item.length);

Example 5

const asJSONobj = map<unknown, string>(readable, JSON.stringify, JSON.parse);

Type Parameters

Tin = unknown
Tout = Tin

Parameters

The input stream

...transformers: ITransformer<any, any>[]

Return Type

A readable stream whose chunks are the result of applying the transform functions (sequentially) to the input chunks

Add Package

deno add jsr:@sgmonda/qfu

Import symbol

import { map } from "@sgmonda/qfu";

---- OR ----

Import directly with a jsr specifier

import { map } from "jsr:@sgmonda/qfu";

Add Package

npx jsr add @sgmonda/qfu

Import symbol

import { map } from "@sgmonda/qfu";

Add Package

yarn dlx jsr add @sgmonda/qfu

Import symbol

import { map } from "@sgmonda/qfu";

Add Package

pnpm dlx jsr add @sgmonda/qfu

Import symbol

import { map } from "@sgmonda/qfu";

Add Package

bunx jsr add @sgmonda/qfu

Import symbol

import { map } from "@sgmonda/qfu";