-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use isPromise/etc function from utils (#2925)
Includes improvements to detection from #2918 --------- Signed-off-by: Sacha Froment <[email protected]> Co-authored-by: Sacha Froment <[email protected]>
- Loading branch information
1 parent
15a70af
commit a32fbeb
Showing
4 changed files
with
21 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
export function isGenerator (obj: unknown): obj is Generator { | ||
if (obj == null) return false | ||
if (obj == null) { | ||
return false | ||
} | ||
|
||
const iterator = (obj as { [Symbol.iterator]?: unknown })?.[Symbol.iterator] | ||
if (typeof iterator !== 'function') return false | ||
|
||
if (typeof iterator !== 'function') { | ||
return false | ||
} | ||
|
||
const instance = obj as { next?: unknown } | ||
|
||
return typeof instance.next === 'function' | ||
} |