Giter Site home page Giter Site logo

rainbow-word's Introduction

rainbow-word

A node module that uses chalk.js to write strings in a colored/stylized pattern.

rainbow-word screencap

package.json

{
  ...
  "dependencies": {
    ...
    "rainbow-word": "git://github.com/unenglishable/rainbow-word",
    ...
  },
  ...
}

Usage

var rw = require('rainbow-word');

Pattern

var rw = require('rainbow-word');
var rainbow = rw.pattern(options);
rainbow.convert('Hello', 'World', ...);

.convert(string1, string2, ...);

.convert() will combine all arguments supplied to it into a single string. Cycling through elements in the scheme array, it converts each argument accordingly.

For a complete list of colors and styles, see the chalk.js git repo.

// Use the default pattern
var default = rw.pattern();
/*
 *  color: '',
 *  scheme: [
 *    {color: 'red'},
 *    {color: 'yellow'},
 *    {color: 'green'},
 *    {color: 'blue'},
 *    {color: 'magenta'}],
 *  styles: [],
 *  save: false
 */

// Supply options to the pattern constructor
var options = {
  color: 'red',
  bgColor: 'bgWhite',
  style: 'bold,
  styles: ['bold', 'underline', ...],
  scheme: [
    {color: 'red', bgColor: 'bgWhite', style: 'bold', styles: ['bold', 'underline', ...]},
    {color: 'blue', style: 'bold'},
    {color: 'white', styles: ['bold', 'underline', ...]},
    {color: 'black'},
    ... ];
  save: true
}

Options are parsed as follows:

  • Anything provided in the scheme has priority (overrides other options)

  • style overrides styles

  • If color is not provided in scheme, color option will be used.

  • bgColor behaves the same way as color

  • If style/styles is/are not provided in scheme, style/styles option will be used.

  • If nothing is provided, defaults will be used

The save option specifies that the pattern should keep track of the last element in the scheme it used and continue there on the next call to .convert(). If save is false, the position is reset after each call to .convert().

Examples

See the example file for examples.

rainbow-word's People

Contributors

unenglishable avatar

Stargazers

Andrew Prentice avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.