UNPKG

@aws-amplify/graphql-api-construct

Version:

AppSync GraphQL Api Construct using Amplify GraphQL Transformer.

29 lines (28 loc) 832 B
export const readableStreamtoIterable = (readableStream) => ({ [Symbol.asyncIterator]: async function* () { const reader = readableStream.getReader(); try { while (true) { const { done, value } = await reader.read(); if (done) return; yield value; } } finally { reader.releaseLock(); } }, }); export const iterableToReadableStream = (asyncIterable) => { const iterator = asyncIterable[Symbol.asyncIterator](); return new ReadableStream({ async pull(controller) { const { done, value } = await iterator.next(); if (done) { return controller.close(); } controller.enqueue(value); }, }); };