Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More

erte

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

erte

String difference with colour for Node.js.

  • 1.1.2
  • npm
  • Socket score

Version published
Maintainers
1
Created

erte

erte

npm version

erte is an npm package to show string difference with colour.

yarn add erte

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

This function will compare the strings using diff package, and color the differences with green or red.

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)

extra

missing

same

c(s: string, t:'red'|'green'|'grey'): string

This function will color the foreground with red, green or grey colors.

/** yarn example-c */
import { c } from 'erte'

const redText = c('RED ALERT', 'red')
console.log(`.${redText}`) // eslint-disable-line
yarn example-c

c

b(s: string, t:'red'|'green'): string

This function will color the background with red or green colors.

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

const greenText = b('VEGAN', 'green')
console.log(`.${greenText}`) // eslint-disable-line
yarn example-b

b


(c) Art Deco Code 2018

Artwork by Erte.

FAQs

Package last updated on 15 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts