stream-connect

WebJar for stream-connect

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

stream-connect
Последняя версия

Последняя версия

1.0.2
Дата

Дата

Тип

Тип

jar
Описание

Описание

stream-connect
WebJar for stream-connect
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/75lb/stream-connect

Скачать stream-connect

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/stream-connect/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>stream-connect</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/stream-connect/
implementation 'org.webjars.npm:stream-connect:1.0.2'
// https://jarcasting.com/artifacts/org.webjars.npm/stream-connect/
implementation ("org.webjars.npm:stream-connect:1.0.2")
'org.webjars.npm:stream-connect:jar:1.0.2'
<dependency org="org.webjars.npm" name="stream-connect" rev="1.0.2">
  <artifact name="stream-connect" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='stream-connect', version='1.0.2')
)
libraryDependencies += "org.webjars.npm" % "stream-connect" % "1.0.2"
[org.webjars.npm/stream-connect "1.0.2"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.webjars.npm : array-back jar [1.0.2,2)

Модули Проекта

Данный проект не имеет модулей.

view on npm npm module downloads Build Status Coverage Status Dependency Status js-standard-style

stream-connect

Similar to .pipe except .pipe returns the last stream in a pipeline. stream-connect returns a stream which writes to the first stream in the pipeline and reads from the last.

Synopsis

const connect = require('stream-connect')
const fs = require('fs')

const connected = connect(stream1, stream2, stream3, stream4)

// data piped into the connected stream is transparently passed through all four internal streams
// then output into process.stdout. Errors in any of the internal streams are emitted
// by the connected stream.
process.stdin
  .pipe(connected)
  .on('error', console.error)
  .pipe(process.stdout)

More detail

Consider this .pipe example.

function getExampleStream () {
 ...
 return streamOne.pipe(streamTwo)
}
const stream = getExampleStream()
stream.on('data', function (chunk) {}) // catches data from streamOne via streamTwo
stream.on('error', function (err) {}) // catches errors only from streamTwo
stream.end('test') // is written to streamTwo

If you write to the output it will be written to streamTwo, whereas you probably wanted to write to the start of the pipeline and read from the end. Fixed by stream-connect:

const connect = require('stream-connect')
function getExampleStream () {
 ...
 return connect(streamOne, streamTwo)
}
const stream = getExampleStream()
stream.on('data', function (chunk) {}) // catches data from streamOne via streamTwo
stream.on('error', function (err) {}) // catches errors from both streamOne and streamTwo
stream.end('test') // is written to streamOne

Any errors emitted in streamOne or streamTwo are propagated to the output stream.

stream-connect

Example

const connect = require('stream-connect')

connect(...streams) ⇒ Duplex

Connect streams.

Kind: Exported function

Param Type Description
...streams Duplex One or more streams to connect.

© 2015 Lloyd Brookes <75pound@gmail.com>. Documented by jsdoc-to-markdown.

Версии библиотеки

Версия
1.0.2
1.0.1