Class: WebStorage

DKTools.IO.WebStorage

Web storage class

new DKTools.IO.WebStorage ()

Methods

DKTools.IO.WebStorage.exists (key)Boolean static

Returns true if the key exists
Name Type Description
key String Key
Returns:
Type Description
Boolean Key exists

DKTools.IO.WebStorage.load (key, object)Object static

Loads a data Returns an object with 3 properties: status - Result of an operation data - Loaded data error - Error if the status is not equal to DKTools.IO.OK then data will be null Possible statuses: DKTools.IO.OK DKTools.IO.ERROR_PATH_DOES_NOT_EXIST DKTools.IO.ERROR_DECOMPRESSING_DATA DKTools.IO.ERROR_PARSING_DATA
Name Type Default Description
key String Key
object Object {} optional Options of an operation
Name Type Description
decompress Boolean optional Use LZString.decompressFromBase64 for a data
parse Boolean | Object optional Use JSON.parse for a data
Name Type Description
reviver function optional A function that transforms the results
Returns:
Type Description
Object Loaded data

DKTools.IO.WebStorage.remove (key)Number static

Removes a data Returns a code of the result of an operation Possible results: DKTools.IO.OK DKTools.IO.ERROR_PATH_DOES_NOT_EXIST
Name Type Description
key String Key
Returns:
Type Description
Number Code of the result of an operation

DKTools.IO.WebStorage.rename (oldKey, newKey, overwrite)Number static

Renames a data Returns a code of the result of an operation Possible results: DKTools.IO.OK DKTools.IO.ERROR_PATH_DOES_NOT_EXIST DKTools.IO.ERROR_OVERWRITING_IS_NOT_AVAILABLE
Name Type Default Description
oldKey String Old key
newKey String New key
overwrite Boolean false optional Overwrite the data
Returns:
Type Description
Number Code of the result of an operation

DKTools.IO.WebStorage.save (key, data, object)Number static

Saves the data Returns a code of the result of an operation Possible results: DKTools.IO.OK DKTools.IO.ERROR_OVERWRITING_IS_NOT_AVAILABLE
Name Type Default Description
key String Key
data * Data to save
object Object {} optional Options of an operation
Name Type Default Description
overwrite Boolean true optional Overwrite the data
stringify Boolean optional Use JSON.stringify for the data
compress Boolean optional Use LZString.compressToBase64 for the data
Returns:
Type Description
Number Code of the result of an operation