summaryrefslogtreecommitdiffstats
path: root/Tools/wasm/python.worker.js
diff options
context:
space:
mode:
authorTrey Hunner <trey@treyhunner.com>2022-07-01 09:52:58 (GMT)
committerGitHub <noreply@github.com>2022-07-01 09:52:58 (GMT)
commita8e333d79aa639417e496181bcbad2cb801a7a56 (patch)
treed136e1ebf4dc07e41c52147b6cb1fe9a7bfd4a47 /Tools/wasm/python.worker.js
parent5f2c91a343fb20f8c2fc78cbb3e68234bcba40a8 (diff)
downloadcpython-a8e333d79aa639417e496181bcbad2cb801a7a56.zip
cpython-a8e333d79aa639417e496181bcbad2cb801a7a56.tar.gz
cpython-a8e333d79aa639417e496181bcbad2cb801a7a56.tar.bz2
gh-84461: Improve WebAssembly in-browser demo (#91879)
* Buffer standard input line-by-line * Add non-root .editorconfig for JS & HTML indent * Add support for clearing REPL with CTRL+L * Support unicode in stdout and stderr * Remove \r\n normalization * Note that local .editorconfig file extends root * Only normalize lone \r characters (convert to \n) * Skip non-printable characters in buffered input * Fix Safari bug (regex lookbehind not supported) Co-authored-by: Christian Heimes <christian@python.org>
Diffstat (limited to 'Tools/wasm/python.worker.js')
-rw-r--r--Tools/wasm/python.worker.js8
1 files changed, 2 insertions, 6 deletions
diff --git a/Tools/wasm/python.worker.js b/Tools/wasm/python.worker.js
index c3a8bdf..1b79460 100644
--- a/Tools/wasm/python.worker.js
+++ b/Tools/wasm/python.worker.js
@@ -35,15 +35,11 @@ class StdinBuffer {
}
}
-const stdoutBufSize = 128;
-const stdoutBuf = new Int32Array()
-let index = 0;
-
const stdout = (charCode) => {
if (charCode) {
postMessage({
type: 'stdout',
- stdout: String.fromCharCode(charCode),
+ stdout: charCode,
})
} else {
console.log(typeof charCode, charCode)
@@ -54,7 +50,7 @@ const stderr = (charCode) => {
if (charCode) {
postMessage({
type: 'stderr',
- stderr: String.fromCharCode(charCode),
+ stderr: charCode,
})
} else {
console.log(typeof charCode, charCode)