From 36e8c8dfd759458aa735f79f5cc7cd346c727914 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Thu, 6 Apr 2023 00:14:16 +0200 Subject: feat(core): sync io ops in core (#18603) This commit adds op_read_sync and op_write_sync to core. These ops are similar to op_read and op_write, but they are synchronous. Just like the async ops, they operate on generic `deno_core::Resource` objects. These now have new `read_byob_sync` and `write_sync` methods, with default implementations throwing "NotSupported" errors, just like the async counterparts. There are no `write_all` or `read` equivalents, because the optimizations they unlock are not useful in synchronous contexts. --- core/lib.deno_core.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'core/lib.deno_core.d.ts') diff --git a/core/lib.deno_core.d.ts b/core/lib.deno_core.d.ts index b238bd6b3..7f3ea2a19 100644 --- a/core/lib.deno_core.d.ts +++ b/core/lib.deno_core.d.ts @@ -60,6 +60,16 @@ declare namespace Deno { */ function writeAll(rid: number, buf: Uint8Array): Promise; + /** + * Synchronously read from a (stream) resource that implements readSync(). + */ + function readSync(rid: number, buf: Uint8Array): number; + + /** + * Synchronously write to a (stream) resource that implements writeSync(). + */ + function writeSync(rid: number, buf: Uint8Array): number; + /** * Print a message to stdout or stderr */ -- cgit v1.2.3