Skip to main content

readSync

method Deno.stdin.readSync
Jump to headingstdin.readSync(p: Uint8Array): number | null

Synchronously read from the incoming data from stdin into an array buffer (p).

Returns either the number of bytes read during the operation or EOF (null) if there was nothing more to read.

It is possible for a read to successfully return with 0 bytes. This does not indicate EOF.

It is not guaranteed that the full buffer will be read in a single call.

// If the text "hello world" is piped into the script:
const buf = new Uint8Array(100);
const numberOfBytesRead = Deno.stdin.readSync(buf); // 11 bytes
const text = new TextDecoder().decode(buf);  // "hello world"

Parameters Jump to heading

Jump to headingp: Uint8Array

Return Type Jump to heading

number | null
Back to top