utilium
    Preparing search index...

    Class Resource<ID>Internal

    The cache for a specific resource

    Type Parameters

    • ID
    Index
    _size: number
    id: ID

    The resource ID

    options: Options
    regions: Region[] = []

    Regions used to reduce unneeded allocations. Think of sparse arrays.

    • get size(): number

      The full size of the resource

      Returns number

    • set size(value: number): void

      Parameters

      • value: number

      Returns void

    • Add new data to the cache at given specified offset

      Parameters

      • data: Uint8Array
      • offset: number

      Returns this

    • Get the cached sub-ranges of an initial range. This is conceptually the inverse of missing.

      Parameters

      • start: number
      • end: number

      Returns Range[]

    • Combines adjacent regions and combines adjacent ranges within a region

      Returns void

    • Combine the region at index with the neighbors it now reaches. Only that region can have changed, so this does not re-walk the whole list the way collect does.

      Parameters

      • index: number

      Returns void

    • Index of the first region positioned after offset. Regions are kept sorted, so this is a binary search.

      Parameters

      • offset: number

      Returns number

    • Merge the region after index into the one at index, if the gap between them is small enough

      Parameters

      • index: number

      Returns boolean

    • Takes an initial range and finds the sub-ranges that are not in the cache

      Parameters

      • start: number
      • end: number

      Returns Range[]

    • Get the region who's ranges include an offset

      Parameters

      • offset: number

      Returns Region | undefined

    • The regions overlapping [start, end), in order. Seeks to the first one rather than scanning from the start.

      Parameters

      • start: number
      • end: number

      Returns Generator<Region>

    • Resize region.data to length bytes. Capacity can be over-allocated geometrically so appending to a region repeatedly stays amortized O(1).

      Parameters

      • region: Region
      • length: number

      Returns void