any-stream

Make any function that takes string input streamable.

Usage no npm install needed!

<script type="module">
  import anyStream from 'https://cdn.skypack.dev/any-stream';
</script>

README

any-stream

NPM version License Build status

Make any function that takes string input (as the first argument) streamable.

Installation

npm install any-stream

Usage

API

anyStream(fn, [...args])

Make fn streamable by leveraging through2 to pass the contents of a stream first and then any consecutive arguments to it.

Example

var fs           = require('fs')
var anyStream    = require('any-stream')
var htmlMinifier = require('html-minifier').minify

var input  = fs.createReadStream('src/index.html')
var output = fs.createWriteStream('dist/index.html')

input
  .pipe(anyStream(htmlMinifier, {
    collapseWhitespace: true,
    removeComments: true
  }))
  .pipe(output)