This made me think: is there an IDE or plugin that makes it easy to visualize the source code of a function by inlining the sources of the undercalled functions?
For example, before the transformation:
function isFooLike(x) {
return x.startsWith("foo");
}
function isBarLike(x) {
return x.startsWith("bar");
}
function bigFunction(str) {
if(isFooLike(str)) {
console.log("Foo!");
}
else if(isBarLike(str)) {
console.log("Bar!");
}
else {
console.log("Unknown!");
}
}
And then:
function bigFunction(str) {
if((function(x) {
return x.startsWith("foo")
})(str)) {
console.log("Foo!");
}
else if((function(x) {
return x.startsWith("bar")
})(str)) {
console.log("Bar!");
}
else {
console.log("Unknown!");
}
}