This is a
playground to test code. It runs a full
Node.js environment and already has all of
npm’s 400,000 packages pre-installed, including
fullcolor with all
npm packages installed. Try it out:
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
Use full 24-bit colors in Node.js! This module makes it simple to use and has zero dependencies.
npm install fullcolor # Alternatively: # yarn install fullcolor
const fullcolor = require('fullcolor');
fullcolor function simply adds escape sequences and returns the text as a string. The first argument is always the text you want to color. This also only changes the text color and not the background.
As of right now, only hex values are accepted for colorString.
const fullcolor = require('fullcolor'); console.log(fullcolor('Let there be colors!', '#66ccff')); console.log(fullcolor('Let there be colors!', '#6cf'));
The values r,g,b must be integers from 0 to 255.
const fullcolor = require('fullcolor'); console.log(fullcolor('Let there be colors!', 102, 204, 255));
If you simply want to print a few different colors to the terminal, you might not even need this module! Just copy and paste this snippet:
// Settings in this example: // text = 'TEXT GOES HERE' // r = 102 // g = 204 // b = 255 console.log('\x1b[38;2;102;204;255mTEXT GOES HERE\x1b[0m') // If you use fullcolor, it becomes: console.log(fullcolor('TEXT GOES HERE', 102, 204, 255)) // If you don't use fullcolor, I'm still happy that you read this. // I hope this was helpful and hope that I helped you avoid adding a dependency. // Also, a GitHub star is appreciated ;)
But if you do want a lightweight abstraction, then this module might be for you!
No side effects. No state. No singletons. Does not monkeypatch or mutate anything.
Why? This is a simple tool that adds a few characters to a string. That's it. Dependencies shouldn't be needed for something this simple. Each dependency is a potential security liability and another thing to maintain.
Will follow semver. Major version every time a breaking change is introduced. Minor version on new features. Changes within a major version (e.g.
y > x) will be backward compatible.
Licensed under Apache-2.0. Written and copyright by Iris Li.
I learned most my truecolor stuff from this awesome gist: https://gist.github.com/XVilka/8346728