# erte

> String difference with colour for Node.js and ANSI formatting. [PUBLIC]

Latest version **1.4.2** (published 2020-05-08) · AGPL-3.0 license · 0 weekly downloads

## Install

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

## 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.4.2 |
| Published | 2020-05-08 |
| First published | 2018-05-10 |
| Weekly downloads | 0 |
| License | AGPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 48 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Art Deco™ |
| Maintainers | zvr |
| Keywords | erte, art deco, artdeco, string, diff, ansi, color, colour, difference, cli |

## Links

- npm: https://www.npmjs.com/package/erte
- Homepage: https://www.artd.eco/
- Issues: https://github.com/art-deco/Issues
- npm.io page: https://npm.io/package/erte

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 1.4.2 (latest) — 2020-05-08
- 1.4.1 — 2020-05-08
- 1.3.0 — 2020-04-01
- 1.2.0 — 2019-04-29
- 1.1.7 — 2019-03-14
- 1.1.6 — 2019-01-24
- 1.1.5 — 2019-01-16
- 1.1.4 — 2018-05-26
- 1.1.3 — 2018-05-15
- 1.1.2 — 2018-05-15
- 1.1.1 — 2018-05-12
- 1.1.0 — 2018-05-12
- 1.0.0 — 2018-05-10

## README

<div align="center"><p align="center">

# erte

[![npm version](https://badge.fury.io/js/erte.svg)](https://www.npmjs.com/package/erte)
<a href="https://gitlab.com/artdeco/erte/-/commits/master">
  <img src="https://gitlab.com/artdeco/erte/badges/master/pipeline.svg" alt="Pipeline Badge">
</a>
</p></div>

`erte` Colours Strings' Foreground And Background And Shows String Difference With Color.

<table>
<thead>
<tr>
 <th>
  Free
 </th>
 <th>
  Paid
 </th>
</tr>
</thead>
<tr>
<td>

```sh
yarn add erte
npm i erte
lud erte
```
</td>
<td>

```sh
yarn add @artdeco/erte
npm i @artdeco/erte
lud @artdeco/erte
```
</td>
</tr>
</table>

<div align="center"><p align="center"><a href="#table-of-contents">
  <img alt="section break" src="https://artdeco.gitlab.io/erte/section-breaks/0.svg">
</a></p></div>

## Table Of Contents

<a href="https://www.artd.eco"><img align="right" src="https://artdeco.gitlab.io/erte/woman.jpg" width="225" alt="erte" /></a>

- [Table Of Contents](#table-of-contents)
- [API](#api)
- [`erte(source, target): string`](#ertesource-stringtarget-string-string)
- [`c(string, color, opts=): string`](#cstring-stringcolor-coloropts-options-string)
  * [`Color`](#type-color)
  * [`Options`](#type-options)
- [`b(string, color, opts=): string`](#bstring-stringcolor-coloropts-options-string)
- [Copyright & License](#copyright--license)

<div align="center"><p align="center"><a href="#table-of-contents">
  <img alt="section break" src="https://artdeco.gitlab.io/erte/section-breaks/1.svg">
</a></p></div>

## API

The package is available by importing its default and named functions:

```js
import erte, { c, b } from 'erte'
```

<div align="center"><p align="center"><a href="#table-of-contents">
  <img alt="section break" src="https://artdeco.gitlab.io/erte/section-breaks/2.svg">
</a></p></div>

## <code><ins>erte</ins>(</code><sub><br/>&nbsp;&nbsp;`source: string,`<br/>&nbsp;&nbsp;`target: string,`<br/></sub><code>): <i>string</i></code>
Compares the strings using the [`diff`](https://www.npmjs.com/package/diff) package,
and outputs a coloured version where strings don't match with green or red differences.
Returns a string which uses shell-codes to highlight differences.

 - <kbd><strong>source*</strong></kbd> <em>`string`</em>: The string to compare.
 - <kbd><strong>target*</strong></kbd> <em>`string`</em>: The string to comparison against.

```js
import erte from 'erte'

const s = 'test this string'
const e = 'test this string with extra data'
const m = 'test this'

const green = erte(s, e)
console.log(green)

const red = erte(s, m)
console.log(red)

const grey = erte(s, s)
console.log(grey)
```
```
test this string with extra data
test this string
test this string
```

![extra](https://artdeco.gitlab.io/erte/extra.png)

![missing](https://artdeco.gitlab.io/erte/missing.png)

![same](https://artdeco.gitlab.io/erte/same.png)

<div align="center"><p align="center"><a href="#table-of-contents">
  <img alt="section break" src="https://artdeco.gitlab.io/erte/section-breaks/3.svg">
</a></p></div>

## <code><ins>c</ins>(</code><sub><br/>&nbsp;&nbsp;`string: string,`<br/>&nbsp;&nbsp;`color: Color,`<br/>&nbsp;&nbsp;`opts=: !Options,`<br/></sub><code>): <i>string</i></code>
Colors the foreground using an ANSI sequence.

 - <kbd><strong>string*</strong></kbd> <em>`string`</em>: The string to color.
 - <kbd><strong>color*</strong></kbd> <em><code><a href="#type-color" title="The color to apply.">Color</a></code></em>: The color to use.
 - <kbd>opts</kbd> <em><code><a href="#type-options" title="Additional options. Only available in the paid version.">!Options</a></code></em> (optional): Additional options. Only available in the paid version.

Any text in strings can be coloured using the `c` and `b` methods. They accept a colour, and additional ANSI transformations.

<code>('black' \| 'red' \| 'green' \| 'yellow' \| 'blue' \| 'magenta' \| 'cyan' \| 'white' \| 'grey')</code> __<a name="type-color">`Color`</a>__: The color to apply.

__<a name="type-options">`Options`</a>__: Additional options. Only available in the paid version.

|   Name    |       Type       |                       Description                        |
| --------- | ---------------- | -------------------------------------------------------- |
| bold      | <em>boolean</em> | The **bold** ANSI.                                       |
| underline | <em>boolean</em> | The ͟u͟n͟d͟e͟r͟l͟i͟n͟e͟ ANSI.                            |
| reverse   | <em>boolean</em> | The `reverse` ANSI (inverses background and foreground). |
| conceal   | <em>boolean</em> | The `conceal` ANSI (doesn't show symbols).               |

```js
import { c } from 'erte'

const redText = c('RED ALERT', 'red', {
  underline: true,
  bold: true,
  conceal: true,
  reverse: true,
})
console.log(redText)
```

![c](https://artdeco.gitlab.io/erte/c.png)

<div align="center"><p align="center"><a href="#table-of-contents">
  <img alt="section break" src="https://artdeco.gitlab.io/erte/section-breaks/4.svg">
</a></p></div>

## <code><ins>b</ins>(</code><sub><br/>&nbsp;&nbsp;`string: string,`<br/>&nbsp;&nbsp;`color: Color,`<br/>&nbsp;&nbsp;`opts=: !Options,`<br/></sub><code>): <i>string</i></code>
Colors the background with specified ANSI color.

 - <kbd><strong>string*</strong></kbd> <em>`string`</em>: The string to color backgroud of.
 - <kbd><strong>color*</strong></kbd> <em><code><a href="#type-color" title="The color to apply.">Color</a></code></em>: The color to use.
 - <kbd>opts</kbd> <em><code><a href="#type-options" title="Additional options. Only available in the paid version.">!Options</a></code></em> (optional): Additional options. Only available in the paid version.

```js
import { b } from 'erte'

const greenText = b('VEGAN', 'green')
console.log(greenText)
```

![b](https://artdeco.gitlab.io/erte/b.png)

<div align="center"><p align="center"><a href="#table-of-contents">
  <img alt="section break" src="https://artdeco.gitlab.io/erte/section-breaks/5.svg">
</a></p></div>

## Copyright & License

The `diff` package is released under [BSD License](COPYING) by [Kevin Decker](https://github.com/kpdecker/jsdiff). [Artwork by Erte][3].

GNU Affero General Public License v3.0

<table>
  <tr>
    <th>
      <a href="https://www.artd.eco">
        <img width="100" src="https://gitlab.com/uploads/-/system/group/avatar/7454762/artdeco.png"
          alt="Art Deco">
      </a>
    </th>
    <th>© <a href="https://www.artd.eco">Art Deco™</a>   2020</th>
    <th>
      <a href="LICENSE"><img src="https://artdeco.gitlab.io/assets/licenses/agpl-3.0.svg" alt="AGPL-3.0"></a>
    </th>
  </tr>
</table>

[2]: https://www.npmjs.com/package/diff
[3]: http://www.erte.com

<div align="center"><p align="center"><a href="#table-of-contents">
  <img alt="section break" src="https://artdeco.gitlab.io/erte/section-breaks/-1.svg">
</a></p></div>

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