Better HN
topnewbestaskshowjobs
Log inSign up

Thunderya

2 karma · joined Mar 5, 2019 (7y ago) · 3 submissions

Submissions

1.

Leavy raises $14m to be the Europe's answer to Airbnb(techcrunch.com ↗)

1 points · by Thunderya · 7y ago · discuss

comment 7y ago · link · parent

Yes unfortunately my example is not very readable, but it was to illustrate the idea of including the sources of the called functions.

Indeed, many IDEs allow you to easily display the source code of one function at a time, by navigating to the sources of the function or by displaying it in a pop-up, but the idea I had in mind is to be able to view the source code of the function with all its dependencies at a glance.

comment 7y ago · link · parent

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!");
        }
    }