Skip to content

Commit 390fdd6

Browse files
Refactored isGeneratorFn to avoid using function name;
1 parent 2a47de4 commit 390fdd6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: lib/use-async-effect.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ const {E_REASON_QUEUE_OVERFLOW, E_REASON_RESTART} = CanceledError.registerErrors
77
E_REASON_RESTART: 'restarted'
88
})
99

10-
const isGeneratorFn = (thing) => typeof thing === 'function' &&
11-
thing.constructor &&
12-
thing.constructor.name === 'GeneratorFunction';
10+
function isGeneratorFn(thing) {
11+
return typeof thing === 'function' && thing[Symbol.toStringTag] === 'GeneratorFunction';
12+
}
1313

1414
const isEvent = (thing) => !!(thing && typeof thing === 'object' && thing.type);
1515

0 commit comments

Comments
 (0)