diff options
author | Luca Casonato <hello@lcas.dev> | 2023-04-06 00:14:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-06 00:14:16 +0200 |
commit | 36e8c8dfd759458aa735f79f5cc7cd346c727914 (patch) | |
tree | ca8065958c406c02a8daa56f5056a658c813839f /core/lib.deno_core.d.ts | |
parent | ee15b49845b9cbe1f8ea75372091931fa460ad0d (diff) |
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.
Diffstat (limited to 'core/lib.deno_core.d.ts')
-rw-r--r-- | core/lib.deno_core.d.ts | 10 |
1 files changed, 10 insertions, 0 deletions
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 @@ -61,6 +61,16 @@ declare namespace Deno { function writeAll(rid: number, buf: Uint8Array): Promise<void>; /** + * 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 */ function print(message: string, is_err?: boolean): void; |