Created
May 26, 2017 13:51
-
-
Save nexpr/eb2963ccdbcc3f33bfce49e2861f9b75 to your computer and use it in GitHub Desktop.
repl for JScript (windows10 only)
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
C:\Users\user\Desktop>cscript //E:{1b7cd997-e5ff-4932-a7a6-2a9e636da385} repl.js | |
Microsoft (R) Windows Script Host Version 5.812 | |
Copyright (C) Microsoft Corporation. All rights reserved. | |
> if(true){\ | |
> 1\ | |
> } | |
1 | |
> var a = 10 | |
undefined | |
> a | |
10 | |
> exit |
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
let acc = "" | |
while(true){ | |
WScript.StdOut.Write("> ") | |
const input = WScript.StdIn.ReadLine() | |
if(input === "exit"){ | |
break | |
} | |
if(input.endsWith("\\")){ | |
acc += input.slice(0, -1) + "\n" | |
continue | |
} | |
const source = acc + input | |
acc = "" | |
try{ | |
const [result = "undefined" ] = [eval(source)] | |
WScript.Echo(result) | |
}catch(err){ | |
WScript.Echo(err.message) | |
WScript.Echo(err.stack) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment