Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@travetto/pool
Advanced tools
This module provides an API for dealing with pools of elements, and special attention is given to pools that are used for managing jobs as opposed to simple resources.
The module wraps around generic-pool
as a base for the pooling mechanism.
With respect to managing jobs, ConcurrentPool
is provided to allow for concurrent operation, and processing of jobs as quickly as possible.
To manage the flow of jobs, there are various DataSource
implementation that allow for a wide range of use cases.
The supported DataSource
s are
Array
is a list of jobs, will execute in order until list is exhausted.Queue
is similar to list but will execute forever waiting for new items to be added to the queue.Iterator
is a generator function that will continue to produce jobs until the iterator is exhausted.Below is a pool that will convert images on demand, while queuing as needed.
class ImageProcessor {
active = false;
proc: ChildProcess;
kill() {
this.proc.kill();
}
async convert(path: string) {
this.active = true;
try {
this.proc = ...convert ...
await this.proc;
} catch (e) {
}
this.active = false;
}
}
class ImageCompressor {
pendingImages: QueueDataSource<string>;
pool = new ConcurrentPool(async () => {
return new ImageProcessor();
});
constructor() {
this.pool.process(this.pendingImages, async (inp, exe) => {
exe.convert(inp);
});
}
convert(...images: string[]) {
for (const img of images) {
this.pendingImages.enqueue(img);
}
}
}
FAQs
Worker pool logic with constructs for concurrency management
The npm package @travetto/pool receives a total of 1 weekly downloads. As such, @travetto/pool popularity was classified as not popular.
We found that @travetto/pool demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.