
Security News
The Next Open Source Security Race: Triage at Machine Speed
Claude Opus 4.6 has uncovered more than 500 open source vulnerabilities, raising new considerations for disclosure, triage, and patching at scale.
request-state-wrapper
Advanced tools
A simple wrapper for Asynchronous JavaScript requests that allows you to detect stalled, fetching and finished states.
What is the point of this tool? Read Better loading states for the modern web.
import { createRequest } from 'request-state-wrapper';
// Create your smart request
const request = createRequest({
request: [<Promise>], // Array of Promises
stalledDelay: Number, // Time in MS before we consider a request stalled
onStateChange: Function, // Callback executed every time request state changes
});
// run it!
request();
// Before
// Set our loading state
loading = true
// Start our asyncronous request/s
Promise.all([asyncRequest(), anotherAsyncRequest()]).then(payload => {
// When it's finished, set loading state to false
loading = false
// Then handle the response
if(payload.error) // show error screen
// show success screen
});
// After
import { createRequest } from 'request-state-wrapper';
const getData = createRequest({
request: [asyncRequest, anotherAsyncRequest],
stalledDelay: 250,
onStateChange: state => { ... },
})
getData().then(payload => console.log(payload));
With async/await
// Before
async function requests () {
const payload = await Promise.all[asyncRequest(), anotherAsyncRequest()];
console.log(payload);
}
// After
import { createRequest } from 'request-state-wrapper';
const getData = createRequest({
request: [asyncRequest, anotherAsyncRequest],
stalledDelay: 250,
onStateChange: state => { ... },
})
const data = await getData();
Add a specific handler for each type of event:
import { createRequest } from 'request-state-wrapper';
const getData = createRequest({
request: [asyncRequest(), anotherAsyncRequest()],
stalledDelay: 250,
onFetching: state => { ... },
onStalled: state => { ... },
onFinished: state => { ... },
})
Note, specific handler will override onStateChange().
Create your request, and add/override handlers when you run the request:
import { createRequest } from 'request-state-wrapper';
const getData = createRequest({
request: [asyncRequest(), anotherAsyncRequest()],
stalledDelay: 250,
})
const data = await getData({ onStateChange: state => { ... } });
Want some more examples? Check out some demo recipes:
Simple UI with React Simple UI with React Hooks NodeJS server
FAQs
A tiny package for managing the state of asynchronous requests.
The npm package request-state-wrapper receives a total of 0 weekly downloads. As such, request-state-wrapper popularity was classified as not popular.
We found that request-state-wrapper 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
Claude Opus 4.6 has uncovered more than 500 open source vulnerabilities, raising new considerations for disclosure, triage, and patching at scale.

Research
/Security News
Malicious dYdX client packages were published to npm and PyPI after a maintainer compromise, enabling wallet credential theft and remote code execution.

Security News
gem.coop is testing registry-level dependency cooldowns to limit exposure during the brief window when malicious gems are most likely to spread.