bare-repl
Read-Evaluate-Print-Loop environment for JavaScript.
npm i bare-repl
Usage
const { start } = require('bare-repl')
const repl = start()
API
const repl = start([options])
Options include:
{
prompt: string,
useColors: boolean,
writer: (message) => message,
input: stream,
output: stream,
eval: (cmd) => {},
useGlobal: boolean
}
repl.defineCommand(keyword, { help, action })
Define a repl command keyword.
repl.defineCommand('greet', {
help: 'Greetings',
action: () => console.log('hello')
})
bare-repl
> .greet
hello
repl.context
Set execution context.
repl.context.f = () => console.log('Hello from context')
bare-repl
> f()
Hello from context
License
Apache-2.0