An open API service indexing awesome lists of open source software.

https://github.com/artdecocode/erte

String difference with colour for Node.js.
https://github.com/artdecocode/erte

Last synced: about 2 months ago
JSON representation

String difference with colour for Node.js.

Awesome Lists containing this project

README

          

erte

# erte

[![npm version](https://badge.fury.io/js/depack.svg)](https://npmjs.org/package/depack)

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

```sh
yarn add -E erte
```

## Table Of Contents

- [Table Of Contents](#table-of-contents)
- [API](#api)
* [`_erte.Color`](#type-_ertecolor)
- [`erte(source: string, target: string): string`](#ertesource-stringtarget-string-string)
- [`c(string: string, color: Color): string`](#cstring-stringcolor-color-string)
- [`b(string: string, color: Color): string`](#bstring-stringcolor-color-string)
- [Copyright](#copyright)

## API

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

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

`('black'|'red'|'green'|'yellow'|'blue'|'magenta'|'cyan'|'white'|'grey')` __`_erte.Color`__: The color to apply.

## `erte(`
  `source: string,`
  `target: string,`
`): string`

Compares the strings using the [`diff`][2] package, and colors the differences with green or red.

```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](doc/extra.png)

![missing](doc/missing.png)

![same](doc/same.png)

## `c(`
  `string: string,`
  `color: Color,`
`): string`

Colors the foreground using an ANSI sequence.

```js
/** yarn example-c */
import { c } from '..'

const redText = c('RED ALERT', 'red')
console.log(redText)
```

![c](doc/c.png)

## `b(`
  `string: string,`
  `color: Color,`
`): string`

Colors the background with specified ANSI color.

```js
/** yarn example-b */
import { b } from 'erte'

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

![b](doc/b.png)

## Copyright

The `diff` package author: [Kevin Decker](https://github.com/kpdecker/jsdiff).

---




Art Deco


© Art Deco 2019


Tech Nation Visa


Tech Nation Visa Sucks

[Artwork by Erte][3].

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

%-1%