JSPM

  • Created
  • Published
  • Downloads 8618
  • Score
    100M100P100Q129608F
  • License MIT

Unzipping files, simple wrap for zip.js(for browser) and yauzl(for nodejs), make the apis consistent for NodeJS/Webpack/Browserify.

Package Exports

  • isomorphic-unzip

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (isomorphic-unzip) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

isomorphic-unzip

This is part of the project isomorphic-pkg-reader.

Now it's only provide a few simple apis for supporting isomorphic-pkg-reader, it can read the specific entries from a .zip file and parse them to Buffer, it works both for NodeJS and Browsersify/Webpack.

// usage

var Unzip = require('isomorphic-unzip');

// In browser, pass a File/Blob into the constructor
var unzip = new Unzip(file /* or blob */);

// In NodeJS, pass the dest path of your file
var unzip = new Unzip('/location/to/your/path');

// They have the same api: getBuffer
unzip.getBuffer(['androidmanifest.xml', 'resources.arsc'], function(err, buffers) {
  if(err) throw err;


  // buffers it's like {'androidmanifest.xml': Buffer, 'resources.arsc': Buffer}
  console.log(buffers);
});

API

unzip.getBuffer(whatYouNeed, callback)

whatYouNeed is an array of string that contains the entry name you want to access, the callback will receive two params as callback(error, buffers). buffers is a object that use the entry name as key, Buffer object as value.

Currently we expose only one api, we'll improve this latter.