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

promise-chain-executor

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-chain-executor - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

5

dist/index.d.ts

@@ -1,3 +0,4 @@

export declare const index: {
execute: <T>(promiseSupplier: (previousResult: T | null) => Promise<T | null>) => Promise<Array<T>>;
export type PromiseSupplier<T> = (previousResult: T | null) => Promise<T | null>;
export declare const promiseChainExecutor: {
execute: <T>(promiseSupplier: PromiseSupplier<T>) => Promise<Array<T>>;
};

32

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.index = void 0;
const execute = (promiseSupplier) => {
exports.promiseChainExecutor = void 0;
const execute = async (promiseSupplier) => {
const results = [];

@@ -10,3 +10,3 @@ const handleError = (err) => {

};
const handleResult = (result) => {
const handleResult = async (result) => {
if (result === null) {

@@ -16,6 +16,11 @@ return Promise.resolve(results);

results.push(result);
const nextPromise = promiseSupplier(result);
return nextPromise
.then(handleResult)
.catch(handleError);
try {
const nextPromise = promiseSupplier(result);
const nextResult = await nextPromise;
return await handleResult(nextResult);
}
catch (err) {
handleError(err);
throw err;
}
};

@@ -26,8 +31,13 @@ const initialPromise = promiseSupplier(null);

}
return initialPromise
.then(handleResult)
.catch(handleError);
try {
const initialResult = await initialPromise;
return await handleResult(initialResult);
}
catch (err) {
handleError(err);
throw err;
}
};
exports.index = {
exports.promiseChainExecutor = {
execute,
};

@@ -14,3 +14,3 @@ "use strict";

};
const results = await index_1.index.execute(promiseSupplier);
const results = await index_1.promiseChainExecutor.execute(promiseSupplier);
expect(results).toStrictEqual([1, 2, 3, 4, 5, 6, 7, 8, 9]);

@@ -17,0 +17,0 @@ });

{
"name": "promise-chain-executor",
"version": "2.0.0",
"version": "3.0.0",
"description": "Executes promises in a chain, allowing results from previous promise to affect following ones",

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

@@ -24,2 +24,3 @@

handleError(err)
throw err
}

@@ -38,2 +39,3 @@ };

handleError(err)
throw err
}

@@ -40,0 +42,0 @@ };

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