LegacyFileAdapter<K, V>
Class: LegacyFileAdapter<K, V>
Legacy file adapter for backward compatibility with existing .robo/data stores.
Key characteristics:
- Filenames are SHA256 hashes of keys (not reversible)
- Values are gzip-compressed JSON
- No scan capability (keys are not enumerable)
- Fixes the
has()truthiness bug from the original implementation
Use this adapter to preserve access to existing Flashcore data. For new projects, consider using a v1 adapter with deterministic key storage.
Type Parameters
| Type Parameter | Default type |
|---|---|
K | string |
V | unknown |
Implements
FlashcoreAdapter<K,V>
Constructors
new LegacyFileAdapter()
new LegacyFileAdapter<K, V>(options): LegacyFileAdapter<K, V>Parameters
| Parameter | Type |
|---|---|
options | LegacyFileAdapterOptions |
Returns
LegacyFileAdapter<K, V>
Properties
| Property | Modifier | Type | Default value | Description |
|---|---|---|---|---|
dataDir | readonly | string | undefined | - |
name | readonly | "LegacyFileAdapter" | 'LegacyFileAdapter' | Human-readable adapter name for logging and introspection. |
Methods
clear()
clear(): Promise<boolean>Clear all data.
Returns
Promise<boolean>
Implementation of
delete()
delete(key): Promise<boolean>Delete a key. Returns true if the key existed and was deleted.
Parameters
| Parameter | Type |
|---|---|
key | K |
Returns
Promise<boolean>
Implementation of
get()
get(key): Promise<V>Get a value by key. Returns undefined if the key does not exist.
Parameters
| Parameter | Type |
|---|---|
key | K |
Returns
Promise<V>
Implementation of
has()
has(key): Promise<boolean>Check if a key exists.
FIXED: Unlike the original implementation which used !!get(),
this properly checks file existence to handle falsy stored values.
Parameters
| Parameter | Type |
|---|---|
key | K |
Returns
Promise<boolean>
Implementation of
init()
init(): Promise<void>Initialize the adapter (e.g., connect, create directories). Called once during Flashcore.$.init().
Returns
Promise<void>
Implementation of
set()
set(key, value): Promise<boolean>Set a key-value pair. Returns true if the operation succeeded.
Parameters
| Parameter | Type |
|---|---|
key | K |
value | V |
Returns
Promise<boolean>
