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.
- Host: GitHub
- URL: https://github.com/artdecocode/erte
- Owner: artdecocode
- License: other
- Created: 2018-05-10T18:24:36.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-29T13:01:09.000Z (over 6 years ago)
- Last Synced: 2025-01-08T06:32:26.392Z (about 1 year ago)
- Language: JavaScript
- Size: 131 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# erte
[](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
```



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

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

## Copyright
The `diff` package author: [Kevin Decker](https://github.com/kpdecker/jsdiff).
---
© Art Deco 2019
Tech Nation Visa Sucks
[Artwork by Erte][3].
[2]: https://npmjs.org/package/diff
[3]: http://www.erte.com
%-1%
