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

@rushstack/node-core-library

Package Overview
Dependencies
Maintainers
3
Versions
136
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rushstack/node-core-library - npm Package Compare versions

Comparing version 4.2.0 to 4.2.1

23

lib/Async.js

@@ -53,4 +53,3 @@ "use strict";

let concurrentUnitsInProgress = 0;
const iterator = (iterable[Symbol.iterator] ||
iterable[Symbol.asyncIterator]).call(iterable);
const iterator = iterable[Symbol.asyncIterator].call(iterable);
let arrayIndex = 0;

@@ -63,5 +62,7 @@ let iteratorIsComplete = false;

!promiseHasResolvedOrRejected) {
// Increment the concurrency while waiting for the iterator.
// This function is reentrant, so this ensures that at most `concurrency` executions are waiting
concurrentUnitsInProgress++;
// Increment the current concurrency units in progress by the concurrency limit before fetching the iterator weight.
// This function is reentrant, so this if concurrency is finite, at most 1 operation will be waiting. If it's infinite,
// there will be effectively no cap on the number of operations waiting.
const limitedConcurrency = !Number.isFinite(concurrency) ? 1 : concurrency;
concurrentUnitsInProgress += limitedConcurrency;
const currentIteratorResult = await iterator.next();

@@ -73,9 +74,11 @@ // eslint-disable-next-line require-atomic-updates

Async.validateWeightedIterable(currentIteratorValue);
// Cap the weight to concurrency, this allows 0 weight items to execute despite the concurrency limit.
const weight = Math.min(currentIteratorValue.weight, concurrency);
// If it's a weighted operation then add the rest of the weight, removing concurrent units if weight < 1.
// Cap it to the concurrency limit, otherwise higher weights can cause issues in the case where 0 weighted
// operations are present.
concurrentUnitsInProgress += weight - 1;
// Remove the "lock" from the concurrency check and only apply the current weight.
// This should allow other operations to execute.
concurrentUnitsInProgress += weight;
concurrentUnitsInProgress -= limitedConcurrency;
Promise.resolve(callback(currentIteratorValue.element, arrayIndex++))
.then(async () => {
// Remove the operation completely from the in progress units.
concurrentUnitsInProgress -= weight;

@@ -91,3 +94,3 @@ await onOperationCompletionAsync();

// The iterator is complete and there wasn't a value, so untrack the waiting state.
concurrentUnitsInProgress--;
concurrentUnitsInProgress -= limitedConcurrency;
}

@@ -94,0 +97,0 @@ }

{
"name": "@rushstack/node-core-library",
"version": "4.2.0",
"version": "4.2.1",
"description": "Core libraries that every NodeJS toolchain project should use",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

Sorry, the diff of this file is not supported yet

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