# simple-transform-stream

> Simple transform stream

Latest version **1.0.6** (published 2021-03-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install simple-transform-stream
pnpm add simple-transform-stream
yarn add simple-transform-stream
bun add simple-transform-stream
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2021-03-25 |
| First published | 2021-03-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 14.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Nicolas Walter Araya |
| Maintainers | hiuxmaycry |
| Keywords | transform, simple, json, stream |

## Links

- npm: https://www.npmjs.com/package/simple-transform-stream
- Repository: https://github.com/hiuxmaycry/transform-stream
- Homepage: https://github.com/hiuxmaycry/transform-stream#readme
- Issues: https://github.com/hiuxmaycry/transform-stream/issues
- npm.io page: https://npm.io/package/simple-transform-stream

## Dependencies (2)

- [typescript](https://npm.io/package/typescript.md) 4.2.3
- [@types/node](https://npm.io/package/@types/node.md) 14.14.35

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.6 (latest) — 2021-03-25
- 1.0.5 — 2021-03-25
- 1.0.4 — 2021-03-25
- 1.0.3 — 2021-03-22
- 1.0.2 — 2021-03-21

## README

# Simple Transform Stream

Transform a stream with messages separated with valid JSON strings into another stream with transformed JSON strings.

If you think I've missed something, be sure to open an issue or submit a pull request.

## Installation

First install the `simple-transform-stream` library:

```console
  $ npm i simple-transform-stream
```

## Usage

To get the transform stream object:

```js
const transformStream = require('transformStream');
const inputStream = createJSONStream();
/* Input have a stream of valid JSON objects
  { value: 1, type: 'begin' }\n
  { value: 2, type: 'hit' }\n
  { value: 3, type: 'hit' }\n
  { value: 4, type: 'end' }\n
  null
*/
const onMessage = async (message) => ({
  ...message,
  value: message.value * 2
});
const onFailure = (error, message) => console.error(error, message);
const transformedStream = transformStream({
  stream: inputStream,
  onMessage,
  onFailure
});
/* New transformed stream have values
  { value: 2, type: 'begin' }\n
  { value: 4, type: 'hit' }\n
  { value: 6, type: 'hit' }\n
  { value: 8, type: 'end' }\n
  null
*/
```

## License

MIT

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