ansi-colors-nestable

0.1.1 • Public • Published

ansi-colors-nestable NPM MIT License Build Status Build Status Coverage Status

Enables nested coloring of texts using ansi-colors.

Install

$ npm install ansi-colors-nestable --save-dev

Usage

const nestableColors = require('ansi-colors-nestable');

const ansiColors = require('ansi-colors');

const blue = nestableColors('blue');
const red = nestableColors(ansi.red);

blue('This package ', red('nested'), ' coloring of texts');

API

nestableColors(color) : function

Returns a function which accepts multiple argument texts and colors each of them with color. If an argument text is already colored, that color is given precedence. As a result, this function make coloring nestable.

This function uses the package ansi-colors inside for supporting Node.js >= v0.10. So color names need to be supported by ansi-colors.

Parameters:

Parameter Type Description
color string or function color name or coloring function

Returns:

A coloring function which can colorize multiple argument texts.

Type: function

The API of this returned function is as follows:

  • color**(...texts): string**

    Parameters:

    Parameter Type Description
    texts string(s) texts to be colored.

    Returned:

    A colored and concatenated text

    Type: string

nestableColors.noColor(...texts) : string

This function has the same API with a returned function from nestableColors and simply returned a concatenated text of argument strings without coloring.

Parameters:

Parameter Type Description
texts string(s) texts to be colored.

Returned:

A concatenated text without coloring.

Type: string

License

Copyright (C) 2017 Takayuki Sato

This program is free software under MIT License. See the file LICENSE in this distribution for more details.

Readme

Keywords

Package Sidebar

Install

npm i ansi-colors-nestable

Weekly Downloads

1

Version

0.1.1

License

MIT

Last publish

Collaborators

  • sttk