gtarsia / easy-repl

Start a repl with your globals

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

repl-with-globals

Starts a node console (repl) with whatever globals you want to preload it with.

Purpose

I miss rails console when working in js, so this facilitates that sort of things.

Running

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'

Requirements

I don't know how far back it goes, but try using node 11 for top-level async.

About

Start a repl with your globals


Languages

Language:JavaScript 100.0%