# streamface

> command-line wrapper for stream-based tools

Latest version **0.0.3** (published 2019-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install streamface
pnpm add streamface
yarn add streamface
bun add streamface
```

## 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.0.3 |
| Published | 2019-11-07 |
| First published | 2019-08-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mac Heller-Ogden |
| Maintainers | machellerogden |

## Links

- npm: https://www.npmjs.com/package/streamface
- Repository: https://github.com/machellerogden/streamface
- Issues: https://github.com/machellerogden/streamface/issues
- npm.io page: https://npm.io/package/streamface

## Dependencies (1)

- [clipboardy](https://npm.io/package/clipboardy.md) ^2.1.0

## Recent versions

- 0.0.3 (latest) — 2019-11-07
- 0.0.2 — 2019-11-06
- 0.0.1 — 2019-08-15
- 0.0.0 — 2019-08-09

## README

# streamface

> The pattern was wet.
  Shared among several packages.
  The pattern is dry.

Streamface is a simple command-line wrapper for stream-based tools. I wrote it because I found myself repeating a certain patterns in several packges I was working on.

## Install

```
npm i streamface
```

## Usage

In order to use streamface, you first need to implement two functions within your project:

### `readAll`

A function which takes a string, an Array or a ReadableStream and returns a promise.

### `readToStream`

A function which takes a string, an Array or a ReadableStream and returns a ReadableStream.

Once you've implemented these functions, you can then invoke the `streamface.wrap` method inside your entry point script. Be sure to pass the `module` object so that streamface can detect the runtime context properly.

```
streamface.wrap({ readAll, readToStream, module });
```

### Example Implementation

Here's an example of an implementation which simply passes input through, unchanged. You don't have to write it this way, but this should serve as an example or as a starting point if you don't know where to begin.

```
#!/usr/bin/env node
'use strict';

const streamface = require('.');
const streamify = require('async-stream-generator');

async function* toAsync(statements) {
    for await (const statement of statements) yield statement;
}

function read(data = '') {
    return data[Symbol.asyncIterator]
        ? data
        : Array.isArray(data)
            ? data.values()
            : [ data ].values();
}

function readToStream(data = '', opts) {
    return streamify(toAsync(read(data)));
}

async function readAll(data = '', opts) {
    const results = [];
    for await (const result of read(data, opts)) results.push(result);
    return results;
}

streamface.wrap({ readAll, readToStream, module });
```

# License

MIT

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