// sink/to-string.ts /* * Copyright (c) 2021-2026 Check Digit, LLC * * This code is licensed under the MIT license (see LICENSE.txt for details). */ import asyncerator, { type Asyncable } from '../asyncerator.ts'; /** * Turn an async iterable iterator into a string. * This will wait until the iterator is done before returning, so be careful using this * with endless iterators (in other words, don't do that). */ export default async function (iterator: Asyncable): Promise { let result = ''; for await (const chunk of asyncerator(iterator)) { result += chunk; } return result; }