basic-repl

2.2.2 • Public • Published

Super basic repl (read, eval, print, loop) for creating CLIs

Usage

repl(prefix, handler)

Example

import repl from 'basic-repl'
repl('> ', code => {
	//Eval input and log it
	console.log(eval(code))
})
repl('[server] ', msg => {
	//This repl is for our chat
	//(Let's assume you already made a function chat(){...})
	chat(msg)
	console.log('✓ Chat message sent')
})

You can switch between multiple repls you have created with Tab

Commonjs

// For compatibility, commonjs works slightly differently
//1. a space is appended to the end of the prefix
//2. the value returned by the function is logged (in ES6 you must console.log() it yourself)
require('basic-repl')('$', code => eval(code))

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i basic-repl

      Weekly Downloads

      5

      Version

      2.2.2

      License

      ISC

      Unpacked Size

      10.3 kB

      Total Files

      4

      Last publish

      Collaborators

      • blobkat