throttle & retry: use default profile 🐛

This commit is contained in:
Jannis R 2020-01-14 23:56:03 +01:00
parent 42b2a8a7bf
commit 51b1e68ddd
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
2 changed files with 6 additions and 2 deletions

View file

@ -1,6 +1,7 @@
'use strict'
const retry = require('p-retry')
const defaultProfile = require('./lib/default-profile')
const retryDefaults = {
retries: 3,
@ -10,7 +11,8 @@ const retryDefaults = {
const withRetrying = (profile, retryOpts = {}) => {
retryOpts = Object.assign({}, retryDefaults, retryOpts)
const {request} = profile
// https://github.com/public-transport/hafas-client/issues/76#issuecomment-574408717
const {request} = {...defaultProfile, ...profile}
const retryingRequest = (...args) => {
const attempt = () => {

View file

@ -1,9 +1,11 @@
'use strict'
const throttle = require('p-throttle')
const defaultProfile = require('./lib/default-profile')
const withThrottling = (profile, limit = 5, interval = 1000) => {
const {request} = profile
// https://github.com/public-transport/hafas-client/issues/76#issuecomment-574408717
const {request} = {...defaultProfile, ...profile}
return {
...profile,