https://github.com/madeindjs/promise-queue-return
A simple plain-JavaScript promise queue that might help you to avoid rate-limiting. This one use an handy API that returns the result of your function
https://github.com/madeindjs/promise-queue-return
Last synced: 3 months ago
JSON representation
A simple plain-JavaScript promise queue that might help you to avoid rate-limiting. This one use an handy API that returns the result of your function
- Host: GitHub
- URL: https://github.com/madeindjs/promise-queue-return
- Owner: madeindjs
- Created: 2025-05-08T22:20:45.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-05-08T22:44:23.000Z (about 1 year ago)
- Last Synced: 2025-06-10T05:04:00.842Z (12 months ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# promise-queue-return
[](https://badge.fury.io/js/promise-queue-return)
A simple plain-JavaScript promise queue that helps you to avoid rate-limiting. This one uses a handy API that returns the result of your function.
```js
import { PromiseQueue } from "promise-queue-return";
const queue = new PromiseQueue();
queue.onJobExecuted = async (job) => {
console.log(`Executed job id=${job.id}, waiting 1s`);
await new Promise((res) => setTimeout(res, 1_000));
};
async function fetchWeather() {
const res = await fetch(
"https://api.open-meteo.com/v1/forecast?latitude=52.52&longitude=13.41¤t=temperature_2m",
);
if (!res.ok) throw Error("API error");
return res.json();
}
while (true) {
const weather = await queue.add(fetchWeather);
console.log(weather);
}
```