UNPKG

@sanity/migrate

Version:

Tooling for running data migrations on Sanity.io projects

18 lines (16 loc) 399 B
export async function* streamToAsyncIterator<T>(stream: ReadableStream<T>) { // Get a lock on the stream const reader = stream.getReader() try { while (true) { // Read from the stream const {done, value} = await reader.read() // Exit if we're done if (done) return // Else yield the chunk yield value } } finally { reader.releaseLock() } }