format: apply repo prettier (3.8.1) to the folded skills tree
963 markdown files reformatted with the repository's pinned prettier so pnpm format:check covers the folded tree like every other repo file. The formatter's embedded-language pass also normalized code fences (TS semicolons, closed HTML tags in examples, lowercased CSS hex colors, one renumbered list that skipped an index). Alphanumeric token deltas vs the fold commit were audited file-by-file; all are formatter-equivalent markup normalizations plus the four sanitized skills.
This commit is contained in:
@@ -9,45 +9,45 @@ Executes each asynchronous task sequentially and passes the current task result
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import { useAsyncQueue } from '@vueuse/core'
|
||||
import { useAsyncQueue } from '@vueuse/core';
|
||||
|
||||
function p1() {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
resolve(1000)
|
||||
}, 10)
|
||||
})
|
||||
resolve(1000);
|
||||
}, 10);
|
||||
});
|
||||
}
|
||||
|
||||
function p2(result: number) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
resolve(1000 + result)
|
||||
}, 20)
|
||||
})
|
||||
resolve(1000 + result);
|
||||
}, 20);
|
||||
});
|
||||
}
|
||||
|
||||
const { activeIndex, result } = useAsyncQueue([p1, p2])
|
||||
const { activeIndex, result } = useAsyncQueue([p1, p2]);
|
||||
|
||||
console.log(activeIndex.value) // current pending task index
|
||||
console.log(activeIndex.value); // current pending task index
|
||||
|
||||
console.log(result) // the tasks result
|
||||
console.log(result); // the tasks result
|
||||
```
|
||||
|
||||
## Type Declarations
|
||||
|
||||
```ts
|
||||
export type UseAsyncQueueTask<T> = (...args: any[]) => T | Promise<T>
|
||||
export type UseAsyncQueueTask<T> = (...args: any[]) => T | Promise<T>;
|
||||
type MapQueueTask<T extends any[]> = {
|
||||
[K in keyof T]: UseAsyncQueueTask<T[K]>
|
||||
}
|
||||
[K in keyof T]: UseAsyncQueueTask<T[K]>;
|
||||
};
|
||||
export interface UseAsyncQueueResult<T> {
|
||||
state: "aborted" | "fulfilled" | "pending" | "rejected"
|
||||
data: T | null
|
||||
state: 'aborted' | 'fulfilled' | 'pending' | 'rejected';
|
||||
data: T | null;
|
||||
}
|
||||
export interface UseAsyncQueueReturn<T> {
|
||||
activeIndex: ShallowRef<number>
|
||||
result: T
|
||||
activeIndex: ShallowRef<number>;
|
||||
result: T;
|
||||
}
|
||||
export interface UseAsyncQueueOptions {
|
||||
/**
|
||||
@@ -55,21 +55,21 @@ export interface UseAsyncQueueOptions {
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
interrupt?: boolean
|
||||
interrupt?: boolean;
|
||||
/**
|
||||
* Trigger it when the tasks fails.
|
||||
*
|
||||
*/
|
||||
onError?: () => void
|
||||
onError?: () => void;
|
||||
/**
|
||||
* Trigger it when the tasks ends.
|
||||
*
|
||||
*/
|
||||
onFinished?: () => void
|
||||
onFinished?: () => void;
|
||||
/**
|
||||
* A AbortSignal that can be used to abort the task.
|
||||
*/
|
||||
signal?: AbortSignal
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
/**
|
||||
* Asynchronous queue task controller.
|
||||
@@ -82,6 +82,6 @@ export declare function useAsyncQueue<T extends any[], S = MapQueueTask<T>>(
|
||||
tasks: S & Array<UseAsyncQueueTask<any>>,
|
||||
options?: UseAsyncQueueOptions,
|
||||
): UseAsyncQueueReturn<{
|
||||
[P in keyof T]: UseAsyncQueueResult<T[P]>
|
||||
}>
|
||||
[P in keyof T]: UseAsyncQueueResult<T[P]>;
|
||||
}>;
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user