New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

warp-pipes

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

warp-pipes

Nodejs stream utility

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-84.62%
Maintainers
1
Weekly downloads
 
Created
Source

warp-pipes [beta]

Build Status Test Coverage Maintainability Greenkeeper badge

logo

Stream util library for nodejs.

Description

Provide transformers and some utility class to extends node stream funcionality.

  • Transformers: Chunk, DropWhile, Filter, Flatten, Map, TakeWhile
  • Utility: fork, pipe, split and all transforms

Installation

yarn add warp-pipes

Quickstart

import { Chunk, Map, ReadableWrap } from 'warp-pipes';
import { WritableMock } from 'stream-mock';

const opts = { objectMode: true };

const setAdult = chunk => Object.assign({}, chunk, { adult: true });
const unsetAdult = chunk => Object.assign({}, chunk, { adult: false });

// readable is a Readable stream
const sink = ReadableWrap.wrap(readable) // create a wrap around readable
  .dropWhile(chunk => chunk.name === undefined, opts) // Drop while name is not defined
  .filter(chunk => chunk.name.startsWith('A'), opts) // Filter names starting with `A`
  .split(
    [
      {
        stream: new Map(setAdult, opts), // pipe to Map stream applying setAdult function to each chunk
        condition: chunk => chunk.age >= 18 // condition to send to setAdult mapper
      },
      {
        stream: new Map(unsetAdult, opts), // pipe to Map stream applying unsetAdult function to each chunk
        condition: chunk => chunk.age < 18 // // condition to send to unsetAdult mapper
      }
    ],
    opts
  )
  .pipe([
    // pipe each stream into another stream
    new Chunk(10, opts), // Chunk data by 10
    new Chunk(5, opts) // Chunk data by 5
  ])
  .merge() // Merge both stream in a simple one
  .pipe(new WritableMock(opts)); // Pipe resulting data in to a WritableMock

sink.on('finish', () => console.log(sink.data));

Caveheats

warp-pipes is currently on beta stage. Here are some caveheats :

  • Test coverage is not high enough for streams in buffer mode
  • API is not definitive (that's why the API doc is in WIP state)
  • No benchamarks.

Road map

  • Improve test coverage
  • Add more transformers
  • Add performance tests
  • Add docs

Contributing

Feel free to open any bug, feature, or pull request. When making a pr, just remember to cover your code with unit tests. And please follow the code style through tslint (but we can discuss about tslint rules).

Keywords

FAQs

Package last updated on 24 Aug 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc