Tired of debugging your Javascript with alert or fumbling about with big, bulky debuggers? Ever wish you could add some console.log to your arrow functions, but still return a value?

Well fret no longer! Introducing tonsole: everyone’s favorite vestigial logger. Tonsole is a drop-in replacement for Node’s console that both logs and returns the logged value; a two-in-one that’s functional and fun!

Adding logging to an ordinary Javascript expression is a real pain, and can even be dangerous:

let compute = (data) => data ? process(data.value) : data;

// Fa, la, la. Just adding some logging. What could possibly go wrong...
compute = (data) => {
    if (!data) {
        console.error('Invalid data: ', data);
        // hope I don't hurt myself with all these dangerous statements...
        return data;
    const r = process(data.value);
    console.log('Processed data: ', r);
    // woooooops...
    return data;

Uh oh, what a mess!

But tonsole makes adding logging fast and safe for the whole family:

$ npm install --save tonsole
const tonsole = require('tonsole');

compute = (data) =>
        ?tonsole.log('Processed data: ', process(data.value))
        :tonsole.error('Invalid data: ', data);

And just look at that nice clean expression! You can’t get results like that with ordinary console.

Tonsole is great for composition too:

compute = _.compose(tonsole.log.bind(null, "Result: "), compute);

If you’ve ever used console.log, you can use tonsole. Using a patented nano-combinating process, Tonsole wraps the entire Node console api and adds return values to all your favorite functions, including console.log, console.error, and even console.assert! And, just in case you’re ever confused, tonsole’s got some incredible documentation that’s sure to clear things right up!

Similar libraries retail for thousands of dollars. But now, in a special Npm exclusive offer, tonsole can be yours for zero dollars and zero cents, including shipping and handling! We’ll even throw in the source code and a digital copy of the documentation! Amazing!

So change that C to a T and set your expressions free!

npm install --save tonsole today!