How to use jszip - 10 common examples

To help you get started, we’ve selected a few jszip examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dtjohnson / xlsx-populate / test / unit / XlsxPopulate.spec.js View on Github external
"use strict";

const proxyquire = require("proxyquire");
const Promise = require("jszip").external.Promise;

describe("XlsxPopulate", () => {
    let dateConverter, Workbook, XlsxPopulate, FormulaError, externals;

    beforeEach(() => {
        dateConverter = jasmine.createSpyObj("dateConverter", ["dateToNumber", "numberToDate"]);
        dateConverter.dateToNumber.and.returnValue("NUMBER");
        dateConverter.numberToDate.and.returnValue("DATE");

        Workbook = jasmine.createSpyObj("Workbook", ["fromBlankAsync", "fromDataAsync", "fromFileAsync"]);
        Workbook.fromBlankAsync.and.returnValue("WORKBOOK");
        Workbook.fromDataAsync.and.returnValue("WORKBOOK");
        Workbook.fromFileAsync.and.returnValue("WORKBOOK");
        Workbook.MIME_TYPE = "MIME_TYPE";

        // proxyquire doesn't like overriding raw objects... a spy obj works.
github duddu / cordova-plugin-antitampering / tests / tamper / android.js View on Github external
'use strict';

/* eslint no-console: 0, no-process-env: 0 */

var fs = require('fs');
var path = require('path');
var JSZip = require('jszip');

var apk;
var indexAsset = 'assets/www/index.html';
var platformPath = path.join(process.env.ANTITAMPERING_TEST_DIR, 'platforms/android');
var tamperedApkPath = path.join(process.env.TRAVIS_BUILD_DIR, 'tests/android-tampered.apk');

new JSZip.external.Promise(function (resolve, reject) {
    fs.readFile(path.join(platformPath, 'app/build/outputs/apk/debug/app-debug.apk'), function (_err, _data) {
        if (!_err) {
            resolve(_data);
        } else {
            fs.readFile(path.join(platformPath, 'build/outputs/apk/android-debug.apk'), function (err, data) {
                if (!err) {
                    resolve(data);
                } else {
                    reject(err);
                }
            });
        }
    });
})
    .then(function (data) {
        return JSZip.loadAsync(data);
github dtjohnson / xlsx-populate / test / unit / XmlParser.spec.js View on Github external
"use strict";

const proxyquire = require("proxyquire");
const Promise = require("jszip").external.Promise;

describe("XmlParser", () => {
    let XmlParser, xmlParser, externals;

    beforeEach(() => {
        // proxyquire doesn't like overriding raw objects... a spy obj works.
        externals = jasmine.createSpyObj("externals", ["_"]);
        externals.Promise = Promise;

        XmlParser = proxyquire("../../lib/XmlParser", {
            './externals': externals,
            '@noCallThru': true
        });
        xmlParser = new XmlParser();
    });
github aamks / aamks / gui / interface / src / app / views / main / risk / results / results.component.ts View on Github external
public showAnimation(chosenAnim) {
    // After static data is loaded to paperjs we can run animations.
    // 0.000001 & friends prevent divisions by 0.
    var promise = new JSZip.external.Promise(function (resolve, reject) {
      JSZipUtils.getBinaryContent("../" + chosenAnim["anim"], function (err, data) {
        if (err) {
          reject(err);
        } else {
          resolve(data);
        }
      });
    });

    promise.then(JSZip.loadAsync)
      .then(function (zip) {
        console.log(zip);
        return zip.catch.toString();
        //return zip.file("anim.json").async("string");
      })
github Secretmapper / Riyu / editor / src / zip / index.js View on Github external
export async function generateZip (html, data) {
  try {
    zip.file('index.html', html)
    zip.folder('src').file('data.js', `module.exports = ${JSON.stringify(data, null, 4)}`)

    if (JSZip.support.blob) {
      const blob = await zip.generateAsync({ type: 'blob' })
      FileSaver.saveAs(blob, 'riyu.zip')
    } else {
      throw new Error('Saving zip files through javascript not supported on this browser')
    }
  } catch (e) {
    // TODO: Better error messages
    alert('Sorry something went wrong! Please reload the page :(')
    console.error(e)
  }
}
github process-engine / bpmn-studio / electron_app / electron.ts View on Github external
async function exportDatabases(): Promise {
  const zip = new JSZip();

  await addDatabaseToZip(zip);

  // eslint-disable-next-line newline-per-chained-call
  const now = new Date().toISOString().replace(/:/g, '-');
  const defaultFilename = `database-backup-${now}.zip`;

  const pathToSaveTo: string = await getPathToSaveTo(defaultFilename);

  if (!pathToSaveTo) {
    return;
  }

  zip.generateAsync({type: 'nodebuffer'}).then((content) => {
    fs.writeFileSync(pathToSaveTo, content);
  });
github Kitware / vtk-js / Sources / Rendering / Misc / SynchronizableRenderWindow / example / index.js View on Github external
function loadZipContent(zipContent, container) {
  const fileContents = { state: null, arrays: {} };

  function getArray(hash, binary) {
    return Promise.resolve(fileContents.arrays[hash]);
  }

  const zip = new JSZip();
  zip.loadAsync(zipContent).then(() => {
    let workLoad = 0;

    function done() {
      if (workLoad !== 0) {
        return;
      }

      // Synchronize context
      const synchronizerContext = vtkSynchronizableRenderWindow.getSynchronizerContext(
        CONTEXT_NAME
      );
      synchronizerContext.setFetchArrayFunction(getArray);

      // openGLRenderWindow
      const openGLRenderWindow = vtkOpenGLRenderWindow.newInstance();
github wp-pwa / worona-dashboard / client / packages / publish-dashboard-extension-worona / src / dashboard / sagas / publishSite.js View on Github external
function createZipFile(siteId, site, user, images, imagesData) {
  /* Creating the zip file */
  const zip = new JSZip();
  const www = zip.folder('www');

  /* Generate index.html file */
  www.file('index.html', indexHtml);

  /* Generate config.xml file */
  const configParams = {
    appId: generateAppId(site.url),
    appName: site.name,
    siteURL: site.url,
    userEmail: user.email,
    userName: user.name,
    siteId,
  };
  const xmlFile = generateConfigXML(configParams);
  www.file('config.xml', xmlFile);
github wing-kai / epub-manga-creator / src / generate_epub.js View on Github external
const generateEPUB = function(State) {
    const Zip = new JSZip();
    const UUID = State.mangaInfo.bookInfo.id.trim() === "" ? generateRandomUUID() : State.mangaInfo.bookInfo.id;

    Zip.folder("META-INF");
    Zip.folder("OEBPS/image");
    Zip.folder("OEBPS/text");
    Zip.folder("OEBPS/style");

    // render toc.xhtml file

    let file_navigation_documents_xhtml = Template["navigation-documents.xhtml"];

    const navigationList = State.mangaInfo.contents.map(navPointInfo => {
        if (navPointInfo.refindex === 1)
            return '<li><a href="text/p_cover.xhtml">' + htmlToEscape(navPointInfo.text) + '</a></li>';

        return '<li><a href="text/p_' + counter(navPointInfo.refindex - 2, 4) + '.xhtml">' + htmlToEscape(navPointInfo.text) + '</a></li>';

jszip

Create, read and edit .zip files with JavaScript http://stuartk.com/jszip

(MIT OR GPL-3.0-or-later)
Latest version published 2 years ago

Package Health Score

80 / 100
Full package analysis