Created
February 14, 2009 15:11
-
-
Save satyr/64386 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
#!js | |
0,function(stream){ | |
var lines = [], line; | |
while((line = stream.readLine()) !== null) lines.push(line); | |
var code = lines.join('\n'); | |
if(!code) return print('usage: js {this} < perplexing.js > unperplexed.js'); | |
code = (Function(code.replace(/^#!.*\n?/, '')).toString() | |
.replace(/^\s*function.*\s+/, '') | |
.replace(/^ {4}((?: )*)\1/mg, '$1') // halving indentation | |
.replace(/\s+\}\s*$/, '')); | |
print(code); | |
return code; | |
}(typeof java === 'undefined' | |
? {readLine: readline} | |
: new java.io.BufferedReader( | |
new java.io.InputStreamReader(java.lang.System['in']))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment