cloneable-readable

WebJar for cloneable-readable

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

cloneable-readable
Last Version

Last Version

1.1.3
Release Date

Release Date

Type

Type

jar
Description

Description

cloneable-readable
WebJar for cloneable-readable
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/mcollina/cloneable-readable

Download cloneable-readable

How to add to project

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

Dependencies

compile (3)

Group / Artifact Type Version
org.webjars.npm : inherits jar [2.0.1,3)
org.webjars.npm : process-nextick-args jar [2.0.0,3)
org.webjars.npm : readable-stream jar [2.3.5,3)

Project Modules

There are no modules declared in this project.

cloneable-readable

Greenkeeper badge

Build Status

Clone a Readable stream, safely.

'use strict'

var cloneable = require('cloneable-readable')
var fs = require('fs')
var pump = require('pump')

var stream = cloneable(fs.createReadStream('./package.json'))

pump(stream.clone(), fs.createWriteStream('./out1'))

// simulate some asynchronicity
setImmediate(function () {
  pump(stream, fs.createWriteStream('./out2'))
})

cloneable-readable automatically handles objectMode: true.

This module comes out of an healthy discussion on the 'right' way to clone a Readable in https://github.com/gulpjs/vinyl/issues/85 and https://github.com/nodejs/readable-stream/issues/202. This is my take.

YOU MUST PIPE ALL CLONES TO START THE FLOW

You can also attach 'data' and 'readable' events to them.

API

cloneable(stream)

Create a Cloneable stream. A Cloneable has a clone() method to create more clones. All clones must be resumed/piped to start the flow.

cloneable.isCloneable(stream)

Check if stream needs to be wrapped in a Cloneable or not.

Acknowledgements

This project was kindly sponsored by nearForm.

License

MIT

Versions

Version
1.1.3
1.1.2