/* global JSZip Blob */
var extractionMap = {};
(function(){
function pathPrefixOrNothing(path) {
  return path
    ? path.slice(-1) == '/'
      ? path
      : path + '/'
    : '';
}
function remappedPath(name, slicing) {
  if (name.slice(0, slicing.from.length) == slicing.from) {
    return slicing.to + name.slice(slicing.from.length);
  } else return null;
}
function fillMaps(base, path) {
  if (path[0]) {
    var newBase = base.get(path[0]);
    if (!newBase) {
      newBase = new Map();
      base.set(path[0], newBase);
    }
    return fillMaps(newBase, path.slice(1));
  }
}
function addFilesFromZip(exMap, sourceEntry, zipData) {
  var zip = new JSZip(zipData);
  var names = Object.keys(zip.files);
  var slicings = sourceEntry.slice || [{}];
  slicings.forEach(function normalizeSlicing(slicing) {
    slicing.from = pathPrefixOrNothing(slicing.from);
    slicing.to = pathPrefixOrNothing(slicing.to);
  });
  names.forEach(function addExMapEntries(name) {
    slicings.forEach(function addEntryForSlice(slicing) {
      var newName = remappedPath(name, slicing);
      if (newName) {
        var file = zip.files[name];
        if (file.dir) {
          fillMaps(exMap.dirs, newName.split('/'));
        } else {
          exMap.files.set(newName, {
            getBlob: function getBlob() {
              return new Blob([file.asArrayBuffer()]);
            },
            getText: function getText() {
              return file.asText();
            }
          });
        }
      }
    });
  });
}
function addToExtractionMap(exMap, sourceEntry, archiveData) {
  if (sourceEntry.type == "zip") {
    return addFilesFromZip(exMap, sourceEntry, archiveData);
  }
}
function newExtractionMap() {
  return {
    files: new Map(),
    dirs: new Map()
  };
}
})();

@@ -21,13 +21,18 @@
  */%0A
-var e
+function E
 xtra
@@ -43,14 +43,65 @@
 nMap
- = %7B%7D;
+() %7B%0A  this.files = new Map();%0A  this.dirs = new Map();%0A%7D
 %0A(fu
@@ -1564,24 +1564,51 @@
 %7D);%0A  %7D);%0A%7D%0A
+ExtractionMap.addArchive =%0A
 function add
@@ -1607,16 +1607,23 @@
 tion add
+Archive
 ToExtrac
@@ -1630,23 +1630,16 @@
 tionMap(
-exMap, 
 sourceEn
@@ -1712,37 +1712,36 @@
 addFilesFromZip(
-exMap
+this
 , sourceEntry, a
@@ -1762,98 +1762,9 @@
  %7D%0A%7D
-%0Afunction newExtractionMap() %7B%0A  return %7B%0A    files: new Map(),%0A    dirs: new Map()%0A  %7D;%0A%7D
+;
 %0A%7D)(

Make ExtractionMap all OOP-y