New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

next-webworker-pool

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-webworker-pool - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

52

dist/index.js
var k = Object.defineProperty;
var h = (n, r, e) => r in n ? k(n, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[r] = e;
var a = (n, r, e) => (h(n, typeof r != "symbol" ? r + "" : r, e), e);
class d {
var h = (i, r, e) => r in i ? k(i, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[r] = e;
var a = (i, r, e) => (h(i, typeof r != "symbol" ? r + "" : r, e), e);
class l {
constructor() {

@@ -19,6 +19,6 @@ a(this, "_taskQueue", []);

data: r
}, s = new Promise((i, t) => {
}, s = new Promise((t, n) => {
this._taskQueue.push(e), this._resultHandlers.set(
e.id,
(o) => "error" in o ? t(o.error) : i(o.data)
(o) => "error" in o ? n(o.error) : t(o.data)
);

@@ -37,3 +37,3 @@ });

const s = this._taskQueue.findIndex(
(i) => i.id === r
(t) => t.id === r
);

@@ -58,3 +58,3 @@ s !== -1 && this._taskQueue.splice(s, 1), this._handleTaskResult({

}
class l extends d {
class c extends l {
constructor(e) {

@@ -76,2 +76,7 @@ super();

}
_getTransferableData(e) {
return typeof e == "object" && e !== null ? Object.values(e).flatMap(
(s) => this._getTransferableData(s)
) : e instanceof ArrayBuffer ? [e] : e instanceof MessagePort ? [e] : e instanceof ImageBitmap ? [e] : e instanceof OffscreenCanvas ? [e] : [];
}
/**

@@ -88,3 +93,8 @@ * Tries to run a task inside a free worker.

const s = this._nextFreeWorker();
return s ? (this._workerTask.set(s, e.id), s.postMessage(e), !0) : !1;
if (s) {
this._workerTask.set(s, e.id);
const t = this._getTransferableData(e.data);
return s.postMessage(e, t), !0;
}
return !1;
}

@@ -101,6 +111,6 @@ /**

super.cancelTask(e, s), this._workers.find(
(t) => this._workerTask.get(t) === e
(n) => this._workerTask.get(n) === e
) && this._replaceWorker(
this._workers.find(
(t) => this._workerTask.get(t) === e
(n) => this._workerTask.get(n) === e
)

@@ -134,8 +144,8 @@ );

_handleWorkerMessage(e) {
const { data: s, target: i } = e, t = this._workerTask.get(i);
const { data: s, target: t } = e, n = this._workerTask.get(t);
if ((s == null ? void 0 : s.id) == null)
throw new Error(
`Invalid task result missing task ID was received from worker processing task with ID "${t}"`
`Invalid task result missing task ID was received from worker processing task with ID "${n}"`
);
this._workerTask.delete(i), this._handleTaskResult(s);
this._workerTask.delete(t), this._handleTaskResult(s);
}

@@ -149,4 +159,4 @@ /**

_handleWorkerError(e) {
const { target: s, error: i } = e, t = this._workerTask.get(s);
t ? this.cancelTask(t, i) : this._replaceWorker(s);
const { target: s, error: t } = e, n = this._workerTask.get(s);
n ? this.cancelTask(n, t) : this._replaceWorker(s);
}

@@ -173,6 +183,6 @@ /**

}
function u(n, r) {
class e extends l {
function _(i, r) {
class e extends c {
_createWorker() {
return n();
return i();
}

@@ -183,5 +193,5 @@ }

export {
d as TaskScheduler,
l as WebWorkerPool,
u as createWorkerPool
l as TaskScheduler,
c as WebWorkerPool,
_ as createWorkerPool
};

@@ -24,2 +24,3 @@ import { Task, TaskId, TaskExecutor } from './TaskExecutor';

protected abstract _createWorker(): Worker;
private _getTransferableData;
/**

@@ -26,0 +27,0 @@ * Tries to run a task inside a free worker.

{
"name": "next-webworker-pool",
"version": "0.0.5",
"version": "0.0.6",
"author": "Iulian-Constantin Marcu",

@@ -5,0 +5,0 @@ "description": "A NPM package that enables developers to build Web Worker pools that can be used in (but not limited to) Next.js applications",

@@ -7,2 +7,6 @@ # next-webworker-pool

## Example
You can find an example Next.js project using `next-webworker-pool` [here](https://stackblitz.com/edit/next-webworker-pool-example?file=app%2Fpage.tsx).
## Installation

@@ -9,0 +13,0 @@

Sorry, the diff of this file is not supported yet

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