Generator Support

Detect native generator function support.

Usage

var hasGeneratorSupport = require( '@stdlib/utils/detect-generator-support' );

hasGeneratorSupport()

Detects if a runtime environment supports ES2015 generator functions, i.e. function*().

var bool = hasGeneratorSupport();
// returns <boolean>

Notes

  • The implementation uses code evaluation, which may be problematic in browser contexts enforcing a strict content security policy (CSP).

Examples

var hasGeneratorSupport = require( '@stdlib/utils/detect-generator-support' );

var bool = hasGeneratorSupport();
if ( bool ) {
    console.log( 'Environment has native generator function support.' );
} else {
    console.log( 'Environment lacks native generator function support.' );
}

CLI

Usage

Usage: hasgenerators [options]

Options:

  -h,    --help                Print this message.
  -V,    --version             Print the package version.

Examples

$ hasgenerators
<boolean>