Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unzipit

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unzipit - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

43

dist/unzipit-worker.js

@@ -1,2 +0,2 @@

/* unzipit@0.1.0, license MIT */
/* unzipit@0.1.1, license MIT */
(function (factory) {

@@ -594,3 +594,5 @@ typeof define === 'function' && define.amd ? define(factory) :

// note: we only workerize the inflate portion.
/* global process, require */
// note: we only handle the inflate portion in a worker
// every other part is already async and JavaScript

@@ -601,6 +603,29 @@ // is non blocking. I suppose if you had a million entry

const msgHelper = (function() {
const isNode = (typeof process !== 'undefined') &&
(typeof process.versions.node !== 'undefined');
if (isNode) {
const { parentPort } = require('worker_threads');
return {
postMessage: parentPort.postMessage.bind(parentPort),
addEventListener: parentPort.on.bind(parentPort),
};
} else {
return {
postMessage: self.postMessage.bind(self),
addEventListener(type, fn) {
self.addEventListener(type, (e) => {
fn(e.data);
});
},
};
}
}());
// class InflateRequest {
// id: string,
// data: arraybuffer, sharedarraybuffer, blob
// uncompressedSize: // can be undefined
// src: ArrayBuffer, SharedArrayBuffer, blob
// uncompressedSize: number,
// type: string or undefined
// }

@@ -631,3 +656,3 @@ //

}
self.postMessage({
msgHelper.postMessage({
id,

@@ -638,3 +663,3 @@ data,

console.error(e);
self.postMessage({
msgHelper.postMessage({
id,

@@ -650,4 +675,4 @@ error: `${e.toString()}`,

self.onmessage = function(e) {
const {type, data} = e.data;
msgHelper.addEventListener('message', function(e) {
const {type, data} = e;
const fn = handlers[type];

@@ -658,4 +683,4 @@ if (!fn) {

fn(data);
};
});
}));

@@ -1,2 +0,2 @@

/* unzipit@0.1.0, license MIT */
/* unzipit@0.1.1, license MIT */
function deflateRaw(data, out, opos, lvl) {

@@ -589,3 +589,5 @@ var opts = [

// note: we only workerize the inflate portion.
/* global process, require */
// note: we only handle the inflate portion in a worker
// every other part is already async and JavaScript

@@ -596,6 +598,29 @@ // is non blocking. I suppose if you had a million entry

const msgHelper = (function() {
const isNode = (typeof process !== 'undefined') &&
(typeof process.versions.node !== 'undefined');
if (isNode) {
const { parentPort } = require('worker_threads');
return {
postMessage: parentPort.postMessage.bind(parentPort),
addEventListener: parentPort.on.bind(parentPort),
};
} else {
return {
postMessage: self.postMessage.bind(self),
addEventListener(type, fn) {
self.addEventListener(type, (e) => {
fn(e.data);
});
},
};
}
}());
// class InflateRequest {
// id: string,
// data: arraybuffer, sharedarraybuffer, blob
// uncompressedSize: // can be undefined
// src: ArrayBuffer, SharedArrayBuffer, blob
// uncompressedSize: number,
// type: string or undefined
// }

@@ -626,3 +651,3 @@ //

}
self.postMessage({
msgHelper.postMessage({
id,

@@ -633,3 +658,3 @@ data,

console.error(e);
self.postMessage({
msgHelper.postMessage({
id,

@@ -645,4 +670,4 @@ error: `${e.toString()}`,

self.onmessage = function(e) {
const {type, data} = e.data;
msgHelper.addEventListener('message', function(e) {
const {type, data} = e;
const fn = handlers[type];

@@ -653,2 +678,2 @@ if (!fn) {

fn(data);
};
});

@@ -1,2 +0,2 @@

/* unzipit@0.1.0, license MIT */
/* unzipit@0.1.1, license MIT */
(function (global, factory) {

@@ -623,2 +623,4 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

/* global process, require */
const config = {

@@ -664,7 +666,40 @@ numWorkers: 1,

const workerHelper = (function() {
const isNode = (typeof process !== 'undefined') &&
(typeof process.versions.node !== 'undefined');
if (isNode) {
const {Worker} = require('worker_threads');
return {
createWorker(url) {
return new Worker(url);
},
addEventListener(worker, fn) {
worker.on('message', (data) => {
fn({target: worker, data});
});
},
async terminate(worker) {
await worker.terminate();
},
};
} else {
return {
createWorker(url) {
return new Worker(url);
},
addEventListener(worker, fn) {
worker.addEventListener('message', fn);
},
async terminate(worker) {
worker.terminate();
},
};
}
}());
function getAvailableWorker() {
if (availableWorkers.length === 0 && numWorkers < config.numWorkers) {
++numWorkers;
const worker = new Worker(config.workerURL);
worker.onmessage = handleResult;
const worker = workerHelper.createWorker(config.workerURL);
workerHelper.addEventListener(worker, handleResult);
availableWorkers.push(worker);

@@ -768,2 +803,8 @@ }

async function cleanup() {
for (const worker of availableWorkers) {
await workerHelper.terminate(worker);
}
}
/*

@@ -1176,3 +1217,3 @@ class Zip {

if (type) {
return new Blob([data], {type});
return new Blob([isSharedArrayBuffer(data.buffer) ? new Uint8Array(data) : data], {type});
}

@@ -1226,2 +1267,7 @@ return data.slice().buffer;

function cleanup$1() {
cleanup();
}
exports.cleanup = cleanup$1;
exports.setOptions = setOptions$1;

@@ -1228,0 +1274,0 @@ exports.unzip = unzip;

@@ -1,2 +0,2 @@

/* unzipit@0.1.0, license MIT */
/* unzipit@0.1.1, license MIT */
/* global SharedArrayBuffer */

@@ -617,2 +617,4 @@

/* global process, require */
const config = {

@@ -658,7 +660,40 @@ numWorkers: 1,

const workerHelper = (function() {
const isNode = (typeof process !== 'undefined') &&
(typeof process.versions.node !== 'undefined');
if (isNode) {
const {Worker} = require('worker_threads');
return {
createWorker(url) {
return new Worker(url);
},
addEventListener(worker, fn) {
worker.on('message', (data) => {
fn({target: worker, data});
});
},
async terminate(worker) {
await worker.terminate();
},
};
} else {
return {
createWorker(url) {
return new Worker(url);
},
addEventListener(worker, fn) {
worker.addEventListener('message', fn);
},
async terminate(worker) {
worker.terminate();
},
};
}
}());
function getAvailableWorker() {
if (availableWorkers.length === 0 && numWorkers < config.numWorkers) {
++numWorkers;
const worker = new Worker(config.workerURL);
worker.onmessage = handleResult;
const worker = workerHelper.createWorker(config.workerURL);
workerHelper.addEventListener(worker, handleResult);
availableWorkers.push(worker);

@@ -762,2 +797,8 @@ }

async function cleanup() {
for (const worker of availableWorkers) {
await workerHelper.terminate(worker);
}
}
/*

@@ -1170,3 +1211,3 @@ class Zip {

if (type) {
return new Blob([data], {type});
return new Blob([isSharedArrayBuffer(data.buffer) ? new Uint8Array(data) : data], {type});
}

@@ -1220,2 +1261,6 @@ return data.slice().buffer;

export { setOptions$1 as setOptions, unzip, unzipRaw };
function cleanup$1() {
cleanup();
}
export { cleanup$1 as cleanup, setOptions$1 as setOptions, unzip, unzipRaw };
{
"name": "unzipit",
"version": "0.1.0",
"version": "0.1.1",
"description": "random access unzip library for JavaScript",

@@ -5,0 +5,0 @@ "main": "dist/unzipit.js",

@@ -159,2 +159,15 @@ # unzipit.js

### Workers in Node
```js
const unzipit = require('unzipit');
unzipit.setOptions({workerURL: require.resolve('unzipit/dist/unzipit-worker.js')});
...
// Only if you need node to exit you need to shut down the workers.
unzipit.cleanup();
```
## Why?

@@ -161,0 +174,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc