slice-stream

WebJar for slice-stream

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

slice-stream
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

slice-stream
WebJar for slice-stream
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/EvanOxfeld/slice-stream

Download slice-stream

How to add to project

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

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : readable-stream jar [1.0.31,1.1)

Project Modules

There are no modules declared in this project.

slice-stream Build Status

Pipe data through a stream until some fixed length is reached, then callback.

Installation

$ npm install slice-stream

Quick Example

End stream once a fixed length has been reached

var SliceStream = require('../');
var streamBuffers = require("stream-buffers");

var ss = new SliceStream({ length: 5}, function (buf, sliceEnd, extra) {
  if (!sliceEnd) {
    return this.push(buf);
  }
  this.push(buf);
  return this.push(null); //signal end of data
});

var sourceStream = new streamBuffers.ReadableStreamBuffer();
sourceStream.put("Hello World");
var writableStream = new streamBuffers.WritableStreamBuffer();

sourceStream
  .pipe(ss)
  .pipe(writableStream)
  .once('close', function () {
    var str = writableStream.getContentsAsString('utf8');
    console.log('First 5 bytes piped:', "'" + str + "'");
    sourceStream.destroy();
  });

//Output
//Piped data before pattern occurs: 'Hello'

License

MIT

Versions

Version
1.0.0