-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support returning async iterables from resolver functions
- Loading branch information
1 parent
6012d28
commit 08acc44
Showing
6 changed files
with
193 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// @flow strict | ||
|
||
import { SYMBOL_ASYNC_ITERATOR } from '../polyfills/symbols'; | ||
|
||
/** | ||
* Returns true if the provided object implements the AsyncIterator protocol via | ||
* either implementing a `Symbol.asyncIterator` or `"@@asyncIterator"` method. | ||
*/ | ||
declare function isAsyncIterable(value: mixed): boolean %checks(value instanceof | ||
AsyncIterable); | ||
|
||
// eslint-disable-next-line no-redeclare | ||
export default function isAsyncIterable(maybeAsyncIterable) { | ||
if (maybeAsyncIterable == null || typeof maybeAsyncIterable !== 'object') { | ||
return false; | ||
} | ||
|
||
return typeof maybeAsyncIterable[SYMBOL_ASYNC_ITERATOR] === 'function'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters