How to use the yauzl.ZipFile.prototype function in yauzl

To help you get started, we’ve selected a few yauzl 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 walletpass / pass-js / src / lib / yazul-promisified.ts View on Github external
writable: false,
    configurable: false,
    value() {
      return new EventIterator((push, stop, fail) => {
        this.addListener('entry', push);
        this.addListener('end', stop);
        this.addListener('error', fail);
      })[Symbol.asyncIterator]();
    },
  },
  openReadStreamAsync: {
    enumerable: true,
    writable: false,
    configurable: false,
    // eslint-disable-next-line @typescript-eslint/unbound-method
    value: promisify(ZipFile.prototype.openReadStream),
  },
  getBuffer: {
    enumerable: true,
    writable: false,
    configurable: false,
    async value(entry: Entry) {
      const stream = await this.openReadStreamAsync(entry);
      return streamToBuffer(stream);
    },
  },
});
export const unzipBuffer = (promisify(ZipFromBuffer) as unknown) as (
  buffer: Buffer,
  options?: Options,
) => Promise<
  ZipFile & {
github walletpass / pass-js / src / lib / yazul-promisified.ts View on Github external
import { promisify } from 'util';

import { Entry, Options, ZipFile, fromBuffer as ZipFromBuffer } from 'yauzl';
import { EventIterator } from 'event-iterator';

import { streamToBuffer } from './stream-to-buffer';

// Promisifying yauzl
Object.defineProperties(ZipFile.prototype, {
  [Symbol.asyncIterator]: {
    enumerable: true,
    writable: false,
    configurable: false,
    value() {
      return new EventIterator((push, stop, fail) => {
        this.addListener('entry', push);
        this.addListener('end', stop);
        this.addListener('error', fail);
      })[Symbol.asyncIterator]();
    },
  },
  openReadStreamAsync: {
    enumerable: true,
    writable: false,
    configurable: false,