Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@reverecre/promise
Advanced tools
@reverecre/promise
npm i @reverecre/promise
Splits an array into subarray chunks.
Function | Type |
---|---|
chunkArray | <T>(arr: readonly T[], chunkSize: number) => T[][] |
Parameters:
arr
: The array to be chunked.chunkSize
: Size of the sub-arrays.Processes an array of items using a given callback and concurrency. Best used as an alternative to Promise.all(items.map(...)) as it limits concurrency.
Function | Type |
---|---|
workerPool | <In, Out>(tasks: readonly In[], fn: (task: In) => MaybePromise<Out>, workers?: number) => Promise<readonly Out[]> |
Parameters:
tasks
: Items to be processed.fn
: Callback to map each item.workers
: Maximum number of promises to execute at once.workerPool
implementation that batches tasks
into chunks before calling
fn
to allow for processing in small batches.
Function | Type |
---|---|
chunkedWorkerPool | <In, Out>(tasks: readonly In[], fn: (task: In[]) => MaybePromise<Out[]>, { chunkSize, workers }?: { workers?: number; chunkSize?: number; }) => Promise<readonly Out[]> |
Parameters:
tasks
: Items to be processed.fn
: Callback to map each item.options
: Concurrency controls.Waits a given number of milliseconds.
Function | Type |
---|---|
sleep | (ms: number) => Promise<unknown> |
Wraps a function that returns a promise adding retry logic, before throwing the last seen error.
Function | Type |
---|---|
retry | <In extends unknown[], Out>(fn: (...args: In) => Promise<Out>, { attempts, backoffDuration, backoffJitter, onError, }?: RetryOptions) => (...args: In) => Promise<Out> |
Wraps a function that returns a promise adding retry logic, before throwing returning a default.
Function | Type |
---|---|
retryWithDefault | <In extends unknown[], Out>(fn: (...args: In) => Promise<Out>, defaultTo: Out, opts?: RetryOptions) => (...args: In) => Promise<Out> |
FAQs
A utility library for working with promises
We found that @reverecre/promise demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.