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

funthreads

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

funthreads - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4

6

CONTRIBUTING.md

@@ -1,9 +0,9 @@

# Contributing to `worker_map`
# Contributing to `funthreads`
Contributions are always welcome.
To contribute, [fork](https://help.github.com/articles/fork-a-repo/) worker_map, commit your changes, & [send a pull request](https://help.github.com/articles/using-pull-requests/).
To contribute, [fork](https://help.github.com/articles/fork-a-repo/) funthreads, commit your changes, & [send a pull request](https://help.github.com/articles/using-pull-requests/).
## Feature Requests
Feature requests should be submitted in the [issue tracker](https://github.com/nairihar/worker_map/issues), with a description of
Feature requests should be submitted in the [issue tracker](https://github.com/nairihar/funthreads/issues), with a description of
the expected behavior & use case.

@@ -10,0 +10,0 @@

{
"name": "funthreads",
"version": "2.0.3",
"version": "2.0.4",
"description": "A lightweight tool built on top of Node.js worker_threads, enabling multithreading.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -113,4 +113,4 @@ ![](https://img.shields.io/badge/dependencies-none-brightgreen.svg)

async function read() {
const modules = new ThreadModules('fs/promises', 'test', 'path', ...);
const content = await executeInThread(task, modules);
const requiredModules = new ThreadModules('fs/promises', 'test', 'path', ...);
const content = await executeInThread(task, requiredModules);
console.log(content);

@@ -122,2 +122,4 @@ }

The `ThreadModules` class lets you set up modules for the thread. Just provide it as the second argument, and you'll have access to the libraries through the `modules` object.
The `ThreadModules` class lets you set up modules for the thread. You can provide it only thorough the second argument, and you'll have access to the libraries through the `modules` object.
You should only provide the `ThreadModules` type of object once through the second parameter. Attempting to provide it multiple times will result in an error. Additionally, avoid returning the `modules` object from the task function, as it will also lead to errors.

@@ -11,5 +11,11 @@ const startWorker = require('./worker/executor');

exports.executeInThread = (task, threadModules, ...args) => {
let modules; let
params;
let params;
let modules;
const moduleArg = args.find((arg) => arg instanceof ThreadModules);
if (moduleArg) {
throw new Error('ThreadModules type of object should be provided only through the second argument!');
}
if (threadModules instanceof ThreadModules) {

@@ -16,0 +22,0 @@ modules = threadModules.names;

@@ -15,4 +15,5 @@ const generateWorkerCode = (func) => `

const task = ${func};
const modules = loadModules(workerData.workerModules);
const res = task(...workerData.workerParams, modules);
const res = workerData.workerModules
? task(loadModules(workerData.workerModules), ...workerData.workerParams)
: task(...workerData.workerParams);
const data = (res instanceof Promise) ? await res : res;

@@ -19,0 +20,0 @@ parentPort.postMessage({ data });

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