The World Map in 500 Bytes: ASCII Art Powered by Deflate Compression
Translated by a model; the original is in Russian.
Developer Iwo Kadziela, with help from the Codex assistant, found a way to generate a recognizable ASCII map of the world, fitting the data into just 445 bytes.
The trick
The core idea is to use deflate compression to store the map data itself. The decompression happens right in the browser with a small snippet of JavaScript.
Simon Willison, who wrote about the project on his blog, noted that he hadn't previously known you could pass base64-encoded data: URI strings to fetch(). That very technique is what the solution rests on: the encoded data is passed to fetch(), the response stream is then piped through DecompressionStream('deflate-raw'), and the resulting text is inserted into the page markup as the contents of a <pre> tag.
This way, just a couple of lines of code cover storing the compressed map data, decompressing it, and rendering it on screen — with no third-party libraries and no server round-trip.
Where the find came from
As Willison explains, he learned about the project through Hacker News, where the post drew interest thanks to its unusual combination of built-in web-platform capabilities — data: URI, fetch() and DecompressionStream — to solve the problem of compactly storing graphical data.
Source: Simon Willison
Comments
Sign in, to comment.