Babel plugin that compiles ES2015 default and rest parameters to ES5-compatible code
91
Build a utility that transforms JavaScript code by wrapping all function calls with a logging statement that records the function name being called.
Your solution should:
For example:
add(1, 2)(console.log("Calling: add"), add(1, 2))The utility should handle:
functionName(args)object.method(args)Create a module that exports a wrapFunctionCalls function:
/**
* Wraps all function calls in the source code with logging statements.
* @param {string} sourceCode - The JavaScript source code to transform
* @returns {string} The transformed code with logging around function calls
*/
function wrapFunctionCalls(sourceCode) {
// Implementation here
}
module.exports = { wrapFunctionCalls };add(1, 2) returns code that logs "Calling: add" before calling the function @testuser.getName() returns code that logs "Calling: getName" before calling the method @testconst result = multiply(3, 4); returns code where the function call is wrapped but the variable assignment works correctly @testProvides JavaScript parsing to AST.
@satisfied-by
Provides AST node creation, validation, and manipulation utilities.
@satisfied-by
Provides AST traversal capabilities.
@satisfied-by
Provides code generation from AST.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-babel--plugin-transform-parametersdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10