Converting AsyncIterableIterator to Array within Effect Type

Hello! I have a pipe that resolves to a AsyncIterableIterator at a certain point, and I'm trying to turn that iterator into a simple array. I have a function that you can pass an AsyncIterableIterator to, and it returns a Promise that resolves to an array of the items.

The following code works, but the return type is Promise<(FileSystemDirectoryHandle | FileSystemFileHandle)[]> instead of just (FileSystemDirectoryHandle | FileSystemFileHandle)[]:

// This is what I want:
// readDirEffect(path: string): Effect.Effect<Promise<(FileSystemDirectoryHandle | FileSystemFileHandle)[]>, SomeError> {
// This is what I'm currently getting
readDirEffect(path: string): Effect.Effect<(FileSystemDirectoryHandle | FileSystemFileHandle)[], SomeError> {
    return pipe(
        getData(), // This returns something like Effect.Effect<AsyncIterableIterator, SomeError, never>
        Effect.map(a => asyncIterToArr(a)),
    );
}


The docs had some examples where Promises were involved but didn't appear in the type signature, which is what I'm trying to do here, but I don't know how to pull it off.

Apologies if that was a bad explanation, I'm still trying to wrap my head around Effect.
Was this page helpful?