# node-stream-tag

> A tagged template literal for streams.

Latest version **1.1.2** (published 2022-10-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-stream-tag
pnpm add node-stream-tag
yarn add node-stream-tag
bun add node-stream-tag
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; no esm support; large bundle.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2022-10-31 |
| First published | 2022-01-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 84.1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | John Wright |
| Maintainers | johngeorgewright |

## Links

- npm: https://www.npmjs.com/package/node-stream-tag
- Repository: https://github.com/johngeorgewright/node-stream-tag
- Homepage: https://github.com/johngeorgewright/node-stream-tag#readme
- Issues: https://github.com/johngeorgewright/node-stream-tag/issues
- npm.io page: https://npm.io/package/node-stream-tag

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) 2.4.1

## Recent versions

- 1.1.2 (latest) — 2022-10-31
- 1.1.1 — 2022-04-22
- 1.1.0 — 2022-01-03
- 1.0.0 — 2022-01-03

## README

# node-stream-tag

Template tag for streaming content. Template parts must be "stringable" or a promise of something "stringable". The strings will be pushed on to the stream as soon as they are available.

## Example

```typescript
import { Server } from 'http'
import { Readable } from 'stream'
import { setTimeout } from 'timers/promises'
import stream from 'node-stream-tag'

const server = new Server((_, res) => {
  const secs = 2
  stream`<!DOCTYPE html>
<html>
  <head>
    <title>Streaming tagged templates</title>
</head>
<body>
  <p>
    I will now wait for ${secs} secs then say hello... ${setTimeout(
    secs * 1_000,
    '<b>Hello</b>'
  )}
  </p>
</body>
</html>`.pipe(res)
}).listen(3_000, () => console.info('server listening on', server.address()))
```

The above example will immediately push a string on to the response, and then will wait for 2secs before finishing.

**When using promises, you must ensure they handle errors correctly, otherwise your stream may break.**

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