db-vendo-client/throttle.js
Kristjan ESPERANTO 66d9fb5194
apply linting rules
follow-up of 228c7253
2024-02-10 16:50:12 +01:00

16 lines
408 B
JavaScript

import throttle from 'p-throttle';
import {defaultProfile} from './lib/default-profile.js';
const withThrottling = (profile, limit = 5, interval = 1000) => {
// https://github.com/public-transport/hafas-client/issues/76#issuecomment-574408717
const {request} = {...defaultProfile, ...profile};
return {
...profile,
request: throttle({limit, interval})(request),
};
};
export {
withThrottling,
};