stream

Methods

(static) create(fd) → {object}

Source:

Create an stream from a file descriptor.

Streams are an efficient way to scan file descriptors for certain types of formats (f.e.: a line of text), without needing to read one byte at a time.

Note that you should NOT create more than one stream for the same file descriptor or you may get into trouble because reads may look incoherent.

Parameters:
Name Type Description
fd number

A valid file descriptor

Returns:

An opaque stream descriptor

Type
object

(static) read_line(sd) → {null|string}

Source:

Read a whole line (all available characters until '\n' or EOF).

Parameters:
Name Type Description
sd object

An opaque stream descriptor

Returns:

A line of text (without the ending \n) or null if EOF was found before the delimiter.

Type
null | string

(static) read_until(sd, delim) → {string}

Source:

Read available characters until a delimiter is found.

Note that, for now, only character (as opposed to string) delimiters are supported.

Parameters:
Name Type Description
sd object

An opaque stream descriptor

delim string

A one-char string containing the delimiter

Returns:

A string without the delimiter or null if EOF was found before the delimiter.

Type
string