Created
May 21, 2011 10:39
-
-
Save dperini/984426 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* | |
* readfile.js - Spidermonkey/V8 readfile wrapper | |
* | |
* Author: Diego Perini <[email protected]> | |
* | |
* 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