5.0.2 • Published 11 months ago

extra-runnable v5.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

extra-runnable

The Runnable and Runner in JavaScript/Typescript.

Install

npm install --save extra-runnable
# or
yarn add extra-runnable

API

IRunnable

interface IRunnable<Result, Args extends unknown[]> {
  init(): Awaitable<void>
  run(...args: Args): Awaitable<Result>
  abort(): Awaitable<void>
  destroy(): Awaitable<void>
}

Runner

enum RunnerState {
  Created = 'created' // => Initializing
, Initializing = 'initializing' // => Ready or Crashed
, Crashed = 'crashed' // => Initializing
, Ready = 'ready' // => Starting or Destroyed
, Starting = 'starting' // => Running or Error
, Running = 'running' // => Stopping or Completed or Error
, Stopping = 'stopping' // => Stopped
, Stopped = 'stopped' // => Destroyed or Starting
, Completed = 'completed' // => Destroyed or Starting
, Error = 'error' // => Destroyed or Starting
, Destroyed = 'destroyed'
}

class Runner<Result, Args extends unknown[]> {
  constructor(runnable: IRunnable<Result, Args>)

  getState(): RunnableState
  async init(): Promise<void>
  async run(...args: Args): Promise<Result>
  async abort(): Promise<void>
  async destroy(): Promise<void>
}
5.0.2

11 months ago

5.0.1

1 year ago

4.0.0

1 year ago

5.0.0

1 year ago

3.0.1

2 years ago

3.0.0

2 years ago

2.0.0

2 years ago

1.0.0

2 years ago