Skip to content

.import

W. "Mac" McMeans edited this page Jul 3, 2022 · 3 revisions

localDataStorage.import( [mode] )

This method reads an exported JSON object. The overwrite mode is optional and, if specified, determines how existing data in the store will be affected by the import. When omitted, mode is defined by the value present in the export object.

The import 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 import is only effective when the key prefix defined in the JSON object matches the prefix of the store in-use. You cannot import keys from a different namespaced store.

When importing data, existing keys may be overwritten. If this happens, a key's prior value cannot be retrieved.

EXAMPLES:

Import an eight-key JSON assigned as storageBackup-1 ensuring existing keys are preserved:
● localData.import( 'storageBackup-1', 'safe' )
--> Importing upto 8 keys from Sun May 29 2022 23:56:37 GMT-0400 (Eastern Daylight Time)...
--> One key imported

Import an eight-key JSON assigned as storageBackup-1 ensuring the export values are authoritative:
● localData.import( 'storageBackup-1', 'unsafe' )
--> Overwriting 8 keys from Sun May 29 2022 23:56:37 GMT-0400 (Eastern Daylight Time)...
--> 8 keys imported

🌐 This method may fire events allowing you to monitor key changes.

✨ The complement to this is export.

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