[lz-string][] is a very popular library that compresses UTF-16 strings using a variation of the [LZ78][] algorithm where literals are only encoded once (and referred as dictionary indexes afterwards).
Despite its impressive 10 million downloads per week at the time of this writing, there is no official documentation on the wire format implemented by this library, and the horrible code quality makes it hard to understand from it. Furthermore, the code contains many bugs / gotchas, some of which are enumerated below. This is probably why many of the [numerous ports][ports] of the library blindly copy its code, doing little more