-
-
Notifications
You must be signed in to change notification settings - Fork 16
Supported Data Types
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.
Array Keys:
push / pull, pullall poke contains where
Broadcasting:
broadcast
Data Transfer:
import / export
Duplicates:
countdupes, showdupes, listdupes
Internals:
cancrunch crunch / uncrunch
shufflestring / unshufflestring
Management:
keys
Memory Consumption:
Memory Quota:
showquota
Query:
haskey, hasval, hastype
setscramblekey / getscramblekey
Type Check:
isarray isbigint isboolean iscrunch
isdate isfloat isinteger isnull
Utility:
chopget copy softset rename
_set / _get _clear _key _remove
Management:
_keys
Type Check:
_isarray _isbigint _isboolean _iscrunch