mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 23:29:35 +02:00
15 lines
435 B
JavaScript
15 lines
435 B
JavaScript
'use strict'
|
|
|
|
const throttle = require('p-throttle')
|
|
|
|
const _request = require('./lib/request')
|
|
|
|
const withThrottling = (createClient, limit = 5, interval = 1000) => {
|
|
const createThrottledClient = (profile, userAgent, request = _request) => {
|
|
const throttledRequest = throttle(request, limit, interval)
|
|
return createClient(profile, userAgent, throttledRequest)
|
|
}
|
|
return createThrottledClient
|
|
}
|
|
|
|
module.exports = withThrottling
|