summaryrefslogtreecommitdiff
path: root/runtime/js
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2022-09-23 09:35:45 +0530
committerGitHub <noreply@github.com>2022-09-23 09:35:45 +0530
commit72af1496d9bc180b49d42976a31b331d0be1b975 (patch)
treee0cc2fba674ccf3a20e662a44263eb61b21b8c17 /runtime/js
parentb5dfcbbcbe6be8ac0a54e14eb8aeb0557b58f55d (diff)
perf: use fast ops for tty (#15976)
Diffstat (limited to 'runtime/js')
-rw-r--r--runtime/js/40_tty.js20
1 files changed, 12 insertions, 8 deletions
diff --git a/runtime/js/40_tty.js b/runtime/js/40_tty.js
index 9cf351cc0..f43859ed7 100644
--- a/runtime/js/40_tty.js
+++ b/runtime/js/40_tty.js
@@ -2,24 +2,28 @@
"use strict";
((window) => {
+ const {
+ Uint32Array,
+ Uint8Array,
+ } = window.__bootstrap.primordials;
const core = window.Deno.core;
const ops = core.ops;
+ const size = new Uint32Array(2);
function consoleSize(rid) {
- return ops.op_console_size(rid);
+ ops.op_console_size(rid, size);
+ return { columns: size[0], rows: size[1] };
}
+ const isattyBuffer = new Uint8Array(1);
function isatty(rid) {
- return ops.op_isatty(rid);
+ ops.op_isatty(rid, isattyBuffer);
+ return !!isattyBuffer[0];
}
- const DEFAULT_SET_RAW_OPTIONS = {
- cbreak: false,
- };
-
+ const DEFAULT_CBREAK = false;
function setRaw(rid, mode, options = {}) {
- const rOptions = { ...DEFAULT_SET_RAW_OPTIONS, ...options };
- ops.op_set_raw({ rid, mode, options: rOptions });
+ ops.op_set_raw(rid, mode, options.cbreak || DEFAULT_CBREAK);
}
window.__bootstrap.tty = {