Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add default export for mapAsyncIterator #3247

Closed
wants to merge 1 commit into from

Conversation

n1ru4l
Copy link
Contributor

@n1ru4l n1ru4l commented Aug 27, 2021

Previously the mapAsyncIterator function could be imported via

import mapAsyncIterator from 'graphql/subscription/mapAsyncIterator.js';

but the export was changed to import { mapAsyncIterator } from 'graphql/subscription/mapAsyncIterator.js';

Could we still have a default export for having easy backward compatibility without having to inline the function into our libraries?

@n1ru4l n1ru4l mentioned this pull request Aug 27, 2021
@n1ru4l
Copy link
Contributor Author

n1ru4l commented Aug 27, 2021

Using this instead (we already had that helper):

export async function* mapAsyncIterator<TInput, TOutput = TInput>(
  asyncIterable: AsyncGenerator<TInput, void, void> | AsyncIterable<TInput>,
  map: (input: TInput) => Promise<TOutput> | TOutput
): AsyncGenerator<TOutput, void, void> {
  for await (const value of asyncIterable) {
    yield map(value);
  }
}

@n1ru4l n1ru4l closed this Aug 27, 2021
@n1ru4l n1ru4l deleted the fix-map-async-iterator-export branch August 27, 2021 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant