Interface SizeReporter<T>

A SizeReporter's only purpose (at the moment) is to calculate the size of a resource. How the size is calculated or what unit it is in is defined by the class implementing this interface. One might use the amount of bytes and another might use the amount of triples stored in a resource.

interface SizeReporter<T> {
    calculateChunkSize: ((chunk: T) => Promise<number>);
    estimateSize: ((metadata: RepresentationMetadata) => Promise<undefined | number>);
    getSize: ((identifier: ResourceIdentifier) => Promise<Size>);
    getUnit: (() => string);
}

Type Parameters

  • T

Implemented by

Properties

calculateChunkSize: ((chunk: T) => Promise<number>)

Calculate the size of a chunk based on which SizeReporter is being used

Type declaration

    • (chunk): Promise<number>
    • Parameters

      • chunk: T

        the chunk of which you want the size

      Returns Promise<number>

      the size of the passed chunk as a number

estimateSize: ((metadata: RepresentationMetadata) => Promise<undefined | number>)

Estimate the size of a body / request by looking at its metadata

Type declaration

    • (metadata): Promise<undefined | number>
    • Parameters

      Returns Promise<undefined | number>

      the estimated size of the body / request or undefined if no meaningful estimation can be made

getSize: ((identifier: ResourceIdentifier) => Promise<Size>)

Get the size of a given resource

Type declaration

    • (identifier): Promise<Size>
    • Parameters

      Returns Promise<Size>

      The size of the resource as a Size object calculated recursively if the identifier leads to a container

getUnit: (() => string)

Get the unit as a string in which a SizeReporter returns data