Skip to content

Getting Started

W. "Mac" McMeans edited this page Apr 27, 2022 · 44 revisions

The code is contained in one JavaScript file, designed against Christian Heilmann’s Revealing Module pattern. It returns an Immediately Invoked Function Expression (IIFE) to create a local scope for all methods and variables in order to avoid polluting the global scope.

To use localDataStorage--

  1. bring the code into your page (via <script> tags, direct copy, etc.)
  2. instantiate it with a meaningful prefix (which provides namespacing)

The generic call would look something like localDataStorage( prefix, switch ).

For example:

<script
    src="https://cdn.jsdelivr.net/gh/macmcmeans/localDataStorage@1.3.1/localDataStorage-1.3.1.min.js"
    integrity="sha384-Rc8gyCOHcneAsNwEsjnQQLQ6JSS0ZBgZxwr2Qh7z4Knfd5O5GLnD5sm6WSCYKv+2"
    crossorigin="anonymous"
></script>

<script>
    const lds = localDataStorage( 'passphrase.life' );
</script>

At this point all key names will have the prefix passphrase.life. prepended to them (note the trailing period), so calling set( 'authorName', 'Mac' ) will store the authorName key as passphrase.life.authorName internally with a value of Mac.

To control how localDataStorage starts up, you may use a few switches. You should specify a prefix to prevent storage contamination.

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