Skip to content

Instantly share code, notes, and snippets.

@piranna
Last active March 20, 2016 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piranna/7dc47f387ecdcf739a19 to your computer and use it in GitHub Desktop.
Save piranna/7dc47f387ecdcf739a19 to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
var Interface = require('readline').Interface
var ReadStream = require('tty').ReadStream
var spawn = require('child_process').spawn
Interface(process.stdin, process.stdout)
var stdin = ReadStream(process.stdin.fd)
process.stdin.pause()
var stdio = [stdin, process.stdout]
spawn('cat', [], {stdio: stdio})
#!/usr/bin/env node
var Readable = require('stream').Readable
var spawn = require('child_process').spawn
const input = 'Habia una vez un circo que siempre alegraba el corazon'
const kpm = 240
var stdio = ['pipe', process.stdout, process.stderr]
var cp = spawn('./fixture.js', [], {stdio: stdio})
var stdin = new Readable()
stdin._read = function(){}
stdin.pipe(cp.stdin)
var index = 0
function type()
{
var data = input[index] || null
stdin.push(data)
index++
if(data !== null) setTimeout(type, 60*1000/kpm)
}
type()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment