terminal-duplex

terminal console that can handle input & output at the same time

Usage no npm install needed!

<script type="module">
  import terminalDuplex from 'https://cdn.skypack.dev/terminal-duplex';
</script>

README

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.