How to use is-generator-function - 4 common examples

To help you get started, we’ve selected a few is-generator-function examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bodil / eulalie / src / index.js View on Github external
function isGen(v) {
  try {
    if (regeneratorRuntime) {
      /* global regeneratorRuntime */
      return regeneratorRuntime.isGeneratorFunction(v);
    }
  } catch(e) {
    return isGeneratorFunction(v);
  }
}
github 51nb / miox / src / miox / src / miox_modules / middleware.js View on Github external
use(...args) {
        args = flatten(args);
        const result = [];
        for (let i = 0; i < args.length; i++) {
            let cb = args[i];
            if (typeof cb !== 'function') {
                throw new Error(
                    'middleware must be a function ' +
                    'but got ' + typeof cb
                );
            }

            // runtime convert generator function to ...
            if (isGeneratorFunction(cb)) {
                cb = convert(cb);
            }

            result.push(cb);
        }
        this.middlewares.push.apply(this.middlewares, result);
        return this;
    }
github haozi23333 / kuQforNodeJSPlugin / src / route.js View on Github external
reg(path,fn,opts={}){
        if(!path)
            throw Error('path must be existed')
        if(!fn)
            throw Error('callback must be a function')
        if(isGeneratorFunction(fn)){
            fn = convert(fn)
        }
        opts = opts || {}

        let r = {
            regexp : pathToRegexp(path),
            fn : fn,
            prefix:this.opts.prefix||'/'
        }
        this.m.push(r)
        return this
    }
github haozi23333 / kuQforNodeJSPlugin / src / client.js View on Github external
use(fn){
        if (typeof fn !== 'function') throw new TypeError('middleware must be a function!');
        if(isGeneratorFunction(fn)){
            fn = convert(fn)
        }
        this.middlewares.push(fn)
        return this
    }
    callback(){

is-generator-function

Determine if a function is a native generator function.

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis

Popular is-generator-function functions