Code Monkey home page Code Monkey logo

wasm-flate-examples's Introduction

๐Ÿ—œ๏ธโšก wasm-flate examples

Python 3.7 http://img.shields.io/node/latest-version.svg

This repo contains examples for interacting with wasm-flate and with and Node servers (Python & Golang coming soon).

wasm-flate
npm package

The follow examples show how to consume compressed data from the browser and decrypt on the server side, or how to compress data server side an decompress in the browser.

Browser โ†’ Server usecases

  • Users uploading files
  • Moving large data from the user to the server
    Covered in Node and Python, working on Go and Rust examples.

Server โ†’ Browser usecases

  • Sending large files for UX (3D files, large config files, downloads)
  • Sending data to people with unstable internet - much smaller packets on network
    Working on Node, Python, Go and Rust examples.

Clone the Examples

git clone https://github.com/drbh/wasm-flate-examples.git
cd wasm-flate-examples

All of the following examples use the DEFLATE algo, but wasm-flate supports gzip and zlib too, just change the compression functions accordingly.

Start UI

All of the UI files are staic and only need to be hosted on a simple webserver. We'll fetch and install the http-server so we can easily start a server in the UI directory.

npm install http-server -g
cd dist
http-server

Now we can access the UI files at localhost:8080/send.html

Browser โ†’ Server (Client-Side)

File Upload and Compress UI

This example page allows us to upload a file from our file system. Compress it with wasm-flate and send it to a local server (in python or node)

http://localhost:8080/send.html

Browser โ†’ Server (Server-Side)

compress and send to server

Node

cd nodejs
npm install
node index.js 

After you send a file you can see the file compressed and decompressed sizes, as well as the server decompression run time.

Recieved data: 1.3 MB
Decompressed data: 5.1 MB
Execution time (hr): 0s 64.069506ms

Python

cd python
pip install flask
python uncompress-requests.py

After you send a file you can see the file compressed and decompressed sizes, as well as the server decompression run time.

Recieved data: 1MB
Decompressed data: 4MB
Execution time (hr): 0:00:00.018002
127.0.0.1 - - [08/May/2019 23:53:24] "POST / HTTP/1.1" 200 -

Browser โ†’ Browser (Only Client-Side)

compress and decompress in browser

This example allows us to compress and download files, or decompress and download files.

wasm-flate-examples's People

Contributors

drbh avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.