Skip to content

.export

W. ❝Mac❞ McMeans edited this page Dec 25, 2023 · 3 revisions

localDataStorage.export( [mode] )

This method lets you create a JSON object representing the state of the store, which can be saved and subsequently imported. The overwrite mode is optional and, if specified, signals how existing data should be affected when the JSON is imported. When omitted, mode is set to unsafe by default, hinting that data in the export object should be treated as authoritative.

The export mode can have one of two possible values:
safe - imported data cannot overwrite existing keys but will create new keys as necessary (identical to using softset)
unsafe - imported data will overwrite any keys with matching names and will also make new keys as necessary (identical to using set)

The created JSON contains:
1 - a timestamp indicating when the export was created,
2 - a keycount,
3 - the key prefix, and
4 - an array of key value pairs

EXAMPLES:

Export all eight keys in the store under the storageBackup-1 variable and hint that existing keys should be preserved:
● storageBackup-1 = localData.export( 'safe' )
--> {ts: 1653884984216, mode: 'safe', keycount: 8, prefix: 'QUnit-test', keys: Array(8)}

Export all eight keys in the store under the storageBackup-1 variable and signal that existing keys should be overwritten by default:
● storageBackup-1 = localData.export()
--> {ts: 1653884984216, mode: 'unsafe', keycount: 8, prefix: 'QUnit-test', keys: Array(8)}

✨ The complement to this is import.

📝 NOTE: While the export mode is used to signal how data should be handled, it can always be overridden during an import. Only disk-based localStorage keys can be exported, not Memory Keys.

localStorage Keys

The usual suspects:

set / get      clear      key      remove

The esoteric ones:

Array Keys:
push / pull, pullall      poke      contains      where

Broadcasting:
broadcast

Bypass:
forceset / forceget

Data Transfer:
import / export

Duplicates:
countdupes, showdupes, listdupes

Internals:
cancrunch      crunch / uncrunch

shufflestring / unshufflestring

xorstring

Management:
keys

Memory Consumption:

Memory Quota:
showquota

Query:
haskey, hasval, hastype

Security:
safeset / safeget

setscramblekey / getscramblekey

Type Check:
isarray      isbigint      isboolean      iscrunch

isdate      isfloat      isinteger      isnull

isnumber      isobject      isstring

showtype

Utility:
chopget      copy      softset      rename

Properties:

channel      length      quota      version

Settings:

verbosity

Memory Keys

Standard:

_set / _get      _clear      _key      _remove

Unconventional:

Data Sync:
_backup / _restore

Management:
_keys

Security:
_safeset / _safeget

Type Check:
_isarray      _isbigint      _isboolean      _iscrunch

_isdate      _isfloat      _isinteger      _isnull

_isnumber      _isobject      _isstring

_showtype

Utility:
_chopget      _copy      _softset      _rename

Clone this wiki locally