# format-stream

> a simple formatter, stream style.

Latest version **0.2.0** (published 2013-09-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install format-stream
pnpm add format-stream
yarn add format-stream
bun add format-stream
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2013-09-08 |
| First published | 2013-09-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Andrew Winterman |
| Maintainers | andrewwinterman |
| Keywords | format, template, simple, stream |

## Links

- npm: https://www.npmjs.com/package/format-stream
- Repository: https://github.com/AWinterman/format-stream
- Issues: https://github.com/AWinterman/format-stream/issues
- npm.io page: https://npm.io/package/format-stream

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2013-09-08
- 0.1.0 — 2013-09-02

## README

# Format-Stream #

A streaming simple formatter. 

## API ##

```javascript
var format = new Format(token, stream)
```

`format` is a transform stream that checks if each chunk of data matches the
token. If it does not, then the chunk is passed through. Otherwise, `format`
emits data from the second argument, `stream` until it is consumed.

## Example ##
Suppose you have a file called `base-template.html`:
```html 
<html>
    <head>
        <title>"Your app!"</title>
    </head>
    <body>
        {{welcome}}
    </body>
</html>
```

And one called `welcome-template.html`.
```
<p>"Hey you party people!"</p>
```

In index.js you write:
```javascript
var Sentinal = require('sentinal-stream')
  , Format = require('format-stream')
  , token = '{{welcome}}'

var inside_stream = fs.createReadStream('welcome-template.html')
  , outside_stream = fs.createReadStream('base-template.html')

// Make sure any instance of {{welcome}} is emitted in its
// own data event
var tokenizer = new Sentinal(new Buffer(token)) 
  , format = new Format(token, inside_stream)

outside_stream
    .pipe(tokenizer)
    .pipe(format)
    .pipe(process.stdout)
```

Then `node index.js` will print:

```
<html>
    <head>
        <title>"Your app!"</title>
    </head>
    <body>
        <p>"Hey you party people!"</p>
    </body>
</html>
```

---
_Source: https://npm.io/package/format-stream · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
