Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const runFailure = (n: number, failure = true) => {
each((v, i) => {
plugin.init(context, next, makeRequest);
context.setState({ error: new Error(`error ${i}`) });
if (failure) {
plugin.error(context, next, makeRequest);
} else {
plugin.complete(context, next, makeRequest);
}
}, Array(n));
};
setTimeout(() => {
const { requests, nexts } = batchRequests[batchKey];
delete batchRequests[batchKey];
makeGroupedRequest(requests)
.then(
each((response, i) => {
nexts[i]({
response,
status: Status.COMPLETE,
});
})
)
.catch((error) => {
const state = { error, status: Status.ERROR };
each((nxt) => nxt(state), nexts);
});
}, batchTimeout);
},
.catch((error) => {
const state = { error, status: Status.ERROR };
each((nxt) => nxt(state), nexts);
});
}, batchTimeout);