# slice-stream

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

Latest version **1.0.0** (published 2014-09-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install slice-stream
pnpm add slice-stream
yarn add slice-stream
bun add slice-stream
```

## 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.0.0 |
| Published | 2014-09-09 |
| First published | 2013-03-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Evan Oxfeld |
| Maintainers | evanoxfeld |
| Keywords | slice, fixed, length, stream, split |

## Links

- npm: https://www.npmjs.com/package/slice-stream
- Repository: https://github.com/EvanOxfeld/slice-stream
- Issues: https://github.com/EvanOxfeld/slice-stream/issues
- npm.io page: https://npm.io/package/slice-stream

## Dependencies (1)

- [readable-stream](https://npm.io/package/readable-stream.md) ~1.0.31

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2014-09-09
- 0.0.0 — 2013-03-15

## README

slice-stream [![Build Status](https://travis-ci.org/EvanOxfeld/slice-stream.png)](https://travis-ci.org/EvanOxfeld/slice-stream)
============

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

## Installation

```bash
$ npm install slice-stream
```

## Quick Example

### End stream once a fixed length has been reached

```javascript
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

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