0.3.0 • Published 3 years ago

@alu0101244488/addlogging v0.3.0

Weekly downloads
-
License
-
Repository
-
Last release
3 years ago

addLogging

module that provides a function that adds a console.log() statement to the functions of the code given. The statement gives information about the name of the function and its parameters.

How it works

The function takes as input a string of code as the one below:

const input = `
function foo(a, b) {
  var x = 'blah';
  var y = (function () {
    return 3;
  })();
}
foo(1, 'wut', 3);
`;

Then the functions read that string and adds a console.log() statement in all the functions in the code. The result with the example of above is the next:

const input = `
function foo(a, b) {
    console.log('Entering foo(${a},${b})');
    var x = 'blah';
    var y = function () {
        console.log('Entering <anonymous function>()');
        return 3;
    }();
}
foo(1, 'wut', 3);

Tests

npm test

Release History

  • 0.2.0 Initial release