vantage-es6-contextified-repl

0.1.0 • Public • Published

Vantage REPL - ES6 & Context

NPM

Build Status code coverage code style code style: prettier made with lass license

Table of Contents

Install

npm:

npm install vantage-es6-contextified-repl

yarn:

yarn add vantage-es6-contextified-repl

Usage

import Vantage from 'vantage'
import repl from 'vantage-es6-contextified-repl'
 
const vantage = Vantage()
  .delimiter('awesome-server$')
  .use(repl, {
    description: 'REL with custom context',
    banner: 'Welcome to my contextified REPL mode !',
    delimiter: chalk.red('repl:'),
    context: { app, db },
    timeout: 10000
  })
  .listen(80)
  .show()
user$ vantage my.server.com:8080
awesome-server$ awesome-repl
Welcome to my contextified REPL mode !
awesome-server$ repl: db.users.find()
[
  { id: 1, name: 'John Doe' },
  { id: 2, name: 'Jane Doe' }
]
awesome-server$ repl: Promise.all([db.users.findOne(2), db.users.findOne(1)])
[
  { id: 2, name: 'Jane Doe' },
  { id: 1, name: 'John Doe' }
]
awesome-server$ repl: Promise.resolve(10).delay(11000)
Error: TimeoutError: operation timed out

Options

  • mode - the command to type to enter in REPL mode, default to repl.
  • description - the mode description displayed in help menu, default to Enters REPL mode..
  • banner - the welcome message displayed when entrering in REPL mode, default to: Entering REPL Mode. To exit, type 'exit'.
  • delimiter - the additional delimiter of the mode, default to repl:.
  • timeout - the maximum amout of time to eval the code, default to 15000.
  • context - the REPL context, accessible from evalued code, default to {}.
  • compiler - the code transformation functon, set null or a functon using signature function(code:string) and that returns a string, the default function uses Babel.
  • formatter - the output transformation functon, set highlight, none or a functon using signature function(input:string) and that returns a string, default to highlight.

TODO: Make an option to use a custom or predefined theme for highlight formatter

Contributors

Name
Victor Rebiard--Crépin

License

MIT © Victor Rebiard--Crépin

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.0
    2
    • latest

Version History

Package Sidebar

Install

npm i vantage-es6-contextified-repl

Weekly Downloads

2

Version

0.1.0

License

MIT

Last publish

Collaborators

  • vblitz