# regex-pipe

> A transformation piping tool based on regex

Latest version **0.0.1** (published 2017-07-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install regex-pipe
pnpm add regex-pipe
yarn add regex-pipe
bun add regex-pipe
```

## 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.0.1 |
| Published | 2017-07-02 |
| First published | 2017-07-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Guilherme Reginaldo Ruella |
| Maintainers | potentii |
| Keywords | pipe, regex, transformation, parse, replace |

## Links

- npm: https://www.npmjs.com/package/regex-pipe
- Repository: https://github.com/Potentii/regex-pipe
- Homepage: https://github.com/Potentii/regex-pipe#readme
- Issues: https://github.com/Potentii/regex-pipe/issues
- npm.io page: https://npm.io/package/regex-pipe

## Dependencies (2)

- [split](https://npm.io/package/split.md) 1.0.0
- [isstream](https://npm.io/package/isstream.md) 0.1.2

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2017-07-02

## README

# regex-pipe

[![NPM Version][npm-image]][npm-url]

A transformation piping tool based on regex.

<br><br>

## Table of contents

-   [Installation](#installation)
-   [Examples](#examples)
 -   [Parsing](#parsing)
 -   [Replacing](#replacing)
-   [Feedback](#feedback)
-   [License](#license)

<br><br>

## Installation

This module is available on [npm][npm-url]:
```bash
$ npm install regex-pipe
```

## Examples

### Parsing

The following example will show how to transform the content of a file to another.

```javascript
const Pipe = require('regex-pipe');

const regex = /(blue|red|yellow)/;
const transformation = matches => 'I have a ' + matches[1] + ' house\n';

new Pipe('./in.txt', './out.txt')
   .parse(regex, transformation, { delimiter: Pipe.DELIMITERS.LINE_BY_LINE })
   .then(() => {
      // Now the out.txt file contains the output...
   })
   .catch(err => {
      // An error happened...
   });
```

Considering the `in.txt` content as:

```text
They have a blue house
They have a red house
They have a yellow house
```

After the execution, the `out.txt` content will be:

```text
I have a blue house
I have a red house
I have a yellow house
```

In other words, the `Pipe.parse` will replace every chunk of data with the return of the `transformation` function

<br><br>

### Replacing

The following example will show how to replace the content of a file to another.

```javascript
const Pipe = require('regex-pipe');

const regex = /blue/;
const replacement = 'red';

new Pipe('./in.txt', './out.txt')
   .replace(regex, replacement, { delimiter: Pipe.DELIMITERS.LINE_BY_LINE })
   .then(() => {
      // Now the out.txt file contains the output...
   })
   .catch(err => {
      // An error happened...
   });
```

Considering the `in.txt` content as:

```text
They have a blue house
```

After the execution, the `out.txt` content will be:

```text
They have a red house
```

This is much like to what the `String.replace` does

<br><br>

## Feedback

If you want a feature to be added or give some other feedback, feel free to open an [issue](https://github.com/Potentii/regex-pipe/issues).

<br><br>

## License
[MIT](LICENSE.txt)

[npm-image]: https://img.shields.io/npm/v/regex-pipe.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/regex-pipe

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