Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

collect-transform-stream

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

collect-transform-stream

create a transform stream that runs a function over all collected elements

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

collect-transform-stream

create a transform stream that runs a function over all collected elements

Sometimes you end up in a situation where you have a stream pipeline like

pump(source, transform, destination)

but you have another transform function that needs to process all elements in the stream before passing them on, e.g. filtering duplicates from an unordered stream:

pump(source, collectAndFilter, transform, destination)

collect-transform-stream is a tiny module that provides this.

Usage

var uniq = require('uniq')
var from = require('from2')
var collect = require('concat-stream')
var collectTransform = require('collect-transform-stream')

var source = from.obj(new Array(500).fill(0).map(function () {
  return Math.floor(Math.random() * 10)
}))

var dedupe = collectTransform(function (nums) {
  return uniq(nums)
})

var dest = collect({encoding:'object'}, console.log)

source.pipe(dedupe).pipe(dest)

outputs

0
1
2
3
4
5
6
7
8
9

API

var collect = require('collect-transform-stream')

collect(fn[, cb])

Create a Transform stream that runs the function fn on all incoming objects at once, then pipes elements individually onward to the next stream in the pipeline.

Use return result to use synchronously; call cb(err, result) to use asynchronously.

Install

With npm installed, run

$ npm install collect-transform-stream

License

ISC

FAQs

Package last updated on 24 Mar 2017

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