Skip to content

AIDC Toolkit / Core / AppDataStorage

Abstract Class: AppDataStorage<SupportsBinary>

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

Generic read/write application data storage.

Extends

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.

Inherited from

ReadOnlyAppDataStorage.BINARY_EXTENSION


JSON_EXTENSION

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

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

Extension to identify JSON data.

Inherited from

ReadOnlyAppDataStorage.JSON_EXTENSION

Constructors

Constructor

protected new AppDataStorage<SupportsBinary>(supportsBinary, path?): AppDataStorage<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

AppDataStorage<SupportsBinary>

Inherited from

ReadOnlyAppDataStorage.constructor

Accessors

supportsBinary

Get Signature

get supportsBinary(): SupportsBinary

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

Determine if binary data is supported.

Returns

SupportsBinary

Inherited from

ReadOnlyAppDataStorage.supportsBinary


path

Get Signature

get path(): string

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

Get the storage path, prepended to each key.

Returns

string

Inherited from

ReadOnlyAppDataStorage.path

Methods

doWrite()

abstract protected doWrite(key, data): Promisable<void>

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

Write a string or binary data in persistent storage.

Parameters

key

string

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

data

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

String or binary data.

Returns

Promisable<void>


write()

write(pathKey, appData): Promise<void>

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

Write application data to storage.

Parameters

pathKey

string

Key relative to path.

appData

AppData

Application data to write.

Returns

Promise<void>


doDelete()

abstract protected doDelete(key): Promisable<void>

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

Delete from persistent storage.

Parameters

key

string

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

Returns

Promisable<void>


delete()

delete(pathKey, asBinary?): Promise<void>

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

Delete application data from persistent storage.

Parameters

pathKey

string

Key relative to path.

asBinary?

boolean

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

Returns

Promise<void>


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.

Inherited from

ReadOnlyAppDataStorage.fullKey


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.

Inherited from

ReadOnlyAppDataStorage.doRead


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.

Inherited from

ReadOnlyAppDataStorage.read