# split-stream

> stream of split strings

Latest version **0.2.0** (published 2013-03-17) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

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

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2013-03-17 |
| First published | 2013-02-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | sasa+1 |
| Maintainers | sasaplus1 |

## Links

- npm: https://www.npmjs.com/package/split-stream
- Repository: https://github.com/sasaplus1/split-stream
- npm.io page: https://npm.io/package/split-stream

## Recent versions

- 0.2.0 (latest) — 2013-03-17
- 0.1.2 — 2013-02-26
- 0.1.1 — 2013-02-21
- 0.1.0 — 2013-02-18

## README

# split-stream  [![Build Status](https://travis-ci.org/sasaplus1/split-stream.png)](https://travis-ci.org/sasaplus1/split-stream)

stream of split strings

## Installation

```sh
$ npm install split-stream
```

## Usage

```js
var fs = require('fs'),
    splitStream = require('split-stream'),
    ss = splitStream.create();

fs.createReadStream('./file').pipe(ss).pipe(process.stdout);
```

### stream2

```js
var fs = require('fs'),
    splitStream = require('split-stream').SplitStream2,
    ss = splitStream.create();

ss.on('readable', function() {
  var buf;

  while ((buf = ss.read(1)) !== null) {
    console.log(buf);
  }
});
ss.on('end', function() {
  console.log('end');
});

fs.createReadStream('./index.js').pipe(ss);
```

### old-style stream

```js
var fs = require('fs'),
    splitStream = require('split-stream').SplitStream1,
    ss = splitStream.create({
      splitStr: '\t'
    });

ss.setEncoding('utf8');

ss.on('data', function(data) {
  console.log(data);
});
ss.on('end', function() {
  ss.destory();
});
ss.on('close', function() {
  console.log('close');
});

fs.createReadStream('./file').pipe(ss);
```

## Class

### SplitStream

class of SplitStream1 or SplitStream2.

```js
var splitStream = require('split-stream');

// true if over version 0.9.
(splitStream === splitStream.SplitStream2);

// true if over version 0.8.
(splitStream === splitStream.SplitStream2);
```

### SplitStream2

inherited stream2 class.

## Function (SplitStream2)

### create(options)

* `` object - options object

* `return` SplitStream2 - SplitStream2

throw TypeError if options.splitStr is not string or regexp types.

objectMode and decodeStrings are always true.

#### options

* `splitStr` string or regexp - split string

default value is `/\r?\n/`.

* `encoding` string - encoding

default value is `utf8`. this value is argument of string_decoder.

### SplitStream1

inherited old-style stream class.

## Function (SplitStream1)

### create(options)

* `options` object - option object

* `return` SplitStream1 - SplitStream1

throw TypeError if options.splitStr is not string or regexp types.

#### options

* `splitStr` string or regexp - split string

default value is `/\r?\n/`.

## Events (SplitStream1)

### close

called destroy().

### data

* `data` string - split string

until buffer is empty.

### drain

when buffer is empty.

### end

call after end() and when buffer is empty.

### error

* `error` Error - error object

call twice destory() or call write() after end().

## Test

```sh
$ npm install
$ npm test
```

## License

The MIT License. Please see LICENSE file.

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