# separatortransform

> Stream transform that divide the input by a sperator token

Latest version **0.1.0** (published 2020-12-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install separatortransform
pnpm add separatortransform
yarn add separatortransform
bun add separatortransform
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2020-12-01 |
| First published | 2020-12-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 17.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Carlos Segura |
| Maintainers | romheat |
| Keywords | transform, stream, tokenizer, token, separator, read-by-line, line-by-line |

## Links

- npm: https://www.npmjs.com/package/separatortransform
- Repository: https://github.com/csegura/SeparatorTransform
- Homepage: https://github.com/csegura/SeparatorTransform#readme
- Issues: https://github.com/csegura/SeparatorTransform/issues
- npm.io page: https://npm.io/package/separatortransform

## 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

- 0.1.0 (latest) — 2020-12-01

## README

# SeparatorTransform

StreamTransform is a stream reader that divide the entry in delimited parts, without buffering the files into memory.

## Install

```
npm install SeparatorTransform
```

## Usage:

Synchronous processing of lines:

The mudule include two class a low level SeparatorTransform that do the work and another that simplify the use `StreamSeparator`

example Divide reader entry line by line

```js
const reader = fs.createReadStream(fileName); // reader entry
const separator = new StreamSeparator({
  separator: /\r\n/g,
  omitChars: /\r\n/g,
});

await separator.read(
  reader,
  data => {
    // do something with data
    console.log(data);
  },
  () => {
    console.log("done");
  }
);
```

## Usage:

**Class: StreamSeparator({options})**

`options` is an object with the following defaults:

```js
{
  skipEmptyLines: true,
  separator: /\r\n/g,
  omits: /\|\r\n*$/,
}
```

**read(reader, onChunk, onFinish)**

`readrer` the entry stream
`onChunk` function to process chunk of data
`onFinish` function on finish

retruns a promise fulfilled when finish

**Class: SeparatorTransform({options})**

`options` same that StreamSeparator

use as any transfrom stream

```js
const trasform = new SeparatorTransform({
  skipEmptyLines: true,
  separator: /,\r\n/g, // divide entry in lines and , separator
  omits: /\|,\r\n*$/, // remove that characters
});
input.pipe(transform).pipe(output);
```

## License:

The MIT License (MIT)

© 2020 Carlos Segura

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