Skip to content

Latest commit

 

History

History
101 lines (57 loc) · 2.26 KB

loopstrategyasync.md

File metadata and controls

101 lines (57 loc) · 2.26 KB

lexureLoopStrategyAsync

Interface: LoopStrategyAsync <A, Z, E>

A strategy for running an input loop asynchronously via Promise.

Type parameters

  • A

Input type.

  • Z

Output type.

  • E

Error type.

Hierarchy

  • LoopStrategyAsync

Index

Methods

Methods

getInput

Gets new input from somewhere e.g. reading a line.

Returns: Promise<LoopAction<A, Z, E>>

A loop action that can: step with the input; finish with some parsed value; fail due to an error.


parse

  • parse(input: A): Promise<LoopAction<null, Z, E>>

Parses given input into the desired type.

Parameters:

Name Type Description
input A The input.

Returns: Promise<LoopAction<null, Z, E>>

A loop action that can: step on; finish with some parsed value; fail due to an error.


optional onInputError

  • onInputError(error: E): Promise<LoopAction<null, Z, E>>

Handles error on getting new input. This function intercepts the fail case of getInput.

Parameters:

Name Type Description
error E The error encountered.

Returns: Promise<LoopAction<null, Z, E>>

A loop action that can: step on; finish with some parsed value; fail due to an error.


optional onParseError

  • onParseError(error: E, input: A): Promise<LoopAction<null, Z, E>>

Handles error on parsing input. This function intercepts the fail case of parse.

Parameters:

Name Type Description
error E The error encountered.
input A The input that could not be parsed.

Returns: Promise<LoopAction<null, Z, E>>

A loop action that can: step on; finish with some parsed value; fail due to an error.