Options
All
  • Public
  • Public/Protected
  • All
Menu

Represents a remote data file on the browser platform.

Hierarchy

Index

Constructors

constructor

Events

Static LOADING_COMPLETE

LOADING_COMPLETE: symbol = ...

Fired when the data loading finishes.

Static LOADING_PROGRESS

LOADING_PROGRESS: symbol = ...

Fired when data loading progresses. Not fired when data loading finishes.

Static LOADING_START

LOADING_START: symbol = ...

Fired when data loading progresses. Not fired when data loading finishes.

Properties

Private _byteLength

_byteLength: number = null

Variable to hold the byte length of the loaded file.

Private _bytesLoaded

_bytesLoaded: number = 0

Variable to hold the bytes loaded so far from the remote file.

Private _isLoadingComplete

_isLoadingComplete: boolean = false

Variable that holds a boolean describing if the loading is complete or not.

Private _onLoadingComplete

_onLoadingComplete: { promise: Promise<number>; reject: (e: Error) => void; resolve: (n: number) => void; started: boolean } = null

Variable that holds a promise that resolves when the file finishes loading

Type declaration

  • promise: Promise<number>
  • reject: (e: Error) => void
      • (e: Error): void
      • Parameters

        • e: Error

        Returns void

  • resolve: (n: number) => void
      • (n: number): void
      • Parameters

        • n: number

        Returns void

  • started: boolean

Private buffer

buffer: ArrayBuffer = null

An ArrayBuffer instance that holds the data loaded for this file, do not keep a local copy of this variable as it could be replaced as the file loads into memory.

Private listeners

listeners: Map<string | symbol, Set<EventCallback>>

Map of registered event listeners with this instance.

Readonly omniEvent

omniEvent: symbol

Returns a symbol that can be used to register an omni-listener.

Private source

source: LocalFileSourceDeno

The source from which the file should be loaded.

Accessors

byteLength

  • get byteLength(): Promise<number>

bytesLoaded

  • get bytesLoaded(): number

isLoadingComplete

  • get isLoadingComplete(): boolean

onLoadingComplete

  • get onLoadingComplete(): Promise<number>

Methods

emit

  • emit(type: string | symbol, ...args: any[]): void
  • Emit an event to all event listeners register for that specific event and omni-listeners (listeners registered wising * as the event type).

    Parameters

    • type: string | symbol

      The event to emit, cannot be *

    • Rest ...args: any[]

      Parameters to pass to the callback functions registered for this event

    Returns void

loadData

  • loadData(start?: number, end?: number): Promise<ArrayBuffer>
  • Loads the file into an ArrayBuffer. Optionally a start and end can be specified to load a part of the file.

    Parameters

    • start: number = 0

      The offset at which the data will start loading

    • end: number = ...

      The offset at which the data will stop loading

    Returns Promise<ArrayBuffer>

off

  • off(type: string | symbol, callback: EventCallback): void
  • Unregister an event listener callback.

    Parameters

    • type: string | symbol

      The event to unregister from

    • callback: EventCallback

      Callback function to remove

    Returns void

on

  • on(type: string | symbol, callback: EventCallback): void
  • Register an event listener callback for the specified event.

    NOTE: Pass * as the event type to listen to all event emitted by this instance.

    Parameters

    • type: string | symbol

      The event to listen for

    • callback: EventCallback

      Called when the event is emitted by this instance

    Returns void

Private readFileStream

  • readFileStream(response: Response): Promise<void>
  • Reads the data from a remote response using streams, this allows for data to be processed even if the file has not been completely loaded.

    Parameters

    • response: Response

      A response object returned by fetch. This object will be used to retrieve the read stream.

    Returns Promise<void>

slice

  • slice(start: number, end: number): DataChunk

startDownloading

  • startDownloading(): Promise<void>

Static fromSource

Static mixin

  • mixin<T>(Parent: T): { omniEvent: symbol } & T
  • Mixin method that holds the EventEmitter implementation, this function is exposed through EventEmitter.mixin.

    Type parameters

    • T

    Parameters

    • Parent: T

      The parent class into which the EventEmitter implementation will be mixed in.

    Returns { omniEvent: symbol } & T

Generated using TypeDoc