0.1.1 • Published 6 years ago

ansi-colors-nestable v0.1.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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:

ParameterTypeDescription
colorstring or functioncolor 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:

    ParameterTypeDescription
    textsstring(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:

ParameterTypeDescription
textsstring(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.