Skip to content

Supported Data Types

W. "Mac" McMeans edited this page Aug 12, 2022 · 29 revisions

Unlike the HTML5 localStorage API that only handles strings, localDataStorage lets you seamlessly work with six of the eight existing JavasScript data types. This includes five of the primitive values (BigInt, Boolean, null, Number and String), as well as Objects.

Boolean type
A Boolean represents a logical entity and can have two values: true or false.

Null type
The null type has exactly one value: null. It is often confused for, but is not the same as, the undefined type. You might look at it like this: a variable set to null is absent any value (but it is set nevertheless), whereas a variable that is undefined is non-initialized. These are similar, sometimes overlapping notions, but they are not identical. For example, attempts to retrieve a non-existing key in the native localStorage API return null, which is slightly misleading (as if the key were present). In localDataStorage, calling a non-existing key always returns undefined because the key is not in the store and obviously cannot have a value.

Number type
Technically, there is only one number type: the double-precision 64-bit binary format IEEE 754 value (number between -(253 -1) and 253 -1). Be that as it may, localDataStorage lets you read/write/test the pseudo-types of Float and Integer (both of them Numbers) as if they were bonafide primitives. The distinction between the two is quite arbitrary. Integers contain no decimal points while floats do, even if they represent the same value, for example, 50 or 50.00.

BigInt type
This is a numeric data type that can represent integers in the arbitrary precision format.

String type
This type represents textual data.

Object type
Unlike primitives, Objects can be seen as a collection of properties. This includes Arrays and Dates. Along with primitives, the ability to use an Object to set a scramble key, or to set a key value, makes localDataStorage extremely robust.

Thus, a key's value can be any of the following nine "types": Array, BigInt, Boolean, Date, Float, Integer, null, Object or String.

Keeping track of a key's data type incurs a small cost in terms of storage overhead.

📝 NOTE: The Symbol and undefined types are not supported.

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