Skip to content

Instantly share code, notes, and snippets.

@dperini
Created May 21, 2011
Embed
What would you like to do?
/*
*
* readfile.js - Spidermonkey/V8 readfile wrapper
*
* Author: Diego Perini <diego.perini@gmail.com>
*
* Released under the Creative Commons license:
* http://creativecommons.org/licenses/by/3.0/
*
*/
// read file from "stdin" using SM or V8 style
var _readFile = typeof this.read == 'function' ?
function() {
return read('/dev/stdin');
} : typeof this.readline == 'function' ?
function() {
var outstr = '', line = '';
while ((line = readline()) != null) {
outstr += line + '\x0a';
}
return outstr;
} :
function() {
return '';
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment