封装factory function
488110
function (cb) {
            debuglog('start load plugin [%s]', name);
            var realFactory = factory[factory.length - 1];
            // 将defaultConf转移至真实factory
            realFactory.defaultConf = factory.defaultConf;
            runFactory(realFactory, function () {
                clearTimeout(depsLoadTimeout);
                depsLoadTimeout = null;
                cb && cb();
            });
        }
889769
function visitDefine(traverse, node, path, state) {

        // 获取 define 语句中的最后一个参数，一般为 factory
        var factory = node.arguments[node.arguments.length - 1];
        var deps;
        var elements;

        utils.catchup(node.range[0], state);

        // 如果是 factory function
        if (factory.type === Syntax.FunctionExpression) {
            var body = factory.body.body;
            deps = node.arguments[node.arguments.length - 2];

            if (deps && deps.type === Syntax.ArrayExpression) {
                elements = deps.elements;
                var params = factory.params;

                elements.forEach(function (element, index) {
                    if (params[index]) {
                        utils.append('var ', state);
                        utils.move(params[index].range[0], state);
                        utils.catchup(params[index].range[1], state);
                        utils.append(' = ', state);
                    }

                    utils.append('require(', state);
                    utils.move(element.range[0], state);
                    utils.catchup(element.range[1], state);
                    utils.append(');\n', state);
                });
            }

            utils.move(body[0].range[0], state);
            path.unshift(node);
            body.forEach(function (node) {
                utils.catchup(node.range[0], state);
                path.unshift(node);
                traverse(node, path, state);
                path.shift();
            });
            path.shift();
            utils.move(node.range[1], state);
        }

        // 如果最后一个参数是对象。
        else if (factory.type === Syntax.ObjectExpression
            || factory.type === Syntax.Literal) {
            utils.append('module.exports = ', state);
            utils.move(factory.range[0], state);
            utils.catchup(factory.range[1], state);
            utils.move(node.range[1], state);
        }

        // 如果最后一个参数是变量
        else if (factory.type === Syntax.Identifier) {
            utils.append('module.exports = typeof ' + factory.name, state);
            utils.append(' === \'function\' ? ', state);

            utils.append(factory.name + '(', state);

            deps = node.arguments[node.arguments.length - 2];
            if (deps && deps.type === Syntax.ArrayExpression) {
                elements = deps.elements;

                utils.append(elements.map(function (element) {
                    return 'require("' + element.value + '")';
                }).join(', '), state);
            }

            utils.append(')', state);

            utils.append(' : ', state);
            utils.move(factory.range[0], state);
            utils.catchup(factory.range[1], state);


            utils.move(node.range[1], state);
        }

        return false;
    }
490645
function modAnalyse() {
        var requireModules = [];
        var requireModulesIndex = {};

        /**
         * 添加需要请求的模块
         *
         * @inner
         * @param {string} id 模块id
         */
        function addRequireModule( id ) {
            if ( modModules[ id ] || requireModulesIndex[ id ] ) {
                return;
            }

            requireModules.push( id );
            requireModulesIndex[ id ] = 1;
        }

        each( modModuleList, function ( module ) {
            if ( module.state > MODULE_PRE_DEFINED ) {
                return;
            }

            var deps = module.deps;
            var hardDependsCount = 0;
            var factory = module.factory;

            // 分析function body中的require
            // 如果包含显式依赖声明，根据AMD规定和性能考虑，可以不分析factoryBody
            if ( typeof factory === 'function' ) {
                hardDependsCount = Math.min( factory.length, deps.length );

                // If the dependencies argument is present, the module loader
                // SHOULD NOT scan for dependencies within the factory function.
                !module.depsDec && factory.toString()
                    .replace( /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, '' )
                    .replace( /require\(\s*(['"'])([^'"]+)\1\s*\)/g,
                        function ( $0, $1, depId ) {
                            deps.push( depId );
                        }
                    );
            }

            each( deps, function ( depId, index ) {
                var idInfo = parseId( depId );
                var absId = normalize( idInfo.module, module.id );
                var moduleInfo, resInfo;

                if ( absId && !BUILDIN_MODULE[ absId ] ) {
                    // 如果依赖是一个资源，将其信息添加到module.depRs
                    //
                    // module.depRs中的项有可能是重复的。
                    // 在这个阶段，加载resource的module可能还未defined，
                    // 导致此时resource id无法被normalize。
                    //
                    // 比如对a/b/c而言，下面几个resource可能指的是同一个资源：
                    // - js!../name.js
                    // - js!a/name.js
                    // - ../../js!../name.js
                    //
                    // 所以加载资源的module ready时，需要遍历module.depRs进行处理
                    if ( idInfo.resource ) {
                        resInfo = {
                            id       : depId,
                            module   : absId,
                            resource : idInfo.resource
                        };
                        autoDefineModules[ absId ] = 1;
                        module.depPMs.push( absId );
                        module.depRs.push( resInfo );
                    }

                    // 对依赖模块的id normalize能保证正确性，在此处进行去重
                    moduleInfo = module.depMkv[ absId ];
                    if ( !moduleInfo ) {
                        moduleInfo = {
                            id      : idInfo.module,
                            absId   : absId,
                            hard    : index < hardDependsCount
                        };
                        module.depMs.push( moduleInfo );
                        module.depMkv[ absId ] = moduleInfo;
                        addRequireModule( absId );
                    }
                }
                else {
                    moduleInfo = { absId: absId };
                }

                // 如果当前正在分析的依赖项是define中声明的，
                // 则记录到module.factoryDeps中
                // 在factory invoke前将用于生成invoke arguments
                if ( index < hardDependsCount ) {
                    module.factoryDeps.push( resInfo || moduleInfo );
                }
            } );

            module.state = MODULE_ANALYZED;
            modInitFactoryInvoker( module.id );
        });

        modAutoInvoke();
        nativeRequire( requireModules );
    }
464208
function factory(options) {
    assert.optionalObject(options, 'options');

    var opts = _.assign({
        topLevelFields: false
    }, options);

    var serializer = new ErrorSerializer(opts);
    // rebind the serialize function since this will be lost when we export it
    // as a POJO
    serializer.serialize = serializer.serialize.bind(serializer);

    return serializer;
}
3416
def factory(cls, object_source):
        
        if object_source.type is ObjectRaw.Types.object:
            return ObjectObject(object_source)
        elif object_source.type not in ObjectRaw.Types or object_source.type is ObjectRaw.Types.type:
            return ObjectType(object_source)
        elif object_source.type is ObjectRaw.Types.array:
            return ObjectArray(object_source)
        elif object_source.type is ObjectRaw.Types.dynamic:
            return ObjectDynamic(object_source)
        elif object_source.type is ObjectRaw.Types.const:
            return ObjectConst(object_source)
        elif object_source.type is ObjectRaw.Types.enum:
            return ObjectEnum(object_source)
        else:
            return Object(object_source)
1134861
function createOneOfTypeChecker(expectedEnumOfTypeValues) {

    return createChainableChecker(function (data, dataName, componentName, fullDataName) {

        if (getDataType(expectedEnumOfTypeValues) !== 'array') {
            throw new Error('[SAN ERROR] '
                + 'Data `' + dataName + '` of `' + componentName + '` has invalid '
                + 'DataType notation inside `oneOf`, array is expected.'
            );
        }

        var dataValue = data[dataName];

        for (var i = 0, len = expectedEnumOfTypeValues.length; i < len; i++) {

            var checker = expectedEnumOfTypeValues[i];

            if (typeof checker !== 'function') {
                continue;
            }

            try {
                checker(data, dataName, componentName, fullDataName);
                // 如果 checker 完成校验没报错，那就返回了
                return;
            }
            catch (e) {
                // 如果有错误，那么应该把错误吞掉
            }

        }

        // 所有的可接受 type 都失败了，才丢一个异常
        throw new Error('[SAN ERROR] '
            + 'Invalid ' + componentName + ' data `' + dataName + '` of value'
            + '(`' + dataValue + '` supplied to ' + componentName + ')'
        );

    });

}
337136
public static Object newInstance(Class type) {
        Constructor _constructor = null;
        Object[] _constructorArgs = new Object[0];
        try {
            _constructor = type.getConstructor(new Class[] {});// 先尝试默认的空构造函数
        } catch (NoSuchMethodException e) {
            // ignore
        }

        if (_constructor == null) {// 没有默认的构造函数，尝试别的带参数的函数
            Constructor[] constructors = type.getConstructors();
            if (constructors.length == 0) {
                throw new UnsupportedOperationException("Class[" + type.getName() + "] has no public constructors");
            }
            _constructor = constructors[0];// 默认取第一个参数
            Class[] params = _constructor.getParameterTypes();
            _constructorArgs = new Object[params.length];
            for (int i = 0; i < params.length; i++) {
                _constructorArgs[i] = getDefaultValue(params[i]);
            }
        }

        return ReflectUtils.newInstance(_constructor, _constructorArgs);
    }
270862
function factory(ctx) {
  decoder.raw = decodeRaw

  return decoder

  // Normalize `position` to add an `indent`.
  function normalize(position) {
    var offsets = ctx.offset
    var line = position.line
    var result = []

    while (++line) {
      if (!(line in offsets)) {
        break
      }

      result.push((offsets[line] || 0) + 1)
    }

    return {start: position, indent: result}
  }

  // Decode `value` (at `position`) into text-nodes.
  function decoder(value, position, handler) {
    entities(value, {
      position: normalize(position),
      warning: handleWarning,
      text: handler,
      reference: handler,
      textContext: ctx,
      referenceContext: ctx
    })
  }

  // Decode `value` (at `position`) into a string.
  function decodeRaw(value, position, options) {
    return entities(
      value,
      xtend(options, {position: normalize(position), warning: handleWarning})
    )
  }

  // Handle a warning.
  // See <https://github.com/wooorm/parse-entities> for the warnings.
  function handleWarning(reason, position, code) {
    if (code !== 3) {
      ctx.file.message(reason, position)
    }
  }
}
388207
function factory(context, user)
{
  var tailored = send.bind(context, user);

  // add custom per type send method
  Object.keys(types).forEach(function(type)
  {
    tailored[toCamelCase(type)] = send.bind(context, user, types[type]);
  });

  return tailored;
}
1367848
function Factory(name, model, attributes) {
    this.name = name;
    this.model = model;
    this.attributes = attributes;
}
30277
function inherit(BaseClass) {
                var kclass = function () {
                    // 若未进行 constructor 的重写，则klass.prototype.constructor指向BaseClass.prototype.constructor
                    return kclass.prototype.constructor.apply(this, arguments);
                };

                Empty.prototype = BaseClass.prototype;

                var proto = kclass.prototype = new Empty();
                proto.$self = kclass;
                if (!('$super' in proto)) {
                    proto.$super = Class.prototype.$super;
                }

                kclass.$superClass = BaseClass;

                return kclass;
            }
1348195
function factory( window, EvEmitter ) {



var $ = window.jQuery;
var console = window.console;

// -------------------------- helpers -------------------------- //

// extend objects
function extend( a, b ) {
  for ( var prop in b ) {
    a[ prop ] = b[ prop ];
  }
  return a;
}

// turn element or nodeList into an array
function makeArray( obj ) {
  var ary = [];
  if ( Array.isArray( obj ) ) {
    // use object if already an array
    ary = obj;
  } else if ( typeof obj.length == 'number' ) {
    // convert nodeList to array
    for ( var i=0; i < obj.length; i++ ) {
      ary.push( obj[i] );
    }
  } else {
    // array of single index
    ary.push( obj );
  }
  return ary;
}

// -------------------------- imagesLoaded -------------------------- //

/**
 * @param {Array, Element, NodeList, String} elem
 * @param {Object or Function} options - if function, use as callback
 * @param {Function} onAlways - callback function
 */
function ImagesLoaded( elem, options, onAlways ) {
  // coerce ImagesLoaded() without new, to be new ImagesLoaded()
  if ( !( this instanceof ImagesLoaded ) ) {
    return new ImagesLoaded( elem, options, onAlways );
  }
  // use elem as selector string
  if ( typeof elem == 'string' ) {
    elem = document.querySelectorAll( elem );
  }

  this.elements = makeArray( elem );
  this.options = extend( {}, this.options );

  if ( typeof options == 'function' ) {
    onAlways = options;
  } else {
    extend( this.options, options );
  }

  if ( onAlways ) {
    this.on( 'always', onAlways );
  }

  this.getImages();

  if ( $ ) {
    // add jQuery Deferred object
    this.jqDeferred = new $.Deferred();
  }

  // HACK check async to allow time to bind listeners
  setTimeout( function() {
    this.check();
  }.bind( this ));
}

ImagesLoaded.prototype = Object.create( EvEmitter.prototype );

ImagesLoaded.prototype.options = {};

ImagesLoaded.prototype.getImages = function() {
  this.images = [];

  // filter & find items if we have an item selector
  this.elements.forEach( this.addElementImages, this );
};

/**
 * @param {Node} element
 */
ImagesLoaded.prototype.addElementImages = function( elem ) {
  // filter siblings
  if ( elem.nodeName == 'IMG' ) {
    this.addImage( elem );
  }
  // get background image on element
  if ( this.options.background === true ) {
    this.addElementBackgroundImages( elem );
  }

  // find children
  // no non-element nodes, #143
  var nodeType = elem.nodeType;
  if ( !nodeType || !elementNodeTypes[ nodeType ] ) {
    return;
  }
  var childImgs = elem.querySelectorAll('img');
  // concat childElems to filterFound array
  for ( var i=0; i < childImgs.length; i++ ) {
    var img = childImgs[i];
    this.addImage( img );
  }

  // get child background images
  if ( typeof this.options.background == 'string' ) {
    var children = elem.querySelectorAll( this.options.background );
    for ( i=0; i < children.length; i++ ) {
      var child = children[i];
      this.addElementBackgroundImages( child );
    }
  }
};

var elementNodeTypes = {
  1: true,
  9: true,
  11: true
};

ImagesLoaded.prototype.addElementBackgroundImages = function( elem ) {
  var style = getComputedStyle( elem );
  if ( !style ) {
    // Firefox returns null if in a hidden iframe https://bugzil.la/548397
    return;
  }
  // get url inside url("...")
  var reURL = /url\((['"])?(.*?)\1\)/gi;
  var matches = reURL.exec( style.backgroundImage );
  while ( matches !== null ) {
    var url = matches && matches[2];
    if ( url ) {
      this.addBackground( url, elem );
    }
    matches = reURL.exec( style.backgroundImage );
  }
};

/**
 * @param {Image} img
 */
ImagesLoaded.prototype.addImage = function( img ) {
  var loadingImage = new LoadingImage( img );
  this.images.push( loadingImage );
};

ImagesLoaded.prototype.addBackground = function( url, elem ) {
  var background = new Background( url, elem );
  this.images.push( background );
};

ImagesLoaded.prototype.check = function() {
  var _this = this;
  this.progressedCount = 0;
  this.hasAnyBroken = false;
  // complete if no images
  if ( !this.images.length ) {
    this.complete();
    return;
  }

  function onProgress( image, elem, message ) {
    // HACK - Chrome triggers event before object properties have changed. #83
    setTimeout( function() {
      _this.progress( image, elem, message );
    });
  }

  this.images.forEach( function( loadingImage ) {
    loadingImage.once( 'progress', onProgress );
    loadingImage.check();
  });
};

ImagesLoaded.prototype.progress = function( image, elem, message ) {
  this.progressedCount++;
  this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded;
  // progress event
  this.emitEvent( 'progress', [ this, image, elem ] );
  if ( this.jqDeferred && this.jqDeferred.notify ) {
    this.jqDeferred.notify( this, image );
  }
  // check if completed
  if ( this.progressedCount == this.images.length ) {
    this.complete();
  }

  if ( this.options.debug && console ) {
    console.log( 'progress: ' + message, image, elem );
  }
};

ImagesLoaded.prototype.complete = function() {
  var eventName = this.hasAnyBroken ? 'fail' : 'done';
  this.isComplete = true;
  this.emitEvent( eventName, [ this ] );
  this.emitEvent( 'always', [ this ] );
  if ( this.jqDeferred ) {
    var jqMethod = this.hasAnyBroken ? 'reject' : 'resolve';
    this.jqDeferred[ jqMethod ]( this );
  }
};

// --------------------------  -------------------------- //

function LoadingImage( img ) {
  this.img = img;
}

LoadingImage.prototype = Object.create( EvEmitter.prototype );

LoadingImage.prototype.check = function() {
  // If complete is true and browser supports natural sizes,
  // try to check for image status manually.
  var isComplete = this.getIsImageComplete();
  if ( isComplete ) {
    // report based on naturalWidth
    this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
    return;
  }

  // If none of the checks above matched, simulate loading on detached element.
  this.proxyImage = new Image();
  this.proxyImage.addEventListener( 'load', this );
  this.proxyImage.addEventListener( 'error', this );
  // bind to image as well for Firefox. #191
  this.img.addEventListener( 'load', this );
  this.img.addEventListener( 'error', this );
  this.proxyImage.src = this.img.src;
};

LoadingImage.prototype.getIsImageComplete = function() {
  return this.img.complete && this.img.naturalWidth !== undefined;
};

LoadingImage.prototype.confirm = function( isLoaded, message ) {
  this.isLoaded = isLoaded;
  this.emitEvent( 'progress', [ this, this.img, message ] );
};

// ----- events ----- //

// trigger specified handler for event type
LoadingImage.prototype.handleEvent = function( event ) {
  var method = 'on' + event.type;
  if ( this[ method ] ) {
    this[ method ]( event );
  }
};

LoadingImage.prototype.onload = function() {
  this.confirm( true, 'onload' );
  this.unbindEvents();
};

LoadingImage.prototype.onerror = function() {
  this.confirm( false, 'onerror' );
  this.unbindEvents();
};

LoadingImage.prototype.unbindEvents = function() {
  this.proxyImage.removeEventListener( 'load', this );
  this.proxyImage.removeEventListener( 'error', this );
  this.img.removeEventListener( 'load', this );
  this.img.removeEventListener( 'error', this );
};

// -------------------------- Background -------------------------- //

function Background( url, element ) {
  this.url = url;
  this.element = element;
  this.img = new Image();
}

// inherit LoadingImage prototype
Background.prototype = Object.create( LoadingImage.prototype );

Background.prototype.check = function() {
  this.img.addEventListener( 'load', this );
  this.img.addEventListener( 'error', this );
  this.img.src = this.url;
  // check if image is already complete
  var isComplete = this.getIsImageComplete();
  if ( isComplete ) {
    this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
    this.unbindEvents();
  }
};

Background.prototype.unbindEvents = function() {
  this.img.removeEventListener( 'load', this );
  this.img.removeEventListener( 'error', this );
};

Background.prototype.confirm = function( isLoaded, message ) {
  this.isLoaded = isLoaded;
  this.emitEvent( 'progress', [ this, this.element, message ] );
};

// -------------------------- jQuery -------------------------- //

ImagesLoaded.makeJQueryPlugin = function( jQuery ) {
  jQuery = jQuery || window.jQuery;
  if ( !jQuery ) {
    return;
  }
  // set local variable
  $ = jQuery;
  // $().imagesLoaded()
  $.fn.imagesLoaded = function( options, callback ) {
    var instance = new ImagesLoaded( this, options, callback );
    return instance.jqDeferred.promise( $(this) );
  };
};
// try making plugin
ImagesLoaded.makeJQueryPlugin();

// --------------------------  -------------------------- //

return ImagesLoaded;

}
859149
def func_factory(p, method: str) -> callable:
    

    def callback(pretty: bool = False):
        res = getattr(p, method)
        dump = partial(json.dumps, indent=4) if pretty else partial(json.dumps)
        click.echo(dump(res))

    return callback
73680
function __init(opts) {
    //扩展参数
    extend(this.options, opts || (opts = {}));
    //获取目标元素
    this.appearWatchElements = this.appearWatchElements || __getElements.call(this, '.' + this.options.cls);
    //初始化位置信息
    __initBoundingRect.call(this, this.appearWatchElements);
    //绑定事件
    __bindEvent.call(this);
  }
205330
function factory(type) {
  point.displayName = type

  return point

  /* Get a point in `node.position` at a bound `type`. */
  function point(node) {
    var point = (node && node.position && node.position[type]) || {}

    return {
      line: point.line || null,
      column: point.column || null,
      offset: isNaN(point.offset) ? null : point.offset
    }
  }
}
1015779
function factory(options) {
  options = _.extend({}, options);

  return tartan.parse([
    tartan.parse.stripe(),
    tartan.parse.literal('('),
    tartan.parse.literal(')'),
    tartan.parse.literal('['),
    tartan.parse.literal(']'),
    tartan.parse.color({
      allowLongNames: true,
      colorPrefix: /[#]/,
      colorSuffix: null,
      colorFormat: 'long',
      allowComment: false
    })
  ], {
    errorHandler: options.errorHandler,
    processTokens: tartan.filter([
      options.processTokens,
      tartan.filter.removeTokens(tartan.defaults.insignificantTokens)
    ]),
    buildSyntaxTree: syntax({
      errorHandler: options.errorHandler,
      processTokens: tartan.filter.classify({
        // Disable some token classes
        isWarpAndWeftSeparator: null,
        isPivot: null,
        isBlockStart: null,
        isBlockEnd: null,

        // Add new token classes
        isWarpStart: function(token) {
          return tartan.utils.token.isLiteral(token) && (token.value == '[');
        },
        isWeftStart: function(token) {
          return tartan.utils.token.isLiteral(token) && (token.value == ']');
        },
        isBlockBodyStart: function(token) {
          return tartan.utils.token.isLiteral(token) && (token.value == '(');
        },
        isBlockBodyEnd: function(token) {
          return tartan.utils.token.isLiteral(token) && (token.value == ')');
        }
      }),
      transformSyntaxTree: options.transformSyntaxTree
    })
  });
}
109600
def functions_factory(cls, coef, domain, kind, **kwargs):
        
        basis_polynomial = cls._basis_polynomial_factory(kind)
        return basis_polynomial(coef, domain)