Using the colors
node module, I could do this:
var foo = "bar".cyan;
Now, instead of having a length of 3, foo
has a length of 13 because of the colors:
foo.length; // -> 13
util.inspect(foo); // -> '\u001b[36mfoo\u001b[39m'
I'm trying to do fancy console logging that deals in columns, etc. and not being able to know the displayed length (3) versus the technical length (13) is killing me.
Is there some function that returns the 'user-viewed' length?
I ended up making this function so far:
Any better or built-in ideas would be appreciated.