New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

stream-transformers

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-transformers

Reusable stream transformers for WHATWG Streams similar to ReactiveX Operators

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

stream-transformers

Node.js CI NPM version license TypeScript types

Reusable stream transformers for WHATWG Streams similar to ReactiveX Operators

Table of Contents

Install

Use either

yarn add stream-transformers

or

npm install stream-transformers

Usage

This module allows you to test WHATWG Streams with [Marble Syntax] in Jest.

import { ReadableStream } from "isomorphic-streams";
import { filter, map } from "stream-transformers";

const SECOND = 1000;

const stream = new ReadableStream({
  start(controller) {
    let index = 0;
    setInterval(() => {
      controller.enqueue(index);
      index += 1;
    }, SECOND);
  },
});

const output = stream.pipeThrough(map((it) => it * 2)).pipeThrough(filter((it) => it < 10));

for await (const value of output) {
  console.dir(value);
}

Operators

  • every - Determines whether every chunk of the stream fulfills a given predicate.
  • filter - Filters chunks emitted by the stream using a predicate.
  • map - Maps each chunk emitted by the stream to another type using a callback.
  • reduce - Aggregates a stream to a value emitting the result when the stream closes.
  • reduce1 - Aggregates a stream to a value emitting the result when the stream closes.
  • scan - Aggregates a stream to a value emitting the intermediate result with each chunk.
  • scan1 - Aggregates a stream to a value emitting the intermediate result with each chunk.
  • some - Determines whether some chunks of the stream fulfill a given predicate.

Contributing

This project is open to feedback and contributions, please open an issue.

stream-transformers follows the Contributor Covenant Code of Conduct.

See Also

Also have a look at the following NPM Packages:

License

MIT © 2021 Konstantin Möllers, see LICENSE.

Keywords

streams

FAQs

Package last updated on 28 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts