UNPKG

recoder-code

Version:

🚀 AI-powered development platform - Chat with 32+ models, build projects, automate workflows. Free models included!

27 lines (26 loc) • 1.08 kB
import { checkExceptions, createWaiter, WaiterState } from "@smithy/util-waiter"; import { HeadBucketCommand } from "../commands/HeadBucketCommand"; const checkState = async (client, input) => { let reason; try { const result = await client.send(new HeadBucketCommand(input)); reason = result; return { state: WaiterState.SUCCESS, reason }; } catch (exception) { reason = exception; if (exception.name && exception.name == "NotFound") { return { state: WaiterState.RETRY, reason }; } } return { state: WaiterState.RETRY, reason }; }; export const waitForBucketExists = async (params, input) => { const serviceDefaults = { minDelay: 5, maxDelay: 120 }; return createWaiter({ ...serviceDefaults, ...params }, input, checkState); }; export const waitUntilBucketExists = async (params, input) => { const serviceDefaults = { minDelay: 5, maxDelay: 120 }; const result = await createWaiter({ ...serviceDefaults, ...params }, input, checkState); return checkExceptions(result); };