# kcl-readable-stream

> Make a KCL object work as a readable stream

Latest version **0.2.0** (published 2017-05-20) · ISC license · 0 weekly downloads

## Install

```sh
npm install kcl-readable-stream
pnpm add kcl-readable-stream
yarn add kcl-readable-stream
bun add kcl-readable-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 | 2017-05-20 |
| First published | 2016-03-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.3.2 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Dirceu Pereira Tiegs |
| Maintainers | dirceu |
| Keywords | kcl, kinesis, aws, streams |

## Links

- npm: https://www.npmjs.com/package/kcl-readable-stream
- Repository: https://github.com/dirceu/kcl-readable-stream
- Homepage: https://github.com/dirceu/kcl-readable-stream#readme
- Issues: https://github.com/dirceu/kcl-readable-stream/issues
- npm.io page: https://npm.io/package/kcl-readable-stream

## Dependencies (1)

- [aws-kcl](https://npm.io/package/aws-kcl.md) ^0.6.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2017-05-20
- 0.1.1 — 2016-03-09
- 0.1.0 — 2016-03-05

## README

# kcl-readable-stream

[![Build Status](https://travis-ci.org/dirceu/kcl-readable-stream.svg?branch=master)](https://travis-ci.org/dirceu/kcl-readable-stream)

This project convert a [KCL](https://github.com/awslabs/amazon-kinesis-client-nodejs) object into a readable stream.

There are three (optional) options that can be used in the constructor:

* `kcl.initialize`: Will be called with `data` and `callback` when the KCL subprocess is initialized. The callback function must be called.
* `kcl.shutdown`: Will be called with `data` and `callback` when the KCL subprocess is shut down because of an error or if the process is stopped. The callback function must be called.
* `kcl.streamSingleRecords`: If `true`, `data` events will be emitted with single records; otherwise, an array of records will be used. Defaults to `false`.

## Example usage

```js
// run this with something like:
// `kcl-bootstrap --java /usr/bin/java -e -p ./conf/kinesis.properties`

const kcl = require('aws-kcl');
const KclReadableStream = require('kcl-readable-stream');

const kclProcessor = new KclReadableStream({
  kcl: {
    initialize: (data, callback) => {
      console.log('Initialized!');
      callback();
    },
    shutdown: (data, callback) => {
      console.log('Shutdown!');
      callback();
    },
    streamSingleRecords: false
  }
});

// if !streamSingleRecords
kclProcessor.on('data', (records) => {
  console.log('This is an array of records: ', records);
});

// if streamSingleRecords === true
kclProcessor.on('data', (record) => {
  console.log('This is a single record: ', record);
});

// you can also .pipe()
kclProcessor.pipe(process.stdout);

kcl(kclProcessor).run();
```

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