The tiniest and the fastest library for terminal output formatting with ANSI colors
89
A terminal color formatting utility that works across different JavaScript environments, including those where the Node.js process object may not be available.
process object is undefined (browser environment), color support detection returns false without throwing an error @testprocess.stdout is undefined but process exists, color support detection handles this gracefully and returns false @test@generates
/**
* Checks if the current environment supports terminal colors.
* Safely handles missing process object.
*
* @returns {boolean} true if colors are supported, false otherwise
*/
function isColorSupported() {
// IMPLEMENTATION HERE
}
/**
* Formats text with red color when supported.
*
* @param {string} text - The text to format
* @returns {string} Formatted text with ANSI codes if supported, plain text otherwise
*/
function red(text) {
// IMPLEMENTATION HERE
}
module.exports = {
isColorSupported,
red
};Provides terminal color formatting with defensive programming patterns for missing process object.
Install with Tessl CLI
npx tessl i tessl/npm-picocolorsdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10