3.4.0-0 • Published 5 years ago

jszip-unzip v3.4.0-0

Weekly downloads
2
License
MIT
Repository
-
Last release
5 years ago

JSZip-unzip

A JSZip version of the unzip command for extracting all the entries from a ZIP archive into a specified directory, creating any required subdirectories.

The target directory can be a physical one (if running in Node.js) or a simulated one by supplying the fs option to unzip. The passed object must support the functions mkdirSync, statSync, and writeFileSync with signatures compatible with Node.js's fs. One such object can be found in memfs.

import unzip from 'jszip-unzip';
import fs from 'fs';

unzip(fs.readFileSync('data.zip'), {to: '/tmp/out'})

With memfs:

import unzip from 'jszip-unzip';
import { fs } from 'memfs';

async function extract() {   
    var data = await fetch('data.zip'),
        raw = new Uint8Array(await data.arrayBuffer());
    await unzip(raw, {to: '/data', fs});
}