export async function convertReadableStreamToArray<T>(
  stream: ReadableStream<T>,
): Promise<T[]> {
  const reader = stream.getReader();
  const result: T[] = [];

  while (true) {
    const { done, value } = await reader.read();
    if (done) break;
    result.push(value);
  }

  return result;
}
