amber/stdout

Values

pub fn close() -> Nil

Closes stdout, freeing the resource.

Examples

stdout.close()
pub fn is_terminal() -> Bool

Checks if stdout is a TTY (terminal).

Examples

// This example is system and context specific
stdout.is_terminal() // True
pub fn writable() -> writable_stream.WritableStream(
  uint8_array.Uint8Array,
)

A writable stream interface to stdout.

pub fn write(
  p: uint8_array.Uint8Array,
) -> promise.Promise(Result(Int, error.Error))

Write the contents of the array buffer (p) to stdout.

Resolves to the number of bytes written.

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

Examples

let data = text_encoder.encode("Hello world")
use result <- promise.then(stdout.write(data))
let assert Ok(bytes_written) = result
// bytes_written == 11
pub fn write_sync(p: uint8_array.Uint8Array) -> Int

Synchronously write the contents of the array buffer (p) to stdout.

Returns the number of bytes written.

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

Examples

let data = text_encoder.encode("Hello world")
let bytes_written = stdout.write_sync(data)
// bytes_written == 11
Search Document