How to use the jszip function in jszip

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 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>';
github mozilla / FirefoxColor / src / web / lib / export.js View on Github external
export default function performThemeExport({
  name = "Default Name",
  // TODO: Need other manifest attributes?
  store,
  bgImages
}) {
  log("performThemeExport");
  reset();

  const zip = new JSZip();
  const state = store.getState();
  const themeData = selectors.theme(state);
  const customBackgrounds = selectors.themeCustomImages(state);
  const theme = convertToBrowserTheme(themeData, bgImages, customBackgrounds);

  if (theme.images) {
    const { images } = theme;
    const { additional_backgrounds } = images;
    if (images.theme_frame) {
      images.theme_frame = addImage(zip, images.theme_frame);
    }
    if (additional_backgrounds) {
      for (let idx = 0; idx &lt; additional_backgrounds.length; idx++) {
        additional_backgrounds[idx] = addImage(
          zip,
          additional_backgrounds[idx]
github steelydylan / atomic-lab / src / components / sidemenu / sidemenu.jsx View on Github external
exportAsZip() {
    const zip = new JSZip();
    const comps = this.props.components;
    const config = this.props.config;
    comps.forEach(function(comp) {
      if(!comp.name){
        return;
      }
      const file1 = `components/${comp.name}/${comp.name}.${config.markup}`;
      const file2 = `components/${comp.name}/${comp.name}.${config.styling}`;
      zip.file(file1, comp.html);
      zip.file(file2, comp.css);
    });
    zip.file("package.json", getPackage());
    zip.generateAsync({
      type: "blob"
    }).then((content) => {
      FileSaver.saveAs(content, "atomic-lab.zip");
github egeriis / zipcelx / src / zipcelx.js View on Github external
export default (config) => {
  if (!validator(config)) {
    throw new Error('Validation failed.');
  }

  const zip = new JSZip();
  const xl = zip.folder('xl');
  xl.file('workbook.xml', workbookXML);
  xl.file('_rels/workbook.xml.rels', workbookXMLRels);
  zip.file('_rels/.rels', rels);
  zip.file('[Content_Types].xml', contentTypes);

  const worksheet = generateXMLWorksheet(config.sheet.data);
  xl.file('worksheets/sheet1.xml', worksheet);

  return zip.generateAsync({
    type: 'blob',
    mimeType:
      'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
  }).then((blob) => {
    FileSaver.saveAs(blob, `${config.filename}.xlsx`);
  });
github rafaelgssa / esgst / browser / src / eventPage.js View on Github external
async function getZip(data, fileName) {
  const zip = new JSZip();
  zip.file(fileName, data);
  return (await zip.generateAsync({
    compression: 'DEFLATE',
    compressionOptions: {
      level: 9
    },
    type: 'blob'
  }));
}
github tomjschuster / sequelize-ui / src / utils.js View on Github external
const formatAndCompressModels = (models, config) => {
  const zip = new JSZip()

  zipFile(zip, {
    name: '_db.js',
    content: serialize.dbFile,
    config
  })

  zipFile(zip, {
    name: 'index.js',
    content: serialize.associationFile(models),
    config
  })

  for (let x of models) {
    zipFile(zip, {
      name: `${Case.snake(x.name)}.js`,
github process-engine / bpmn-studio / electron_app / electron.ts View on Github external
async function createFeedbackZip(feedbackData: FeedbackData): Promise {
  const zip = new JSZip();

  const zipFolder = zip.folder('feedback');

  if (feedbackData.attachInternalDatabases) {
    await addDatabaseToZip(zipFolder);
  }

  const bugsProvided: boolean = feedbackData.bugs.trim() !== '';
  if (bugsProvided) {
    zipFolder.file('Bugs.txt', feedbackData.bugs);
  }

  const suggestionsProvided: boolean = feedbackData.suggestions.trim() !== '';
  if (suggestionsProvided) {
    zipFolder.file('Suggestions.txt', feedbackData.suggestions);
  }

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