Skip to content
W. "Mac" McMeans edited this page Aug 13, 2022 · 80 revisions

As an interface for the HTML5 localStorage API, localDataStorage
1) lets you set and get keys that respect native data types without having to perform your own conversion;
2) provides simple data scrambling;
3) intelligently compresses string data;
4) permits query by key (name) as well as query by (key) value;
5) facilitates shared storage segmentation in the same domain;
6) broadcasts change events across the origin for the benefit of other windows/tabs; and
7) offers Memory Keys for the fastest read times possible.

Array Keys are a dedicated key type making it easy to work with array data in localStorage.

Because JavaScript is running in a single thread in the browser, there are no race conditions or concerns with atomicity using localDataStorage. Further, all methods are synchronous. (Obviously, this is not referring to node.js, where single-threaded JavaScript is running on a server; or web workers, where multiple processes are running in a single thread.)

Both the keyname and its value are case-sensitive. With 80+ total methods and properties, the localDataStorage wrapper can be considered a superset of web storage, and when things change, it conveniently fires its own events.

Data created under this software is generally incompatible with the HTML5 localStorage API. Keys can still be read (using getItem), but since localDataStorage handles so much more than just strings, the returned values won't make much sense using the native API.

As with localStorage, key names in localDataStorage are unique, key values are not. Duplicate values are easily discovered.

The process of storing and retrieving data to and from localStorage isn't actually slow, but it cannot compare to memory. When your use-case demands the fastest read times, you can employ Memory Keys for the best performance.

If you'd like to know what goes on under the hood, see the details on memory usage.

When you're ready to include this in your next project, it's easy to get started.

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