Collection of convenience code snippets (helpers) that aims to make it a little easier to work with vanilla JS
vanillajs-helpers > “isGenerator”
► isGenerator(obj: any
): boolean
Defined in isGenerator.ts:39
Determine if the given object is a Generator Function
function* gen() {}
isGeneratorLike(gen); // -> true
isGeneratorLike(() => {}); // -> false
Parameters:
Param | Type | Description |
---|---|---|
obj | any |
Object to test |
Returns: boolean
► isGeneratorLike(obj: any
): boolean
Defined in isGenerator.ts:20
Determine if the given object is a Generator(ish) object
function* gen() {}
isGeneratorLike(gen); // -> true
isGeneratorLike({ next() {}, throw() {} }); // -> true
isGeneratorLike(() => {}); // -> false
Parameters:
Param | Type | Description |
---|---|---|
obj | any |
Object to test |
Returns: boolean