@revolugo/booking-api-client
Advanced tools
Comparing version 1.1.1-beta.0 to 1.1.2-beta.0
@@ -16,3 +16,3 @@ export interface IPollerResponse { | ||
callCount?: number; | ||
delay?: number; | ||
interval?: number; | ||
maxCallCount?: number; | ||
@@ -19,0 +19,0 @@ request: TPollerRequestCallback<Partial<U>>; |
@@ -6,2 +6,3 @@ "use strict"; | ||
const case_transformers_1 = require("./utils/case-transformers"); | ||
const INTERVAL = 1000; | ||
class Poller { | ||
@@ -11,2 +12,3 @@ constructor() { | ||
callCount: 1, | ||
interval: INTERVAL, | ||
maxCallCount: 10 | ||
@@ -51,3 +53,3 @@ }; | ||
} | ||
if (options.delay) { | ||
if (options.interval) { | ||
await this.pause(options); | ||
@@ -102,3 +104,3 @@ } | ||
pause(options) { | ||
return new Promise(resolve => setTimeout(resolve, options.delay)); | ||
return new Promise(resolve => setTimeout(resolve, options.interval)); | ||
} | ||
@@ -105,0 +107,0 @@ removeCurrentPolling(options) { |
@@ -33,3 +33,3 @@ { | ||
"types": "build/index.d.ts", | ||
"version": "1.1.1-beta.0" | ||
"version": "1.1.2-beta.0" | ||
} |
@@ -20,5 +20,7 @@ import { v4 as uuidv4 } from 'uuid' | ||
const INTERVAL = 1000 | ||
export interface IPollerOptions<U> { | ||
callCount?: number, | ||
delay?: number, | ||
interval?: number, | ||
maxCallCount?: number, | ||
@@ -35,2 +37,3 @@ request: TPollerRequestCallback<Partial<U>>, | ||
callCount: 1, | ||
interval: INTERVAL, | ||
maxCallCount: 10 | ||
@@ -87,3 +90,3 @@ } | ||
if (options.delay) { | ||
if (options.interval) { | ||
await this.pause(options) | ||
@@ -145,3 +148,3 @@ } | ||
private pause (options: TOptions<V>): Promise<void> { | ||
return new Promise(resolve => setTimeout(resolve, options.delay)) | ||
return new Promise(resolve => setTimeout(resolve, options.interval)) | ||
} | ||
@@ -148,0 +151,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1108995
21665