@26brains/throttled-queue-decorator 中文文档教程
Throttled Queue Decorator
Install
npm i @26brains/throttled-queue-decorator
Usage
const { createThrottle } = require('throttled-queue-decorator');
const throttle = createThrottle(2, 1000); // 2 requests per 1000 milliseconds
const func = (id) => axios.get(`http://example.com/record/${id}`);
const throttledFunc = throttle(func);
const main = async () => {
return await Promise.all([
throttledFunc(1),
throttledFunc(2),
throttledFunc(3),
])
}
//third request will be delayed by 1 second
main();
Tests
npm test
Example
node example/example.js
Credits
单个setTimeout()
的使用代码> 从 https://github.com/shaunpersad/throttled-queue 复制的事件。
Throttled Queue Decorator
Install
npm i @26brains/throttled-queue-decorator
Usage
const { createThrottle } = require('throttled-queue-decorator');
const throttle = createThrottle(2, 1000); // 2 requests per 1000 milliseconds
const func = (id) => axios.get(`http://example.com/record/${id}`);
const throttledFunc = throttle(func);
const main = async () => {
return await Promise.all([
throttledFunc(1),
throttledFunc(2),
throttledFunc(3),
])
}
//third request will be delayed by 1 second
main();
Tests
npm test
Example
node example/example.js
Credits
Use of single setTimeout()
event copied from https://github.com/shaunpersad/throttled-queue.
更多
你可能也喜欢
- 3dtilesdownloader 中文文档教程
- @01jam/forge-ui 中文文档教程
- @128technology/ui 中文文档教程
- @12stonechurch/react-native-video-controls 中文文档教程
- @365werk/threesixfive-vue-library 中文文档教程
- @5stones/nest-oidc 中文文档教程
- @6thquake/react-material 中文文档教程
- @aads/lambda-logger 中文文档教程
- @aarondewes/wp-prettier-config 中文文档教程
- @abhiputulshek/deltasortable 中文文档教程