# @njakob/rainbow

> String styling helpers inspired by Chalk

Latest version **1.3.2** (published 2017-06-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install @njakob/rainbow
pnpm add @njakob/rainbow
yarn add @njakob/rainbow
bun add @njakob/rainbow
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.2 |
| Published | 2017-06-04 |
| First published | 2017-04-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Nicolas Jakob |
| Maintainers | njakob |
| Keywords | style, styles, color, colors, colour, terminal, console, cli, string, str, text, ansi, tty, formatter, formatting, rgb, log, logger, logging, command-line |

## Links

- npm: https://www.npmjs.com/package/@njakob/rainbow
- Repository: https://github.com/njakob/rainbow
- Issues: https://github.com/njakob/rainbow/issues
- npm.io page: https://npm.io/package/@njakob/rainbow

## Dependencies (1)

- [ansi-styles](https://npm.io/package/ansi-styles.md) ^3.0.0

## 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.3.2 (latest) — 2017-06-04
- 1.3.1 — 2017-05-21
- 1.3.0 — 2017-04-22
- 1.2.1 — 2017-04-15
- 1.2.0 — 2017-04-15
- 1.1.0 — 2017-04-14
- 1.0.3 — 2017-04-10
- 1.0.2 — 2017-04-10
- 1.0.1 — 2017-04-10
- 1.0.0 — 2017-04-09

## README

# rainbow [![NPM version][npm-status-image]][npm] [![Build Status][build-status-image]][travis] [![ESLint Config][eslint-config-image]][github:eslint-config] [![Conventional Commits][badge:conventional-commits]][conventional-commits]

> String styling helpers inspired by [Chalk][github:chalk].

## Installation

With NPM:

```
$ npm install @njakob/rainbow
```

With Yarn:

```
$ yarn add @njakob/rainbow
```

## Usage

Rainbow relies on tagged template literals in order to generate _style nodes_. Theses nodes can then be formatted through a specific function and generate a _styled string_.

```js
import { Rainbow, ansiStyleFormatter } from '@njakob/Rainbow';

const styles = new Rainbow(ansiStyleFormatter);

const styleNode = styles.parse`Stuff to ${styles.red`log`} with some ${styles.bold.blue`colors`}`;
const styledString = styles.format(styleNode);

console.log(styledString.value);
process.stdout.write(`${styledString.value}\n`);
```

#### Colors

* `` styles.parse`${styles.black`black`}` ``
* `` styles.parse`${styles.red`red`}` ``
* `` styles.parse`${styles.green`green`}` ``
* `` styles.parse`${styles.yellow`yellow`}` ``
* `` styles.parse`${styles.blue`blue`}` ``
* `` styles.parse`${styles.cyan`cyan`}` ``
* `` styles.parse`${styles.magenta`magenta`}` ``
* `` styles.parse`${styles.white`white`}` ``
* `` styles.parse`${styles.gray`gray`}` ``

#### Backgrounds

* `` styles.parse`${styles.bgBlack`black`}` ``
* `` styles.parse`${styles.bgRed`red`}` ``
* `` styles.parse`${styles.bgGreen`green`}` ``
* `` styles.parse`${styles.bgYellow`yellow`}` ``
* `` styles.parse`${styles.bgBlue`blue`}` ``
* `` styles.parse`${styles.bgCyan`cyan`}` ``
* `` styles.parse`${styles.bgMagenta`magenta`}` ``
* `` styles.parse`${styles.bgWhite`white`}` ``

#### Modifiers

* `` styles.parse`${styles.bold`bold`}` ``
* `` styles.parse`${styles.dim`dim`}` ``
* `` styles.parse`${styles.italic`italic`}` ``
* `` styles.parse`${styles.inverse`inverse`}` ``
* `` styles.parse`${styles.hidden`hidden`}` ``
* `` styles.parse`${styles.strikethrough`strikethrough`}` ``
* `` styles.parse`${styles.underline`underline`}` ``

### Flowtype

In order for Flowtype to correctly parse the definition, the following option
must be added to your `.flowconfig`.

```
[options]
unsafe.enable_getters_and_setters=true
```

## Changelog

See [changelog][CHANGELOG].

## Licences

`njakob/rainbow` is licensed under the [MIT License][licence].

[changelog]: CHANGELOG.md
[licence]: LICENSE
[github:eslint-config]: https://github.com/njakob/eslint-config
[github:chalk]: https://github.com/chalk/chalk
[npm]: https://nodei.co/npm/@njakob/rainbow
[travis]: https://travis-ci.org/njakob/rainbow
[conventional-commits]: https://conventionalcommits.org
[npm-status-image]: https://img.shields.io/npm/v/@njakob/rainbow.svg
[build-status-image]: https://travis-ci.org/njakob/rainbow.svg?branch=master
[eslint-config-image]: https://img.shields.io/badge/eslint_config-njakob-463fd4.svg
[badge:conventional-commits]: https://img.shields.io/badge/conventional%20commits-1.0.0-yellow.svg

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