# stream-from-to

> Utility for piping to/from a stream from a variety of sources to a variety of destinations

Latest version **1.4.3** (published 2016-04-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install stream-from-to
pnpm add stream-from-to
yarn add stream-from-to
bun add stream-from-to
```

## 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.4.3 |
| Published | 2016-04-20 |
| First published | 2013-12-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Alan Shaw |
| Maintainers | alanshaw |

## Links

- npm: https://www.npmjs.com/package/stream-from-to
- Repository: https://github.com/alanshaw/stream-from-to
- Issues: https://github.com/alanshaw/stream-from-to/issues
- npm.io page: https://npm.io/package/stream-from-to

## Dependencies (4)

- [async](https://npm.io/package/async.md) ^1.5.2
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.0
- [concat-stream](https://npm.io/package/concat-stream.md) ^1.4.7
- [series-stream](https://npm.io/package/series-stream.md) ^1.0.1

## Recent versions

- 1.4.3 (latest) — 2016-04-20
- 1.4.2 — 2015-03-16
- 1.4.1 — 2015-01-25
- 1.4.0 — 2014-01-30
- 1.3.0 — 2013-12-29
- 1.2.0 — 2013-12-27
- 1.1.0 — 2013-12-15
- 1.0.0 — 2013-12-15
- 0.0.1 — 2013-12-15
- 0.0.0 — 2013-12-14

## README

stream-from-to [![Build Status](https://travis-ci.org/alanshaw/stream-from-to.svg)](https://travis-ci.org/alanshaw/stream-from-to) [![Dependency Status](https://david-dm.org/alanshaw/stream-from-to.svg)](https://david-dm.org/alanshaw/stream-from-to)
===
Utility for piping to/from a stream from a variety of sources to a variety of destinations.

Pass stream-from-to a function that creates a [through](https://npmjs.org/package/through) stream and it'll give you back an object that simplifies the constructon of source and destination streams for piping to/from the through stream.

Usage examples
---

```javascript
var streamft = require("stream-from-to")
  , through = require("through")

var mdToHtml = function (filePath) {
  // Through stream that converts markdown to HTML
  return through()
}

streamft(mdToHtml).from.path("/path/to/doc.md").to.path("/path/to/doc.html", function (er) {
    if (er) return console.error(er)
    // Done!
})
```

With [brfs](https://github.com/substack/brfs):

```javascript
var streamft = require("stream-from-to")
  , brfs = require("brfs")

streamft(brfs).from("src/index.js").to("dist/index.js")
```

API
---

### from.path(path, opts)

Create a readable stream from `path` and pipe to the through stream. `path` can be a single path or array of paths.

### from.string(string)

Create a readable stream from `string` and pipe to the through stream. `string` can be a single string or array of strings.

### concat.from.paths(paths, opts)

Create and concatinate readable streams from `paths` and pipe to the through stream.

### concat.from.strings(strings, opts)

Create and concatinate readable streams from `strings` and pipe to the through stream.

### to.path(path, cb)

Create a writeable stream to `path` and pipe output from the through stream to it. `path` can be a single path, or array of output paths if you specified an array of inputs. The callback function `cb` will be invoked when data has finished being written.

### to.buffer(opts, cb)

Create a [concat-stream](https://npmjs.org/package/concat-stream) and pipe output from the through stream to it. The callback function `cb` will be invoked when the buffer has been created.

### to.string(opts, cb)

Create a [concat-stream](https://npmjs.org/package/concat-stream) and pipe output from the through stream to it. The callback function `cb` will be invoked when the string has been created.

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