Skip to main content

abstractWorkUnit <Options, Input, Output>

Hierarchy

Implements

Index

Events

readonlyonFail

onFail: Event<[null | Error, Input], string> = ...

Called when an execution fails.

readonlyonPass

onPass: Event<[Output, Input], string> = ...

Called when an execution succeeds.

readonlyonRun

onRun: BailEvent<[Input], string> = ...

Called before a work unit is executed. Can return true to skip the work unit.

readonlyonSkip

onSkip: Event<[Input], string> = ...

Called when an execution is skipped.

Other

constructor

  • new WorkUnit<Options, Input, Output>(title: string, action: Action<any, Input, Output>, options?: Options): WorkUnit<Options, Input, Output>
  • Type parameters

    • Options: object
    • Input = unknown
    • Output = Input

depth

depth: number = 0

Current depth of nested pipelines.

index

index: number = 0

Current index amongst sibling work units.

optionalinput

input?: Input

readonlyoptions

options: Readonly<Required<Options>>

Validated and configured options.

optionaloutput

output?: Output

startTime

startTime: number = 0

statusText

statusText: string = ''

stopTime

stopTime: number = 0

readonlytitle

title: string

id

  • get id(): string
  • Return a unique hierarchical ID.

abstractblueprint

  • blueprint(_schemas: __module, onConstruction?: boolean): object
  • Define an optimal blueprint in which to validate and build the options object passed to the constructor, or when manual setting.

    A boolean is passed as the 2nd argument to determine whether this is validating on class instantiation (first time), or by calling configure() (all other times).

configure

  • configure(options?: Partial<Options> | (options: Required<Options>) => Partial<Options>): Readonly<Required<Options>>
  • Set an options object by merging the new partial and existing options with the defined blueprint, while running all validation checks. Freeze and return the options object.

    object.configure({ name: 'Boost' });

    object.configure((prevOptions) => ({
    nestedObject: {
    ...prevOptions.nestedObject,
    some: 'value',
    },
    }));

hasFailed

  • hasFailed(): boolean
  • Return true if the task failed when executing.

hasPassed

  • hasPassed(): boolean
  • Return true if the task executed successfully.

isComplete

  • isComplete(): boolean
  • Return true if the task has been completed in any form.

isPending

  • isPending(): boolean
  • Return true if the task has not been executed yet.

isRunning

  • isRunning(): boolean
  • Return true if the task is currently running.

isSkipped

  • isSkipped(): boolean
  • Return true if the task was or will be skipped.

run

  • run(context: Context, value: Input): Promise<Output>
  • Run the current task by executing it and performing any before and after processes.

skip

  • skip(condition?: boolean): this
  • Mark a task as skipped if the condition is true.