Skip to content

Commit 242ba01

Browse files
committed
Rename wait parameter maxAttempts to max_attempts
1 parent 7c3bd45 commit 242ba01

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

index.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ declare module 'replicate' {
8585
identifier: `${string}/${string}:${string}`,
8686
options: {
8787
input: object;
88-
wait?: boolean | { interval?: number; maxAttempts?: number };
88+
wait?: { interval?: number; max_attempts?: number };
8989
webhook?: string;
9090
webhook_events_filter?: WebhookEventType[];
9191
}
@@ -99,11 +99,12 @@ declare module 'replicate' {
9999
}): Promise<Response>;
100100

101101
paginate<T>(endpoint: () => Promise<Page<T>>): AsyncGenerator<[ T ]>;
102+
102103
wait(
103104
prediction: Prediction,
104105
options: {
105106
interval?: number;
106-
maxAttempts?: number;
107+
max_attempts?: number;
107108
}
108109
): Promise<Prediction>;
109110

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class Replicate {
218218
* @param {object} prediction - Prediction object
219219
* @param {object} options - Options
220220
* @param {number} [options.interval] - Polling interval in milliseconds. Defaults to 250
221-
* @param {number} [options.maxAttempts] - Maximum number of polling attempts. Defaults to no limit
221+
* @param {number} [options.max_attempts] - Maximum number of polling attempts. Defaults to no limit
222222
* @throws {Error} If the prediction doesn't complete within the maximum number of attempts
223223
* @throws {Error} If the prediction failed
224224
* @returns {Promise<object>} Resolves with the completed prediction object
@@ -244,17 +244,17 @@ class Replicate {
244244

245245
let attempts = 0;
246246
const interval = options.interval || 250;
247-
const maxAttempts = options.maxAttempts || null;
247+
const max_attempts = options.max_attempts || null;
248248

249249
while (
250250
updatedPrediction.status !== 'succeeded' &&
251251
updatedPrediction.status !== 'failed' &&
252252
updatedPrediction.status !== 'canceled'
253253
) {
254254
attempts += 1;
255-
if (maxAttempts && attempts > maxAttempts) {
255+
if (max_attempts && attempts > max_attempts) {
256256
throw new Error(
257-
`Prediction ${id} did not finish after ${maxAttempts} attempts`
257+
`Prediction ${id} did not finish after ${max_attempts} attempts`
258258
);
259259
}
260260

0 commit comments

Comments
 (0)