Object - io : ReadableByteChannel

ReadableByteChannel represents an input resource (i.e file, socket). which could be used to source bytes.

read

(int nBytes)

returns [byte[], int] | Error

Source bytes from a given input/output resource.

Number of bytes returned will be < 0 if the file reached its end.

This operation will be asynchronous, where the total number of required bytes might not be returned at a given time.

Parameters

  • nBytes int
  • Positive integer. Represents the number of bytes which should be read

  • Return Type

    ([byte[], int] | Error)
  • Content, the number of bytes read or Error if any error occurred

base64Encode

()

returns ReadableByteChannel | Error

Encodes a given ReadableByteChannel with Base64 encoding scheme.

base64Decode

()

returns ReadableByteChannel | Error

Decodes a given ReadableByteChannel with Base64 encoding scheme.

close

()

returns Error?

Closes a given ReadableByteChannel.

  • Return Type

    (Error?)
  • Will return () if there's no error