A fast and small port of Zstandard to WASM.

Zstandard WASM

A fast and small port of Zstandard to WASM. (Decompress-only for now).

Features

  • Fast: Zstandard has been compiled with the -03 flag, so all optimizations are enabled and it will go pretty fast. Potentially in the future Zstandard could be recompiled with SIMD instructions too.
  • Small: the whole library weighs ~28kb min+gizpped, with no third-party dependencies other than Zstandard itself, which is bundled-in.
  • Up-to-date: starting from v1.5.0 of Zstandard this library aims to remain up to date with it, if you need version X of Zstandard install version X of zstandard-wasm.
  • Decompress-only: for now only a way to decompress zstd archives is exposed, potentially in the future a way to make zstd archives could be exposed too.
  • TypeScript-ready: the library is written in TypeScript so the exposed interface is clear.
  • Easy to use: using this module is easy, there's no need for a special bundler plugin and it works both in the browser and in Node.js.

Install

npm install --save zstandard-wasm

Usage

import fs from 'fs';
import zstd from 'zstandard-wasm'; // Default entrypoint, optimized for speed, ~28kb min+gzip
// import zstd from 'zstandard-wasm/speed'; // Default entrypoint, optimized for speed, ~28kb min+gzip
// import zstd from 'zstandard-wasm/size'; // Alternative entrypoint, optimized for bundle size, ~22kb min+gzip

await zstd.loadWASM (); // First of all you need to load the WASM instance and wait for it

const compressed = fs.readFileSync ( 'something.zst' ); // You get a Buffer or Uint8Array to decompress
const decompressed = zstd.decompress ( compressed ); // You get a Uint8Array containing the decompressed data

Limitations

  • This library doesn't support streaming decompression (yet?), so in order for it to decompress an archive you have to make sure that either the archive itself contains some metadata about the size of the uncompressed archive or you pass the decompress function the appropriate size number manually. This isn't a problem in practice if you just make archives via a simple zstd -9 file.txt or something, but if you are doing something fancier than that you might want to check that this library is actually able to decompress your files before shipping them.

Licenses

Owner
Fabio Spampinato
Full-stack developer passionate about open source and empowering people.
Fabio Spampinato
Similar Resources

A small, fast, vectorizeable libm

jodiemath a small, fast, vectorizeable libm goals: all functions have absolute or relative error ~= 0.000010 or less, this isn't a fast math library,

Mar 29, 2022

A small, fast codeforces command line tool for competitive programming.

A small, fast codeforces command line tool for competitive programming.

chainsaw: A Codeforces Commandline Tool chainsaw is a small and faster drop-in replacement for your copy and paste while attending Codeforces contests

Dec 8, 2022

The Wren Programming Language. Wren is a small, fast, class-based concurrent scripting language.

Wren is a small, fast, class-based concurrent scripting language Think Smalltalk in a Lua-sized package with a dash of Erlang and wrapped up in a fami

Dec 30, 2022

Peregrine - A blazing fast language for the blazing fast world(WIP)

Peregrine - A blazing fast language for the blazing fast world(WIP)

A Blazing-Fast Language for the Blazing-Fast world. The Peregrine Programming Language Peregrine is a Compiled, Systems Programming Language, currentl

Jan 2, 2023

Hobbyist Operating System targeting x86_64 systems. Includes userspace, Virtual File System, An InitFS (tarfs), Lua port, easy porting, a decent LibC and LibM, and a shell that supports: piping, file redirection, and more.

Hobbyist Operating System targeting x86_64 systems. Includes userspace, Virtual File System, An InitFS (tarfs), Lua port, easy porting, a decent LibC and LibM, and a shell that supports: piping, file redirection, and more.

SynnixOS Epic Hobby OS targeting x86_64 CPUs, it includes some hacked together functionality for most essential OSs although, with interactivity via Q

Oct 28, 2022

This is the Arduino® compatible port of the AIfES machine learning framework, developed and maintained by Fraunhofer Institute for Microelectronic Circuits and Systems.

AIfES for Arduino® AIfES (Artificial Intelligence for Embedded Systems) is a platform-independent and standalone AI software framework optimized for e

Jan 4, 2023

Apple cctools and ld64 port for Linux, *BSD and macOS

Apple cctools and ld64 port for Linux, *BSD and macOS

Dec 30, 2022

Project is to port original Zmodem for Unix to CP/M and provide binaries and source code for platform specific modification as needed. Based on 1986 C source code by Chuck Forsberg

Zmodem-CP-M This repository is intended to foster a RetroBrewComputers community effort to port the original Zmodem source code for Unix to CP/M so ev

Aug 31, 2022

Project is to port original Zmodem for Unix to CP/M and provide binaries and source code for platform specific modification as needed. Based on 1986 C source code by Chuck Forsberg

Zmodem4CPM This repository is intended to foster a RetroBrewComputers community effort to port the original Zmodem source code for Unix to CP/M so eve

Aug 31, 2022
JS/WASM build of libjxl (JPEG-XL)

libjxl-js JS/WASM build of libjxl (JPEG-XL) Try It Out! Try it in your browser here Building This project uses git submodules to pull in libjxl. If de

Nov 28, 2022
Twitter thread explorer made in C++/Wasm/WebGL
Twitter thread explorer made in C++/Wasm/WebGL

Visa Viz Twitter thread explorer made in C++/Wasm/WebGL Once upon a time, I stumbled upon @visakanv's network of threads, but it was too cumbersome to

Oct 24, 2022
A single header C++ wasm frontend library leveraging Emscripten
A single header C++ wasm frontend library leveraging Emscripten

Livid Livid is a single header C++ wasm frontend library leveraging Emscripten. Usage The code looks something like this: #include "livid/livid.hpp" #

Nov 26, 2022
C++11 header-only library that offers small vector, small flat map/set/multimap/multiset.

sfl library This is header-only C++11 library that offers several new containers: small_vector small_flat_set small_flat_map small_flat_multiset small

Dec 14, 2022
dwm is an extremely fast, small, and dynamic window manager for X.

dwm - dynamic window manager dwm is an extremely fast, small, and dynamic window manager for X. My Patches This is in the order that I patched everyth

Dec 23, 2022
⛵ The missing small and fast image decoding library for humans (not for machines).
⛵ The missing small and fast image decoding library for humans (not for machines).

Squirrel Abstract Image Library The missing fast and easy-to-use image decoding library for humans (not for machines). Target Audience • Features • Im

Dec 19, 2022
A small and fast programming language.
A small and fast programming language.

Pocketlang is a small (~3000 semicolons) and fast functional language written in C. It's syntactically similar to Ruby and it can be learned within 15

Dec 28, 2022
ArkScript is a small, fast, functional and scripting language for C++ projects
ArkScript is a small, fast, functional and scripting language for C++ projects

ArkScript Documentation Discord server: invite link, to discuss the specification of the language and receive help Modules Nota bene: the project is r

Jan 1, 2023
A family of small, fast, and simple bitmap fonts in single-file C headers
A family of small, fast, and simple bitmap fonts in single-file C headers

Blit A family of small, fast, and simple bitmap fonts in single-file C headers [go to repository] These are not intended as a replacement for fancy us

Dec 22, 2022
TinyGL: a Small, Free and Fast Subset of OpenGL
TinyGL: a Small, Free and Fast Subset of OpenGL

TinyGL A major overhaul of Fabrice Bellard's TinyGL to be more useful as a software rasterizer. Now with limited multithreading support Tightly tweake

Dec 30, 2022