Starts a node console (repl) with whatever globals you want to preload it with.
I miss rails console
when working in js, so this facilitates that sort of things.
Please, run this in node 11 and use node --experimental-repl-await
for awesome top-level async support.
const dog = {
bark: () => 'Woof, woof'
barkAsync: async () => Promise.resolve(dog.bark())
}
const repl = require('repl-with-globals')
repl({ dog })
// > dog.bark()
// 'Woof, woof'
// > await dog.barkAsync()
// 'Woof, woof'
I don't know how far back it goes, but try using node 11 for top-level async.