Class VirtualDriveStorage
Source: virtualDriveStorage.ts
A wrapper for localStorage with additional functionality like compression and a size limit.
Extends
Constructors
Constructor
new VirtualDriveStorage(
virtualDriveConfig:VirtualDriveConfig):VirtualDriveStorage
Parameters
virtualDriveConfig
Returns
VirtualDriveStorage
Overrides
Properties
enableCompression
enableCompression:
boolean=false
Enables compression of values stored in this storage.
Default
falseInherited from
prefix
prefix:
string|undefined
The prefix to prepend to keys.
Default
undefinedInherited from
MAX_BYTES
readonlystaticMAX_BYTES:5000000=5_000_000
The maximum amount of bytes of a value in this storage.
Inherited from
COMPRESSED_PREFIX
readonlystaticCOMPRESSED_PREFIX:""="\uE000"
Inherited from
UNCOMPRESSED_PREFIX
readonlystaticUNCOMPRESSED_PREFIX:""="\uE001"
Inherited from
virtualDriveConfig
virtualDriveConfig:
VirtualDriveConfig
KEY
readonlystaticKEY:"drive"="drive"
Methods
rename()
rename(
oldKey:string,newKey:string):this
Replaces the key of an item if it exists.
Parameters
oldKey
string
The key to replace.
newKey
string
The new key.
Returns
this
Inherited from
remove()
remove(
key:string):this
Removes the item with the given key from this storage.
Parameters
key
string
The key of the item.
Returns
this
Inherited from
clear()
clear():
this
Clears all items stored in this storage.
Returns
this
Inherited from
getItemByteSize()
getItemByteSize(
key:string,value:string):number
Returns the byte size of a key and value pair.
Parameters
key
string
The key of the item.
value
string
The value of the item.
Returns
number
Inherited from
getEncodedByteSize()
getEncodedByteSize(
string:string|null):number
Parameters
string
string | null
Returns
number
Inherited from
encode()
encode(
string:string): {result:string;size:number; }
Parameters
string
string
Returns
{ result: string; size: number; }
result
result:
string
size
size:
number
Inherited from
decode()
decode(
string:string):string
Parameters
string
string
Returns
string
Inherited from
setPrefix()
setPrefix(
prefix?:string):this
Parameters
prefix?
string
Returns
this
Inherited from
getByteSize()
staticgetByteSize(string:string|null):number
Parameters
string
string | null
Returns
number
Inherited from
byteToKilobyte()
staticbyteToKilobyte(bytes:number):number
Parameters
bytes
number
Returns
number
Inherited from
load()
load(
key:string):string|null
Loads a value associated with the given key.
Parameters
key
string
The key of the item.
Returns
string | null
The value of the item.
Overrides
store()
store(
key:string,value:string):void
Stores a key and value pair in this storage.
Parameters
key
string
The key to store.
value
string
The value to store.
Returns
void
Overrides
synchronize()
synchronize():
void
Returns
void