Skip to content
Build zip files out of whatwg streams in the browser
JavaScript HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
benchmark
example
.airtap.yml
.editorconfig
.eslintrc.js
.gitignore
.markdownlint.json
.travis.yml
LICENSE
README.md
crc.js
index.js
package-lock.json
package.json
read.js
test.js
write.js

README.md

Conflux by Transcend

Conflux

Build and read zip files with whatwg streams in the browser.

/ˈkänˌfləks/ (noun) a flowing together of two or more streams



Build Status Known Vulnerabilities Code Coverage Netlify Status

Sauce Test Status


Examples

Usage

Importing Conflux

npm install --save @transcend-io/conflux
import Zip from '@transcend-io/conflux/write';

const { readable, writable } = new Zip();

Writing a ZIP

import Zip from '@transcend-io/conflux/write';
import streamSaver from 'streamsaver'

// Set up conflux
const { readable, writable } = new Zip();
const writer = writable.getWriter();

// Set up streamsaver
const fileStream = streamSaver.createWriteStream('conflux.zip');

// Add a file
writer.write({
  name: '/cat.txt',
  lastModified: new Date(0),
  stream: () => new Response('mjau').body
});

readable.pipeTo(fileStream);

writer.close();

Incorporating other streams

(async () => {
  writer.write({
    name: '/cat.txt',
    lastModified: new Date(0),
    stream: () => new Response('mjau').body,
  });

  const imgStream = await fetch('https://s3-us-west-2.amazonaws.com/bencmbrook/Earth.jpg')
    .then(r => r.body);

  writer.write({
    name: '/Earth.jpg',
    lastModified: new Date(0),
    stream: () => imgStream,
  });

  readable.pipeTo(fileStream)

  writer.close();
})();

Reading ZIP files

import reader from '@transcend-io/conflux/read';

fetch("https://cdn.jsdelivr.net/gh/Stuk/jszip/test/ref/deflate.zip")
  .then(async res => {
    const zip = await res.blob();
    for await (const entry of reader(zip)) {
      console.log(entry);
    }
  });

Big Thanks

Cross-browser Testing Platform and Open Source <3 Provided by Sauce Labs

License

FOSSA Status

You can’t perform that action at this time.