nodejsscript / echo
constecho:EchoFunction
This is mixed function between bash’s echo and console.log.
By default, works more like console.log with partial supports
for styling mimic CSS and console.log in the web browser. See echo.css (internally uses css-in-console - npm).
The 'echo.use' provides more echo way,
the first argument accepts options string starting with -:
-n: Don’t append new line-1/-2: Outputs tostdout/stderr-c: Don’t colorize output (e.g. objects)-P: Outputs objects in prettier format-R/-r: Starts/Ends rewritable mode (for spinners, progress bars, etc.). Mode can be ended with any otherechowithout-R.
There is also
// as console.log
const count = 5;
echo('count: %d', count);
// Prints: count: 5, to stdout
echo('count:', count);
// Prints: count: 5, to stdout
echo({ count });
// Prints: { count: 5 }, to stdout
echo(new Error("Test"));
// Prints: 'Error: Test', when `config.verbose= false`
echo("%cRed", "color: red");
// Prints 'Red' in redecho.use("-R", "0%");
// …
echo.use("-r", "100%");
// combination
echo.use("-2cP", { a: "A" });echo("Hi").to("./test.txt");
// Prints: 'Hi' & save to file 'test.txt'The text to print.
Returns processed string with additional utility methods like .to().