Download internal/node-utils/src/spinner.ts from binhugg3/admin: direct link, hf CLI and curl.
- Browser
- Download file 541 Bytes
-
https://huggingface.co/spaces/binhugg3/admin/resolve/main/internal/node-utils/src/spinner.ts
- Command line
-
hf download hf://spaces/binhugg3/admin/internal/node-utils/src/spinner.ts
-
curl -L -o spinner.ts https://huggingface.co/spaces/binhugg3/admin/resolve/main/internal/node-utils/src/spinner.ts
541 Bytes
| import ora, { type Ora } from 'ora'; | |
| interface SpinnerOptions { | |
| failedText?: string; | |
| successText?: string; | |
| title: string; | |
| } | |
| export async function spinner<T>( | |
| { failedText, successText, title }: SpinnerOptions, | |
| callback: () => Promise<T>, | |
| ): Promise<T> { | |
| const loading: Ora = ora(title).start(); | |
| try { | |
| const result = await callback(); | |
| loading.succeed(successText || 'Success!'); | |
| return result; | |
| } catch (error) { | |
| loading.fail(failedText || 'Failed!'); | |
| throw error; | |
| } finally { | |
| loading.stop(); | |
| } | |
| } | |