A faster experimental wasm-based tar implementation for browsers.

Overview

@bytedance/tar-wasm

A faster* experimental wasm-based tar implementation for browsers.

*50-160x faster, see benchmarks below.

Usage

Install

npm install @bytedance/tar-wasm

Example

import { TarBuilder } from "@bytedance/tar-wasm";

// Create a new tar builder
const tarBuilder = new TarBuilder();

// Optionally enable gzip compression
// tarBuilder.set_gzip(true);
// However, I recommend using the Compression Streams API instead when possible:
// https://developer.mozilla.org/en-US/docs/Web/API/Compression_Streams_API

for (const file of files) {
  // Add files to the tar
  tarBuilder.add_file(file.name, file.content);
}

// Finish building the tar and get the result
const tar: UInt8Array = tarBuilder.finish();

// Optionally convert the tar to a Blob or whatever
const tarBlob = new Blob([tar], { type: "application/x-tar" });

Performance Notes

This library is optimized for performance via WebAssembly. However, WebAssembly runs in the main thread by default and can be computationally expensive by nature depending on the size of the tar.

We recommend using Web Worker or Worker Threads to run the tar building in a separate thread. You may want to refer to Greenlet for a lightweight implementation.

Benchmarks

According to my benchmark, it can be 50-160x faster than existing JavaScript implementations on NPM, depending on the browser and the file size.

Results on my machine (Intel(R) Xeon(R) Platinum 8269CY CPU @ 2.50GHz):

Running benchmark...
Generated 1001 random files to test in 191.13816452026367ms
@bytedance/tar-wasm: 24.62919044494629ms (baseline)
tar-js: 3943.49857711792ms (160.11482740095886x slower than @bytedance/tar-wasm)
tarts: 1251.595199584961ms (50.817553357373065x slower than @bytedance/tar-wasm)

See ./benchmark folder for more details.

TODO

  • Include a Promise API working from a separate worker thread.
  • Add support for reading and writing tar files.
  • Support of Node.js environment
  • Tests
  • Benchmarks
You might also like...
gc-sections for wasm

wasm-gc Note: you probably don't need to use this project. This project is no longer necessary to run by hand, nor do you need the wasm-gc executable

List the symbols within a wasm file

wasm-nm List the symbols within a wasm file. Library Executable License Contributing Executable To install the wasm-nm executable, run $ cargo install

Instrument and transform wasm modules.

wasm-instrument A Rust library containing a collection of wasm module instrumentations and transformations mainly useful for wasm based block chains a

Just a little game I made in a day to try out the WASM-4 fantasy console.

Dodgeball This is just a little game I made in a day to try out the WASM-4 fantasy console. Play it here. The palette is SODA-CAP by Cappuchi. License

WebAssembly (Wasm) interpreter.

Continuous Integration Test Coverage Documentation Crates.io wasmi- WebAssembly (Wasm) Interpreter wasmi was conceived as a component of parity-ethere

📝 A template for creating WASM + Typescript + Rust workflow libraries.
📝 A template for creating WASM + Typescript + Rust workflow libraries.

Create Rust + TypeScript libraries with ease! PR'S WELCOMED! ✨ Inspiration I wanted to create a WebAssembly/Rust library with additional JS features,

Parametric surfaces drawn using the Rust + WASM toolchain with WebGL, React, and TypeScript.

Parametric Surfaces in the Browser My.Movie.3.mp4 Wanted to experiment with WebGL using the Rust + WASM toolchain, with React and TypeScript to glue e

A self-guided learning project that includes Rust + Wasm together
A self-guided learning project that includes Rust + Wasm together

A self-guided learning project that includes Rust + Wasm together. Who knows, maybe Typescript and React joins too..

WASM-compiled built-in actors used by all Filecoin clients

Built-in Filecoin actors (v8) This repo contains the code for the on-chain built-in actors that power the Filecoin network starting from network versi

Comments
  • Support Node.js

    Support Node.js

    Now the published package is built with --target bundler, but doesn't work with Node.js. The Node.js benchmark works with a separately built package --target nodejs, but it is not published. Need to find a way to support both targets at the same time if possible.

    enhancement 
    opened by eligao 0
Releases(v0.1.7)
  • v0.1.7(Oct 27, 2022)

    What's Changed

    • Correct a typo in benchmark/README.md by @felixonmars in https://github.com/bytedance/tar-wasm/pull/4
    • feat: isomorphic package for both node.js and web bundler by @eligao in https://github.com/bytedance/tar-wasm/pull/5
      • Added an example next.js benchmark

    New Contributors

    • @felixonmars made their first contribution in https://github.com/bytedance/tar-wasm/pull/4
    • @eligao made their first contribution in https://github.com/bytedance/tar-wasm/pull/5

    Full Changelog: https://github.com/bytedance/tar-wasm/compare/v0.1.6...v0.1.7

    Source code(tar.gz)
    Source code(zip)
Owner
Bytedance Inc.
Bytedance Inc.
Lunatic based webserver embedding WASM. Supports scaling down to zero and up to infinity.

Frenezulo A WASM-embedding webserver build on top of submillisecond and lunatic. Build to serve as an entry point for microservices compiled to WASM.

Kai Jellinghaus 13 Oct 23, 2022
An serverless framework based on wasm runtime.

wasm_serverless An distributed serverless framework based on wasm runtime. Feishu doc https://fvd360f8oos.feishu.cn/docx/XSxcdONk2oVJD5xtZuicxftqn3f?f

null 3 Nov 23, 2023
Rust based WASM/JS bindings for ur-rust

ur-wasm-js WASM/JS bindings for the ur-rust rust library Getting started Installation Either build the library yourself with wasm-pack or install for

Lightning Digital Entertainment 5 Feb 28, 2024
Rust implementation of the Mina protocol, targeting Wasm and ARM architectures.

Mina-rs An implementation of Mina protocol in Rust, with focus on web and Wasm compatibility ** As you can probably tell this is a WIP! Don't use for

ChainSafe 157 Dec 12, 2022
Very experimental Python bindings for the Rust biscuit-auth library

Overview This is a very experimental take on Python bindings for the biscuit_auth Rust library. It is very much a work in progress (limited testing, m

Josh Wright 5 Sep 14, 2022
📦✨ your favorite rust -> wasm workflow tool!

?? ✨ wasm-pack Your favorite Rust → Wasm workflow tool! Docs | Contributing | Chat Built with ?? ?? by The Rust and WebAssembly Working Group About Th

Rust and WebAssembly 4.8k Jan 5, 2023
Facilitating high-level interactions between Wasm modules and JavaScript

wasm-bindgen Facilitating high-level interactions between Wasm modules and JavaScript. Guide | API Docs | Contributing | Chat Built with ?? ?? by The

Rust and WebAssembly 5.9k Jan 8, 2023
Gun port in rust & wasm

gun-rs-wasm Rust & WASM port of Gun. For a non-wasm version, check out gun-rs Example (source) Use npm install rusty-gun import { Node as Gun } from "

Martti Malmi 39 Dec 19, 2022
Install `wasm-pack` by downloading the executable

wasm-pack-action Install wasm-pack by downloading the executable (much faster than cargo install wasm-pack, seconds vs minutes). Usage - uses: jetli/w

Jet Li 33 Nov 23, 2022
`wasm-snip` replaces a WebAssembly function's body with an `unreachable`

wasm-snip wasm-snip replaces a Wasm function's body with an unreachable instruction. API Docs | Contributing | Chat Built with ?? ?? by The Rust and W

Rust and WebAssembly 177 Dec 28, 2022