# tap-reader

> A smol, streaming TAP parser.

Latest version **0.2.1** (published 2024-07-29) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install tap-reader
pnpm add tap-reader
yarn add tap-reader
bun add tap-reader
```

Provides the command `tap-reader`.

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2024-07-29 |
| First published | 2023-10-13 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 143 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | tbeseda |
| Maintainers | tbeseda |
| Keywords | tap, parser, testing, tape |

## Links

- npm: https://www.npmjs.com/package/tap-reader
- Repository: https://github.com/tbeseda/tap-reader
- Homepage: https://github.com/tbeseda/tap-reader#readme
- Issues: https://github.com/tbeseda/tap-reader/issues
- npm.io page: https://npm.io/package/tap-reader

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.2.1 (latest) — 2024-07-29
- 0.0.1-1 (next) — 2023-10-13
- 0.2.0 — 2024-07-29
- 0.1.0 — 2023-10-26
- 0.0.10 — 2023-10-26
- 0.0.9 — 2023-10-18
- 0.0.8 — 2023-10-16
- 0.0.7 — 2023-10-15
- 0.0.6 — 2023-10-15
- 0.0.5 — 2023-10-14
- 0.0.4 — 2023-10-14
- 0.0.3 — 2023-10-14
- 0.0.2 — 2023-10-14
- 0.0.1 — 2023-10-13
- 0.0.1-0 — 2023-10-13

## README

<h1 align="center"><code>tap-reader</code> 📜</h1>

<p align="center">
  A smol, streaming <a href="https://testanything.org/">TAP</a> parser. Works well with <a href="https://www.npmjs.com/package/tape/"><code>tape</code></a>.<br>
  <a href="https://www.npmjs.com/package/tap-reader"><strong><code>tap-reader</code> on npmjs.org »</strong></a><br>
  Documentation soon...
</p>

Sample reporter that leverages `tap-reader`:

```js
#!/usr/bin/env node
import { stdin } from 'node:process';
import TapReader from 'tap-reader'

const write = console.log
const reader = TapReader({ input: stdin });

reader.on('version', ({ version }) => {
  write('VERSION', version);
});

reader.on('pass', ({ id, desc, skip, todo }) => {
  write('PASS', id, desc, todo ? 'TODO' : skip ? 'SKIP' : '');
});

reader.on('fail', ({ id, desc, skip, todo, diag }) => {
  write('FAIL', id, desc, todo ? 'TODO' : skip ? 'SKIP' : '');
  
  for (const key in diag)
    write(`  ${key}: ${diag[key]}`);
});

reader.on('plan', ({ plan, comment, todo }) => {
  write(`plan: ${plan[0]} → ${plan[1]} ${comment || ''} ${todo ? 'TODO' :''}`);
})

reader.on('comment', ({ comment, todo, skip }) => {
  write('COMMENT', comment, todo ? 'TODO' : skip ? 'SKIP' : '');
})

reader.on('other', ({ line }) => {
  if (line.trim().length > 0) write('OTHER', line);
})

reader.on('done', ({ summary, ok }) => {
  const { total, pass, fail, skip, todo } = summary;

  write('DONE')
  write(`total: ${total}`)
  write(`pass: ${pass}`)
  write(`fail: ${fail}`)
  write(`skip: ${skip}`)
  write(`todo: ${todo}`)
  write(`OK ${ok}`)
})

reader.on('end', ({ ok }) => {
  process.exit(ok ? 0 : 1);
})
```

Also see `examples/table-reporter.js` for another example.

## Coming next:

- [ ] More TAP features like subtests, +pragmas, etc.
- [ ] Documentation for config and events
- [ ] Intellisense via `.d.ts`

## FAQ:

**Why is `yaml` vendored?**  
Because the published module is large. `tap-reader` should install and run as quickly as possible in a CI environment.  
I'm not stoked on it so this may change in the future.

**Why not use `tap-parser`?**  
`tap-parser` is great but... see above.

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