Skip to content

Prefixes

W. "Mac" McMeans edited this page May 29, 2022 · 13 revisions

When on the same domain, prefixes help keep your storage keys from being overwritten by someone else's use of localStorage. Prefixes provide namespacing and let you instantiate more than one copy of localDataStorage using the same keys with each instance, if required.

Prefixes are strongly encouraged but are not mandatory and must be specified when localDataStorage starts up. A period (.) is used to separate the keyname from the prefix, but it may contain periods itself. As with all key names and key values, prefixes are multibyte Unicode‑safe.

EXAMPLES:

Start the software specifying a typical prefix
z = localDataStorage( 'mac' ); -->
localDataStorage instantiated. Your specified prefix (mac.) adds 4 bytes to every key name (stored using 8 bytes).

Start the software specifying an unconventional prefix
z = localDataStorage( '𝘁𝔥𝓲𝗌.𝓹ⓡ𝒆⒡ⓘ𝖝.𝓾𝘴𝖊𝑠.𝗹o𝖙𝐬.𝑜𝖋.𝕞ⓔ𝓂𝔬𝕣𝘆' ); -->
localDataStorage instantiated. Your specified prefix (𝘁𝔥𝓲𝗌.𝓹ⓡ𝒆⒡ⓘ𝖝.𝓾𝘴𝖊𝑠.𝗹o𝖙𝐬.𝑜𝖋.𝕞ⓔ𝓂𝔬𝕣𝘆.) adds 103 bytes to every key name (stored using 206 bytes).

Start the software forcing no prefix
z = localDataStorage( '' ); -->
Empty prefix given (), but a usable prefix is strongly recommended to organize keys!
localDataStorage instantiated. Your specified prefix () adds 0 bytes to every key name (stored using 0 bytes).

Start the software getting a random prefix
z = localDataStorage(); -->
No prefix specified. Creating a random prefix --> 1588540882487:252103633.
localDataStorage instantiated. The random prefix (1588540882487:252103633.) adds 24 bytes to every key name (stored using 48 bytes).

When starting localDataStorage, you may also use a few switches.

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