
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
@dadajam4/async-combiner
Advanced tools
Service that combines multiple asynchronous requests into one
Service that combines multiple asynchronous requests into one
It was troublesome to implement each project individually to solve the following problems when creating the front-end screen, so I wanted to solve it (I want to make a method that can be used in common).
npm install @dadajam4/async-combiner --save
//
// Class base syntax
//
import { AsyncCombiner } from '@dadajam4/async-combiner';
class SomeClass extends AsyncCombiner {
constructor(someValue1, someValue2) {
super();
this.someValue1 = someValue1;
this.someValue2 = someValue2;
}
someHeavyAsyncFunc(url, query) {
const condition = [url, query];
return this.$asyncCombine(condition, () => this._func(url, query));
}
_someHeavyAsyncFuncExecutor(url, query) {
/**
* @see: https://github.com/axios/axios
*/
return axios.get(url, { params: query });
}
}
import { Combine } from '@dadajam4/async-combiner';
class SomeClass {
// Of course you can also use `class extends`
@Combine()
someHeavyAsyncFunc(url, query) {
/**
* @see: https://github.com/axios/axios
*/
return axios.get(url, { params: query });
}
}
Logic that uses the mechanism of this library should always match the response to the input parameters.
Do not use it for things like get requests that change frequently over time.
Inside the library, the parameters passed to the method are stored as a "condition object", and all requests of the same condition that are triggered before the processing is completed are combined into one execution.
When using the decorator, the parameters passed to the method are automatically converted into a condition object for convenience, but you may want to customize this depending on the condition of the parameter.
You can delay the execution of asynchronous processing if necessary. This feature can significantly reduce the backend service load, depending on the system load.
See the documentation for individual parameter settings.
AbortController, but I think it is important that it can work with NodeJS as it is, so I would like to think of a way to solve this well.FAQs
Service that combines multiple asynchronous requests into one
We found that @dadajam4/async-combiner 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.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.