JSPM

streaming-format

2.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 49
  • Score
    100M100P100Q62412F
  • License MIT

Simple streaming formatter

Package Exports

  • streaming-format

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (streaming-format) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

streaming-format

Simple streaming formatter

npm install streaming-format

build status

Usage

Assuming you have a stream that contains handlebars format values like

... BIG DATA ...
{{hello}} world
... MORE BIG DATA ...

And you want to replace {{hello}} with a another value without reading the entire stream into memory use this module

var format = require('streaming-format')

bigData
  .pipe(format(function(name) {
    return name.toUpperCase()
  }))
  .pipe(process.stdout)

Which will produce

... BIG DATA ...
HELLO world
... MORE BIG DATA ...

API

var stream = format([opts], replacer) where opts can contain

{
  start: '{{', // set the format start string
  end: '}}'    // set the format end string
}

Command line tool

There is also a command line tool available

npm install -g streaming-format
echo 'hello {{hello}}' | format --hello world # prints hello world

License

MIT