From 09204107d85351dae07a45f6a9684b5b6e573652 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Mon, 30 Oct 2023 08:53:08 -0700 Subject: fix: implement node:tty (#20892) Fixes #21012 Closes https://github.com/denoland/deno/issues/20855 Fixes https://github.com/denoland/deno/issues/20890 Fixes https://github.com/denoland/deno/issues/20611 Fixes https://github.com/denoland/deno/issues/20336 Fixes `create-svelte` from https://github.com/denoland/deno/issues/17248 Fixes more reports here: - https://github.com/denoland/deno/issues/6529#issuecomment-1432690559 - https://github.com/denoland/deno/issues/6529#issuecomment-1522059006 - https://github.com/denoland/deno/issues/6529#issuecomment-1695803570 --- ext/node/polyfills/internal_binding/util.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'ext/node/polyfills/internal_binding/util.ts') diff --git a/ext/node/polyfills/internal_binding/util.ts b/ext/node/polyfills/internal_binding/util.ts index a2d355c1e..38eeebee0 100644 --- a/ext/node/polyfills/internal_binding/util.ts +++ b/ext/node/polyfills/internal_binding/util.ts @@ -28,10 +28,13 @@ // TODO(petamoriken): enable prefer-primordials for node polyfills // deno-lint-ignore-file prefer-primordials -import { notImplemented } from "ext:deno_node/_utils.ts"; +const core = globalThis.Deno.core; +const ops = core.ops; -export function guessHandleType(_fd: number): string { - notImplemented("util.guessHandleType"); +const handleTypes = ["TCP", "TTY", "UDP", "FILE", "PIPE", "UNKNOWN"]; +export function guessHandleType(fd: number): string { + const type = ops.op_node_guess_handle_type(fd); + return handleTypes[type]; } export const ALL_PROPERTIES = 0; -- cgit v1.2.3