Skip to content

Instantly share code, notes, and snippets.

@andrijac
Created March 5, 2014 10:41
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 andrijac/9364950 to your computer and use it in GitHub Desktop.
Save andrijac/9364950 to your computer and use it in GitHub Desktop.
Node.js console boilerplate
var readline = require('readline');
var toArray = function(){return Array.prototype.slice.call(arguments[0]);}
var log = function() {
var arr = toArray(arguments).map(function(v) {
// debugger;
return v + '';
});
console.log(arr.join(" "));
}
var blank = function(){log("");}
var wl = function(){log.apply(this, toArray(arguments)); blank();}
blank();
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
if (process.argv.length < 3) {
process.argv.forEach(function (e) {
wl(e);
});
}
rl.question("", function(){rl.close();});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment