How to use the @tinkoff/utils/array/each function in @tinkoff/utils

To help you get started, we’ve selected a few @tinkoff/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TinkoffCreditSystems / tinkoff-request / packages / plugin-circuit-breaker / src / circuit-breaker.spec.ts View on Github external
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));
    };
github TinkoffCreditSystems / tinkoff-request / packages / plugin-batch / src / batch.ts View on Github external
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);
        },
github TinkoffCreditSystems / tinkoff-request / packages / plugin-batch / src / batch.ts View on Github external
.catch((error) => {
                        const state = { error, status: Status.ERROR };

                        each((nxt) => nxt(state), nexts);
                    });
            }, batchTimeout);