sesaparcours
    Preparing search index...

    A class to manage checkpoints (multiple backups). Stored data is of type string (json conversion if needed). One can add tags to checkpoints.

    name is a string used to identify each instance. maxItems is the maximum number of checkpoints we keep before removing old ones. Set to zero to disable.

    Type Parameters

    • T
    Index

    Constructors

    • Type Parameters

      • T

      Parameters

      • name: string
      • OptionalmaxItems: number

      Returns CheckpointsManager<T>

    Properties

    ready: () => Promise<[void, void]>
    toHumanDate: (timestamp: string | number) => string

    Convert a timestamp to a (french) human date : DD/MM/YYYY, hh:mm:ss

    Methods

    • Clear all checkpoints.

      Returns Promise<void>

    • Get checkpoint from its timestamp.

      Parameters

      • timestamp: string

      Returns Promise<T | null | undefined>

    • Get checkpoint at a specific index (0 is the most recent).

      Parameters

      • index: number

      Returns Promise<T | null | undefined>

    • Get tags at a specific index (0 is the most recent).

      Parameters

      • index: number

      Returns Promise<string[] | undefined>

    • Get timestamp at a specific index (0 is the most recent).

      Parameters

      • index: number

      Returns Promise<string | undefined>

    • Get the most recent checkpoint. Equivalent to getIndex(0).

      Returns Promise<T | null | undefined>

    • Get the most recent tags. Equivalent to getIndex(0).

      Returns Promise<string[] | undefined>

    • Get the most recent timestamp. Equivalent to getIndexTimestamp(0).

      Returns Promise<string | undefined>

    • Get tags from timestamp.

      Parameters

      • timestamp: string

      Returns Promise<string[] | undefined>

    • Does this checkpoint has this tag?

      Parameters

      • timestamp: string
      • tag: string

      Returns Promise<boolean | null>

    • Does the most recent checkpoint has this tag?

      Parameters

      • tag: string

      Returns Promise<boolean | null>

    • Get the total number of checkpoints.

      Returns Promise<number>

    • Push checkpoint to DB. Timestamps are computed here. tags is an array of strings.

      Parameters

      • data: T
      • Optionaltags: string[] | null

      Returns Promise<string>

    • Remove checkpoint at a specific timestamp.

      Parameters

      • timestamp: string

      Returns Promise<void>

    • Remove the oldest checkpoint.

      Returns Promise<void>

    • Set a tag to a checkpoint.

      Parameters

      • timestamp: string
      • tag: string

      Returns Promise<void>

    • Add a tag to last checkpoint.

      Parameters

      • tag: string

      Returns Promise<void>

    • Get the array of all timestamps sorted in reverse historical order.

      Returns Promise<string[] | undefined>

    • Remove a tag from a checkpoint.

      Parameters

      • timestamp: string
      • tag: string

      Returns Promise<void>

    • Remove a tag from last checkpoint.

      Parameters

      • tag: string

      Returns Promise<void>

    • Drop a checkpoint table from its name.

      Parameters

      • name: string

      Returns Promise<void>