Class: StdioContext

StdioContext

new StdioContext(options)

Creates a stdio context in which the given streams will be used as stdin, stdout, and stderr.
Parameters:
Name Type Description
options StdioContextOptions | Array.<(!stream.Readable|!stream.Writable)> Streams which will be used as stdin, stdout, and stderr either as an object with named properties or an Array of [stdin, stdout, stderr].
Source:
See:

Methods

enter()

Enters this stdio context and starts using the stdio streams it defines.
Source:
See:

exec(func, …args) → {ReturnType}

Executes a function, which may be either synchronous or asynchronous, such that it executes in this stdio context. This function behaves as if it called #wrap and immediately invoked the result with the remaining arguments. @ template ReturnType
Parameters:
Name Type Attributes Description
func function Function to execute.
args * <repeatable>
Arguments passed to func.
Source:
See:
Returns:
Value returned by func.
Type
ReturnType

execSync(func, …args) → {ReturnType}

Executes a synchronous function such that it executes in this stdio context. This function behaves as if it called #wrap and immediately invoked the result with the remaining arguments. @ template ReturnType
Parameters:
Name Type Attributes Description
func function Function to execute.
args * <repeatable>
Arguments passed to func.
Source:
See:
Returns:
Value returned by func.
Type
ReturnType

exit()

Exits this stdio context, stops using the stdio streams it defines, and restores the stdio streams present when enter() was called.
Source:
See:
Throws:
If this instance was constructed with options.strict and the streams do not have the values set by StdioContext#enter.
Type
Error

wrap(func) → {Func}

Wraps a function, which may be either synchronous or asynchronous, such that it executes in this stdio context. This stdio context is entered when the returned wrapper function is called and exited under any of the following conditions: - When the wrapped function throws an exception. - When the wrapped function returns, if it didn't return a Promise and the last argument was not a function. - When a Promise returned by the function is resolved or rejected. - When a function passed as the last argument to the function is called. @ template Func
Parameters:
Name Type Description
func Func Function to wrap.
Source:
See:
Returns:
A function which enters this stdio context, invokes func with the arguments given and a wrapped callback, if present. Then exits this stdio context when the callback is first called, or when the returned Promise is resolved or rejected, or immediately if the invoked function throws an exception or doesn't have a Promise or callback.
Type
Func

wrapSync(func) → {Func}

Wraps a synchronous function such that it executes in this stdio context. This stdio context is entered when the returned wrapper function is called and exited when the wrapped function returns or throws an exception. @ template Func
Parameters:
Name Type Description
func Func Function to wrap.
Source:
See:
Returns:
A function which enters this stdio context, invokes func with the arguments given, then exits this stdio context upon return or exception from func.
Type
Func