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

utilsac

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

utilsac - npm Package Compare versions

Comparing version 15.0.2 to 15.1.0

6

changelog.md
# Changelog
## 15.1.0
add decorateForceSequential
## 15.0.1

@@ -7,3 +11,2 @@

## 15.0.0

@@ -13,3 +16,2 @@

## 14.2.0

@@ -16,0 +18,0 @@

{
"name": "utilsac",
"version": "15.0.2",
"version": "15.1.0",
"description": "Utility functions",

@@ -5,0 +5,0 @@ "license": "CC0-1.0",

@@ -20,7 +20,8 @@ # [utilsac](https://github.com/GrosSacASac/utilsac)

throttledWithLast,
chainPromiseNTimes,
chainPromises,
somePromisesParallel,
chainRequestAnimationFrame,
decorateForceSequential,
doNTimes,
chainPromiseNTimes,
timeFunction,

@@ -27,0 +28,0 @@ timePromise,

@@ -5,7 +5,8 @@ export {

throttledWithLast,
chainPromiseNTimes,
chainPromises,
somePromisesParallel,
chainRequestAnimationFrame,
decorateForceSequential,
doNTimes,
chainPromiseNTimes,
timeFunction,

@@ -116,5 +117,26 @@ timePromise,

const decorateForceSequential = function (promiseCreator) {
/* forces a function that returns a promise to be sequential
useful for fs for example */
let lastPromise = Promise.resolve();
return async function (...x) {
const promiseWeAreWaitingFor = lastPromise;
let currentPromise;
let callback;
// we need to change lastPromise before await anything,
// otherwise 2 calls might wait the same thing
lastPromise = new Promise(function (resolve) {
callback = resolve;
});
await promiseWeAreWaitingFor;
currentPromise = promiseCreator(...x);
currentPromise.then(callback).catch(callback);
return currentPromise;
};
};
const somePromisesParallel = function (promiseCreators, x = 10) {
/* same as chainPromises except it will run up to x amount of
promise in paraell */
promise in parallel */
const {length} = promiseCreators;

@@ -121,0 +143,0 @@ const values = [];

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