Freeze-dries an HTML Document.

For most use cases, use the freezeDry function, a convenience wrapper around this class.

Use this class instead if you need more control; for example to access the incomplete result before freezeDry finishes, or to obtain it as a Document or Blob rather than a string.

Example

This is roughly what running freezeDry(document, options) does:

const freezeDryer = new FreezeDryer(document, options)
await freezeDryier.run()
const html = freezeDryer.result.string

Hierarchy

  • FreezeDryer

Implements

  • AbortController

Properties

Constructors

Methods

Accessors

Properties

original: Document

The Document that was passed to this FreezeDryer to be freeze-dried.

The clone of the original document. After completing run, this is the freeze-dried result. It can also be accessed before or while running, to already obtain a partial result if needed.

The configuration of this FreezeDryer (based on the passed options).

Constructors

  • Parameters

    • document: Document

      Document to be freeze-dried. Remains unmodified.

    • options: Partial<FreezeDryConfig> = {}

      Options to customise freezeDry’s behaviour.

    Returns FreezeDryer

Methods

  • Run the freeze-drying process.

    Starts the process of recursively crawling and drying subresources of result, then finalises the snapshot itself.

    Returns

    The FreezeDryer itself.

    Returns Promise<FreezeDryer>

  • Abort freeze-drying. Stops further crawling of subresources, but still finishes the snapshot using the currently available subresources.

    Parameters

    • Optional reason: any

    Returns Promise<void>

Accessors

  • get signal(): AbortSignal
  • Signals whether freeze-drying has been aborted.

    Aborting can happen in several ways:

    • This FreezeDryer’s abort method was called.
    • The timeout given in options has been reached.
    • The signal given in options was triggered.

    Returns AbortSignal