Class Attempt

One attempt of a step, counted from 1: the first execution of a step is its first attempt, and each retry is the next. Only itinera makes one.

It writes itself as its number, in a template string and in JSON.

import assert from "node:assert/strict";
import { Attempt } from "itinera/step";

function label(attempt: Attempt): string {
return attempt.isFirst()
? "first try"
: `retry, attempt ${attempt.toString()}`;
}

assert.equal(label(Attempt.first), "first try");
assert.equal(Attempt.first.number, 1);
assert.equal(JSON.stringify({ attempt: Attempt.first }), '{"attempt":1}');

Index

number: number

The attempt's number, from 1.

first: Attempt = ...

The first attempt of a step.

  • Whether this is the first attempt of its step.

    Returns boolean

  • The attempt's number, which is how JSON.stringify writes it.

    Returns number

  • The attempt's number, as text.

    Returns string