Skip to content

AIDC Toolkit / Core / ReadOnlyAppDataStorage

Abstract Class: ReadOnlyAppDataStorage<SupportsBinary>

Defined in: app-data-storage.ts:7

Generic read-only application data storage.

Extended by

Type Parameters

SupportsBinary

SupportsBinary extends boolean

Properties

BINARY_EXTENSION

protected readonly static BINARY_EXTENSION: ".bin" = ".bin"

Defined in: app-data-storage.ts:11

Extension to identify binary data.


JSON_EXTENSION

protected readonly static JSON_EXTENSION: ".json" = ".json"

Defined in: app-data-storage.ts:16

Extension to identify JSON data.

Constructors

Constructor

protected new ReadOnlyAppDataStorage<SupportsBinary>(supportsBinary, path?): ReadOnlyAppDataStorage<SupportsBinary>

Defined in: app-data-storage.ts:37

Constructor.

Parameters

supportsBinary

SupportsBinary

True if binary data is supported.

path?

string

Storage path prepended to each key along with '/' if defined, empty string if not.

Returns

ReadOnlyAppDataStorage<SupportsBinary>

Accessors

supportsBinary

Get Signature

get supportsBinary(): SupportsBinary

Defined in: app-data-storage.ts:45

Determine if binary data is supported.

Returns

SupportsBinary


path

Get Signature

get path(): string

Defined in: app-data-storage.ts:52

Get the storage path, prepended to each key.

Returns

string

Methods

fullKey()

protected fullKey(pathKey, isBinary): string

Defined in: app-data-storage.ts:68

Build the full storage key.

Parameters

pathKey

string

Key relative to path.

isBinary

boolean

True if key is to binary data, false or undefined if to string data. Ignored if binary data is not supported.

Returns

string

Full storage key.


doRead()

abstract protected doRead(key, asBinary): Promisable<SupportsBinary extends true ? string | Uint8Array<ArrayBufferLike> : string | undefined>

Defined in: app-data-storage.ts:90

Read a string or binary data from persistent storage.

Parameters

key

string

Storage key (file path in Node.js, key in localStorage).

asBinary

True if binary data is requested, false or undefined if string data is requested. Ignored if binary data is not supported.

boolean | undefined

Returns

Promisable<SupportsBinary extends true ? string | Uint8Array<ArrayBufferLike> : string | undefined>

String or binary data or undefined if not found.


read()

read(pathKey, asBinary?): Promise<AppData | undefined>

Defined in: app-data-storage.ts:105

Read application data from storage.

Parameters

pathKey

string

Key relative to path.

asBinary?

boolean

True if binary data is requested, false or undefined if string data is requested. Ignored if binary data is not supported.

Returns

Promise<AppData | undefined>

Application data or undefined if not found.