Call any program as if it were a function


Call any shell command like a function using EcmaScript 6 Proxies & Generators.

Uses node v0.11.x with --harmony-proxies --harmony-generators flags, along with

Use n to install node v0.11.x

n 0.11.13
var co = require('co');
var read = require('co-read');
var sh = require('co-sh');
co(function *(){
  var ls = yield;
  var buf;
  while (buf = yield read(tail.stdout)) {
  try {
    yield sh.nonexistingcmd();
  } catch(e){

Assuming the above code is in a file called test.js run it using;

node --harmony-proxies --harmony--generators test.js

See the examples folder for more