Hacker News new | ask | show | jobs
by daliwali 3273 days ago
This has been revised. There is now a separate entry point for helpers, to make it obvious to people who don't read docs, that it is separate functionality:

    var helpers = require('simulacra/helpers')
    var bindEvents = helpers.bindEvents
    var animate = helpers.animate
There is no practical difference. It is just for those who read code but lack reading comprehension skills.
1 comments

I'm not sure what that accomplishes.

The "entire API surface area," as you put it, surely includes more functions than the only one you need for a landing page's hello-world. I don't evaluate something like Simulacra with a hello-world in mind, else I wouldn't need Simulacra.

My advice is to just change "one function" to "tiny API". Or maybe "just three functions in the public API". That's just as respectable and spares you from needing to split your API into a pointless "helpers" namespace.

    const {bindObject, bindEvents, animate} = require('simulacra')
^ looks ideal to me.
No, the entire API really is one function. The events and animation helpers can be implemented by the user in a few lines of code, they are not at all required. There is nothing stopping you from adding event listeners or CSS classes without these conveniences. Putting rather trivial functionality in the same level as the only core function would be highly misleading. I would rather completely remove the helper functions, than to satisfy pedants who complain, "but there's two completely optional functions so it's not just one!!1"