-
-
Notifications
You must be signed in to change notification settings - Fork 16
String Compression
The localDataStorage utility incorporates SMAZ (a simple string compression library written in C) created by Salvatore Sanfilippo (https://github.com/antirez/smaz) under a BSD license. The derivative work included in this project (a javascript port of C code), was written by personalcomputer (https://github.com/personalcomputer/smaz.js), under the same BSD license.
The compression logic is suitable for crunching very short strings, but does not work well for general purpose data. It can compress text by 40-50% on average, with English phrases providing superior results, and even strings of two or three bytes can be optimized for space.
The original SMAZ appears to calculate compression ratios based on string length. For example, the following graphemes will each maintain a length of 1 after compression, but each will also conflate from 1 byte to 2 bytes: z, x, < and >. In contrast, the version included here is modified to prioritize byte count regardless of length, which is much more appropriate for efficient storage.
📝 NOTE: Dates, floats and integers are always stored compressed. This not only saves storage but also offers a measure of data protection through obfuscation.
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