I guess when you do things like this with your parameters, you possibly need a parser.
const myDaftFunction = (
n,
greet = function(
{ greeting = 'Hello', name = 'Bob' } = {},
fn = (str) => str.toUpperCase(),
sep = ' '
) {
return fn(greeting + sep + name)
}
) => {
return greet({name: 'Fred!'}).repeat(n)
}
console.log(myDaftFunction(3)) // "HELLO FRED!HELLO FRED!HELLO FRED!"
I would also add that if I was writing my own framework, that using something like Acorn would make perfect sense.
It’s been interesting looking into this though