Marak / colors.js

get colors in your node.js console
https://github.com/Marak/colors.js
Other
5.17k stars 446 forks source link

Boolean values return undefined #209

Closed eperry closed 6 years ago

eperry commented 6 years ago

I believe this to be a bug/unhandled issue with colors

If you use"colors" on boolean values it comes back as undefined not true.{color} or "false.".{color}

var colors = require('colors') var isTrue = true console.log("isTrue ",isTrue) console.log ("isTrue ".red,isTrue.green)

screenshot from 2018-02-03 17-14-54

I know how to deal with this with an if statement but believe since this is a Language defined type, it should be handled within colors

22nds commented 6 years ago

Maybe this will help you.

console.log(colors.red("isTrue "), colors.green(isTrue));
DABH commented 6 years ago

The nifty way of using colors extends String prototypes, but not Boolean prototypes; so as the above commenter suggested you have to use the non-nifty way to bools. We'd welcome a PR to extend the Boolean class in a similar way as Strings; but otherwise I'll close this issue for now since there is a standard way of handling this already. Thanks!