Skip to content
Snippets Groups Projects
Commit 17114178 authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt :koala:
Browse files

feat: add useArray function

This is helpful when dealing with iterator objects.
parent 7e8271b0
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ import {
computed,
ComputedGetter,
ComputedRef,
DebuggerOptions,
MaybeRefOrGetter,
readonly,
Ref,
......@@ -429,6 +430,13 @@ export async function fromAsync<T>(iterable: AsyncIterable<T>): Promise<T[]> {
return result
}
export function useArray<T>(
iterable: MaybeRefOrGetter<Iterable<T>>,
debugOptions?: DebuggerOptions,
) {
return computed(() => Array.from(toValue(iterable)), debugOptions)
}
export function ensureError(error: unknown) {
return error instanceof Error ? error : new Error(String(error))
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment