So far I've just been copying and pasting my library code—my big pile of functions—from one sample file to the next. That's not exactly ideal, though it works. Thankfully using ES modules, it's pretty easy to take all that code, dump it in an external file, and import it where I need to use it.
In my first example here I did just that, with a library.js
file in the sample script's directory. Note that for simplicity's sake I'm simply doing an export
of every function in the file; I might come back to a fancier or smoother way of handling this later, but for now, again, it just kind of works for what I'm doing. Then I used import
in my main script file to pull it in, assigning the whole thing to the $e
object. That gives me the nice benefit of using code hints in my editor to type $e
and then get suggested autocompletes of all the functions, or "methods," in my library.