Skip to content

Instantly share code, notes, and snippets.

@martin12333
Forked from nexpr/repl.example.txt
Created June 3, 2024 04:56
Show Gist options
  • Save martin12333/976f45ecd8ffd619161d729b14810f9c to your computer and use it in GitHub Desktop.
Save martin12333/976f45ecd8ffd619161d729b14810f9c to your computer and use it in GitHub Desktop.
repl for JScript (windows10 only)
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
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