terminal-duplex

2.0.7 • Public • Published

terminal-duplex

const Terminal = require('terminal-duplex')
const terminal = new Terminal()

x.on('some output', data=> terminal.log(data)) //console.logs
const listener = input=> terminal.log('user inputted:', input)
terminal.listen(listener) //can add as many as you want

terminal.unlisten(listener) //if you want you can also unlisten when you're done

terminal.close() //unhooks from input and outputs

alternatively instead of using terminal.log you could just pass true into the constructor and it will overwrite console.log everywhere.

const Terminal = require('terminal-duplex')
const terminal = new Terminal(true)

x.on('some output', data=> console.log(data))
const listener = input=> console.log('user inputted:', input)
terminal.listen(listener) //can add as many as you want

terminal.unlisten(listener) //if you want you can also unlisten when you're done

terminal.close() //unhooks from input and outputs

What is this?

Turns this:

image

Into this:

image

image

image

Amazingly something like this didn't exist already.

Package Sidebar

Install

npm i terminal-duplex

Weekly Downloads

0

Version

2.0.7

License

ISC

Unpacked Size

5.76 kB

Total Files

5

Last publish

Collaborators

  • jestdotty