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

streaming

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

streaming

Transforms and other streaming helpers

  • 0.3.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
432
decreased by-4.64%
Maintainers
1
Weekly downloads
 
Created
Source

streaming

A few stream helpers, abiding by the new-style Node.js stream standards ("Streams2").

npm install streaming

streaming.Glob

new Glob(pattern, options) inherits stream.Readable

  • _readableState.objectMode: true

streaming.json.Stringifier

new Stringifier(replacer, space) inherits streaming.Splitter

  • objectMode: false
    • _writableState.objectMode: false
    • _readableState.objectMode: true

streaming.json.Parser

new Parser() inherits streaming.Splitter

  • objectMode: true

streaming.Line

new Line() inherits stream.Transform

  • _writableState.objectMode: false
  • _readableState.objectMode: true

streaming.Mapper

new Mapper(fn) inherits stream.Transform

  • _writableState.objectMode: true
  • _readableState.objectMode: true

streaming.Queue

new Queue(concurrency, worker) inherits streaming.Mapper

  • _writableState.objectMode: true
  • _readableState.objectMode: true

Example:

var streaming = require('streaming');

var lazy_worker = function(task, callback) {
  setTimeout(function() {
    var json = JSON.stringify(task);
    callback(null, json.length + ' after 1s\n');
  }, 1000);
};

process.stdin
.pipe(new streaming.Line())
.pipe(new streaming.Mapper(JSON.parse))
.pipe(new streaming.Queue(5, lazy_worker))
.pipe(process.stdout);

streaming.Splitter

Very similar to streaming.Line, but more configurable.

new Splitter(split, opts) inherits stream.Transform

streaming.Timeout

new Timeout(seconds, opts) inherits stream.Transform

stream.Transform(opts) results:

opts. decodeStringsopts. objectMode_writableState. decodeStrings_writableState. objectMode_readableState. objectMode
truetruetruetruetrue
falsetruefalsetruetrue
undefinedtruetruetruetrue
truefalsetruefalsefalse
falsefalsefalsefalsefalse
undefinedfalsetruefalsefalse
trueundefinedtruefalsefalse
falseundefinedfalsefalsefalse
undefinedundefinedtruefalsefalse

License

Copyright © 2013 Christopher Brown. MIT Licensed.

Keywords

FAQs

Package last updated on 19 Aug 2013

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