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

async-transforms

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-transforms - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

require/internal-worker.js

20

lib/worker.js

@@ -8,11 +8,11 @@ import worker from 'worker_threads';

*/
function scriptDir() {
function getScriptContext() {
try {
const absolutePath = String(import.meta.url).replace(/^file:\/\//, '');
return path.dirname(absolutePath);
return {dirname: __dirname, module: false};
} catch (e) {
// try __dirname
// We have to try __dirname first, as this way we can detect module mode correctly.
}
try {
return __dirname;
const absolutePath = String(import.meta.url).replace(/^file:\/\//, '');
return {dirname: path.dirname(absolutePath), module: true};
} catch (e) {

@@ -23,4 +23,6 @@ throw new Error(`could not resolve __dirname or import.meta.url`);

const {dirname: scriptDir, module: isModule} = getScriptContext();
const cpuCount = os.cpus().length || 4;
const workerTarget = path.join(scriptDir(), './internal-worker.js');
const workerTarget = path.join(scriptDir, './internal-worker.' + (isModule ? 'js' : 'cjs'));

@@ -59,3 +61,7 @@ export function pool(dep, options) {

} else if (activeWorkers < options.tasks) {
w = new worker.Worker(workerTarget, {workerData: {dep}});
// In commonJS mode, we have to _again_ require the script, as the Worker ctor incorrectly
// only allows ".js" (run as modules because of `type: module`) or ".mjs" extensions.
// This will probably be fixed in a future Node. Sounds like a bug.
const code = isModule ? workerTarget : `require(${JSON.stringify(workerTarget)});`;
w = new worker.Worker(code, {workerData: {dep}, eval: !isModule});
++activeWorkers;

@@ -62,0 +68,0 @@ } else {

{
"name": "async-transforms",
"version": "1.0.1",
"version": "1.0.2",
"description": "Asynchronous stream transforms",

@@ -9,4 +9,6 @@ "type": "module",

"exports": {
"import": "./lib/transforms.js",
"require": "./require/transforms.cjs",
".": {
"import": "./lib/transforms.js",
"require": "./require/transforms.cjs"
},
"./worker": {

@@ -13,0 +15,0 @@ "import": "./lib/worker.js",

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