Home Reference Source

Function

Static Public Summary
public

Retrieve an IDBFileStorage instance by name (and it creates the indexedDB if it doesn't exist yet).

public

Wraps a DOMRequest into a promise, optionally transforming the result using the onsuccess callback.

Static Public

public async getFileStorage(param: Object): IDBFileStorage source

import {getFileStorage} from 'idb-file-storage/src/idb-file-storage.js'

Retrieve an IDBFileStorage instance by name (and it creates the indexedDB if it doesn't exist yet).

Params:

NameTypeAttributeDescription
param Object
  • optional
param.name string
  • optional
  • default: "default"

The name associated to the IDB File Storage.

param.persistent boolean
  • optional

Optionally enable persistent storage mode (not enabled by default).

Return:

IDBFileStorage

The IDBFileStorage instance with the given name.

public waitForDOMRequest(req: IDBRequest | DOMRequest, onsuccess: function): Promise source

import {waitForDOMRequest} from 'idb-file-storage/src/idb-file-storage.js'

Wraps a DOMRequest into a promise, optionally transforming the result using the onsuccess callback.

Params:

NameTypeAttributeDescription
req IDBRequest | DOMRequest

The DOMRequest instance to wrap in a Promise.

onsuccess function
  • optional

An optional onsuccess callback which can transform the result before resolving it.

Return:

Promise

The promise which wraps the request result, rejected if the request.onerror has been called.