根据时间判断 func 能否被执行
977564
function shouldInvoke(time) {
    let timeSinceLastCall = time - lastCallTime;

    let timeSinceLastInvoke = time - lastInvokeTime;
    // 几种满足条件的情况
    return (lastCallTime === undefined ||
      (timeSinceLastCall >= wait) ||
      (timeSinceLastCall < 0) ||
      (maxing && timeSinceLastInvoke >= maxWait)); // 超过最大等待时间
  }
449027
function request(opts, callback, agents) {
    var uri = url.parse(opts.url);
    var protocol = uri.protocol || DEFAULT_PROTOCOL;
    protocol = protocol.substring(0, protocol.length - 1);

    var options = {
        hostname: uri.hostname,
        port: uri.port || DEFAULT_PORTS[protocol] || DEFAULT_PORT,
        path: uri.path,
        method: opts.method,
        headers: opts.headers,
        agent: (agents || defaultAgents)[protocol]
    };

    var client = clients[protocol];
    var req = client.request(options, function (res) {
        var data = [];

        res.on('data', function (chunk) {
            data.push(chunk);
        });

        res.on('end', function () {
            if (data.length) {
                data = Buffer.concat(data).toString('utf8');
            }
            else {
                data = '';
            }
            callback(null, res, data);
        });
    });

    req.on('error', callback);

    var abort = req.abort;
    if (opts.timeout) {
        setTimeout(
            function () {
                abort.call(req);
                var e = new Error('TIMEOUT');
                e.code = 'timeout';
                callback(e);
            },
            opts.timeout
        );
    }

    // 重载abort方法 提示错误
    req.abort = function () {
        abort.call(this);
        var e = new Error('ABORT');
        e.code = 'abort';
        callback(e);
    };

    req.write(opts.body || '');
    req.end();

    return req;
}
710653
@Override
	public Object call(Object[] args, Context context) {
		// 只能有一个参数且只能为字符串
		if ((args.length >= 1) && (args[0] instanceof String) && (args[0] != null)) {
			String spel = (String) args[0];
			Expression expression = getExpression(spel);
			// 如果有第二参数，取他作为根对象
			if ((args.length >= 2) && (args[1] != null)) {
				return expression.getValue(createEvaluationContext(args[1], context));
			} else {
				return expression.getValue(createEvaluationContext(Collections.emptyMap(), context));
			}
		}
		return null;
	}
531473
function vNumber(func, type, str, range) {
    let success   = true;
    let checkType = true;
    let errmsg;
    // 先验证类型
    if (!func(str)) {
      errmsg = localData.em_type({
        desc,
        str,
        type,
      });
      checkType = false;
      success = false;
    }
    // 再验证类型范围
    // if (range && range.min === undefined) {
    //   range.min = 0;
    // }
    if (range && (range.min === undefined || range.min < -NUMBER_MAX)) {
      range.min = -NUMBER_MAX;
    }
    if (range && (range.max === undefined || range.max > NUMBER_MAX)) {
      range.max = NUMBER_MAX;
    }
    if (success && checkType && range && (range.min !== undefined || range.max !== undefined)) {
      if (range && range.min !== undefined && range.min > Number(str)) {
        success = false;
      }
      if (success && range && range.max !== undefined && range.max < Number(str)) {
        success = false;
      }
      if (!success) {
        errmsg = localData.em_minmax({
          desc,
          type,
          opDesc: 'value',
          minOp : '>=',
          min   : range.min,
          maxOp : '<=',
          max   : range.max,
        });
      }
    }
    return { success, errmsg };
  }
531083
async function handle(sofar) {
    let ret = { ret: 0 };

    try {
        //根据令牌进行鉴权
        if(!sofar.socket.user){
            sofar.socket.user = await facade.GetObject(EntityType.User, sofar.msg.oemInfo.token, IndexType.Token);
        }

        if (!sofar.socket.user || sofar.msg.func == "login"/*如果是login则强制重新验证*/) {
            //针对各类第三方平台，执行一些必要的验证流程：
            switch(GetDomainType(sofar.msg.oemInfo.domain)) {
                case DomainType.TX: { //QQ游戏开发平台, 前向校验下用户的合法性
                        if (!sofar.facade.options.debug) {
                            ret = await sofar.facade.service.txApi.Get_Info(sofar.msg.oemInfo.openid, sofar.msg.oemInfo.openkey, sofar.msg.oemInfo.pf, sofar.msg.userip);
                        }
                        if (ret.ret != 0) { //验证未通过
                            sofar.fn({ code: ReturnCode.authThirdPartFailed, data: ret });
                            sofar.recy = false;
                            return;
                        }
                        ret.openid = sofar.msg.oemInfo.openid;
                        ret.openkey = sofar.msg.oemInfo.openkey;
                        ret.pf = sofar.msg.oemInfo.pf;
                        break;
                    }

                default: {
                        if(!!sofar.msg.oemInfo.auth) {
                            if(!!sofar.msg.oemInfo.authControl) { //自定义验签流程
                                try {
                                    sofar.msg.oemInfo.openid = await facade.current.control[sofar.msg.oemInfo.authControl].check(sofar.msg.oemInfo);
                                } catch(e) {
                                    sofar.fn({ code: ReturnCode.authThirdPartFailed });
                                    sofar.recy = false;
                                    return;
                                }
                            } else { // 通用验签流程
                                let _sign = (sofar.msg.oemInfo.auth.sign == facade.util.sign(sofar.msg.oemInfo.auth, sofar.facade.options[DomainType.D360].game_secret));
                                let _exp = (Math.abs(sofar.msg.oemInfo.auth.t - CommonFunc.now()) <= 300);
                                if (!_sign || !_exp) {
                                    sofar.fn({ code: ReturnCode.authThirdPartFailed });
                                    sofar.recy = false;
                                    return;
                                }
                                sofar.msg.oemInfo.openid = sofar.msg.oemInfo.auth.plat_user_id;
                            }
                        }
                        sofar.msg.domainId = `${sofar.msg.oemInfo.domain}.${sofar.msg.oemInfo.openid}`;
                        break;
                    }
            }

            sofar.msg.oemInfo.token = facade.util.sign({ did: sofar.msg.domainId }, sofar.facade.options.game_secret); //为用户生成令牌
            
            let usr = facade.GetObject(EntityType.User, sofar.msg.domainId, IndexType.Domain);
            if (!!usr) {//老用户登录
                usr.socket = sofar.socket; //更新通讯句柄
                usr.userip = sofar.msg.userip;
                sofar.socket.user = usr;

                usr.baseMgr.info.UnsetStatus(UserStatus.isNewbie, false);
                if (!!usr.socket && usr.socket != sofar.socket) {
                    //禁止多点登录
                    sofar.facade.notifyEvent('socket.userKick', {sid:usr.socket});
                }
            }
            else if (!!sofar.msg.oemInfo.openid) {//	新玩家注册
                //sofar.msg.func = 'login'; //强制登录
                let name;
                if(!!sofar.msg.userinfo){
                    name = sofar.msg.userinfo.nick;
                }else{
                    name = '猴子' + facade.util.rand(10000, 99999);	  //随机名称
                }
                let appId = '';												    //应用ID    
                let serverId = '';												//服务器ID

                let oemInfo = sofar.msg.oemInfo;
                // if (oemInfo.userName) {
                //     name = oemInfo.userName;
                // }
                if (oemInfo.appId) {
                    appId = oemInfo.appId;
                }
                if (oemInfo.serverId) {
                    serverId = oemInfo.serverId;
                }

                usr = await facade.GetMapping(EntityType.User).Create(name, oemInfo.domain, oemInfo.openid);
                if (!!usr) {
                    usr.socket = sofar.socket; //更新通讯句柄
                    usr.userip = sofar.msg.userip;
                    sofar.socket.user = usr;

                    //写入账号信息
                    usr.WriteUserInfo(appId, serverId, CommonFunc.now(), sofar.msg.oemInfo.token);
                    sofar.facade.notifyEvent('user.newAttr', {user: usr, attr:[{type:'uid', value:usr.id}, {type:'name', value:usr.name}]});
                    sofar.facade.notifyEvent('user.afterRegister', {user:usr});
                }
            }

            if (!!usr) {
                if(sofar.facade.options.debug){//模拟填充测试数据/用户头像信息
                    ret.figureurl = facade.config.fileMap.DataConst.user.icon;
                }
                sofar.facade.notifyEvent('user.afterLogin', {user:usr, objData:sofar.msg});//发送"登录后"事件
                if(usr.domainType == DomainType.TX) { //设置腾讯会员属性
                    await usr.SetTxInfo(ret); //异步执行，因为涉及到了QQ头像的CDN地址转换
                }
                usr.sign = sofar.msg.oemInfo.token;         //记录登录令牌
                usr.time = CommonFunc.now();                //记录标识令牌有效期的时间戳
                facade.GetMapping(EntityType.User).addId([usr.sign, usr.id],IndexType.Token); //添加一定有效期的令牌类型的反向索引
            }
        }

        if (!sofar.socket.user) {//未通过身份校验
            sofar.fn({ code: ReturnCode.userIllegal });
            sofar.recy = false;
        }
        else {
            //console.log(`鉴权成功, OpenId/Token: ${sofar.msg.oemInfo.openid}/${sofar.msg.oemInfo.token}`);
            //分发用户上行报文的消息，可以借此执行一些刷新操作
            sofar.facade.notifyEvent('user.packetIn', {user: sofar.socket.user});
        }
    }
    catch (e) {
        console.log(e);
        sofar.fn({ code: ReturnCode.illegalData, data: ret });
        sofar.recy = false;
    }
}
98715
function nextTick(fn, thisArg) {
    if (thisArg) {
        fn = bind(fn, thisArg);
    }
    nextTasks.push(fn);

    if (nextHandler) {
        return;
    }

    nextHandler = function () {
        var tasks = nextTasks.slice(0);
        nextTasks = [];
        nextHandler = null;

        for (var i = 0, l = tasks.length; i < l; i++) {
            tasks[i]();
        }
    };

    // 非标准方法，但是此方法非常吻合要求。
    /* istanbul ignore next */
    if (typeof setImmediate === 'function') {
        setImmediate(nextHandler);
    }
    // 用MessageChannel去做setImmediate的polyfill
    // 原理是将新的message事件加入到原有的dom events之后
    else if (typeof MessageChannel === 'function') {
        var channel = new MessageChannel();
        var port = channel.port2;
        channel.port1.onmessage = nextHandler;
        port.postMessage(1);
    }
    // for native app
    else if (isNativePromise) {
        Promise.resolve().then(nextHandler);
    }
    else {
        setTimeout(nextHandler, 0);
    }
}
935356
function async(func)
{
  function wrapper()
  {
    var context = this;
    var args    = arguments;
    process.nextTick(function()
    {
      func.apply(context, args);
    });
  }

  return wrapper;
}
150425
function makeCurry(func, { arity = func.length, args = [] } = {}) {
    return function curried(...rest) {

        // 校验参数
        if (rest.length) {
            let count = 0,
                arr = [],
                cb = arg => {
                    arg === _ && count++;
                    arr.push(arg);
                };

            // 补全点位
            args.forEach(arg => {
                cb(arg === _ && rest.length ? rest.shift() : arg);
            });

            // 遍历能数
            rest.length && rest.forEach(cb);

            // 执行回调
            return (
                count < 1 && arr.length >= arity ?
                    func.apply(this, arr) :
                    makeCurry(func, { arity, args: arr })
            );
        }

        // 返回原函数
        return curried;
    };
}
973056
def func_call(self, t):
        
        func, params = t
        func_name = func.value
        func.value = "({}({}))".format(func_name, params)
        return func
1186320
def runcall(self, func, *args, **kw):
        
        # XXX where is this used ? can be removed ?
        self.enable_by_count()
        try:
            return func(*args, **kw)
        finally:
            self.disable_by_count()
1126144
function compose(middlewares, ctx) {
    let i = middlewares.length;
    let next = async function(){};

    // 循环算出来next
    for (let i = middlewares.length - 1; i >=0; i--) {
        next = getCallback(middlewares[i], ctx, next);
    }

    return next;
}
1054965
public function actionRun()
    {
        $crontab = Task::findAll(['switch' => Task::SWITCH_ACTIVE]);
        $tasks = [];

        foreach ($crontab as $task) {
            // 第一次运行,先计算下次运行时间
            if (!$task->next_rundate) {
                $task->next_rundate = $task->getNextRunDate();
                $task->save(false);
                continue;
            }
            // 判断运行时间到了没
            if ($task->next_rundate <= date('Y-m-d H:i:s')) {
                $tasks[] = $task;
            }
        }

        $this->executeTask($tasks);
        return ExitCode::OK;
    }
642076
function jsGetCallback(node, cb) {
        return function(e) {
            e = e || global.event;
            
            if(e.type === 'load' || regJSLOAD.test(node.readyState)) {
                
                //确保执行一次+内存回收
                node.onload = node.onerror = node.onreadystatechange = null

                if(node.parentNode && !config.debug) {
                    HEAD.removeChild(node)
                }
            
                node = undefined

                cb()
            }
        }

    }
442184
def run(self):
        
        # 如果出现了日期的改变 才会进行结算的事件
        _date = None

        while QA_util_if_tradetime(self.now):
            for data in self.ingest_data:  # 对于在ingest_data中的数据
                # <class 'QUANTAXIS.QAData.QADataStruct.QA_DataStruct_Stock_day'>
                date = data.date[0]
                if self.market_type is MARKET_TYPE.STOCK_CN:  # 如果是股票市场
                    if _date != date:  # 如果新的date
                        # 前一天的交易日已经过去
                        # 往 broker 和 account 发送 settle 事件
                        try:
                            self.market.trade_engine.join()
                            # time.sleep(2)
                            self.market._settle(self.broker_name)

                        except Exception as e:
                            raise e
                # 基金 指数 期货
                elif self.market_type in [MARKET_TYPE.FUND_CN, MARKET_TYPE.INDEX_CN, MARKET_TYPE.FUTURE_CN]:
                    self.market._settle(self.broker_name)
                # print(data)
                self.broker.run(
                    QA_Event(event_type=ENGINE_EVENT.UPCOMING_DATA, market_data=data))
                # 生成 UPCOMING_DATA 事件放到 队列中去执行

                self.market.upcoming_data(self.broker_name, data)

                self.market.trade_engine.join()

                _date = date
1133829
function(url, filepath, fn){
        // 提交请求
        try{
            fs.createReadStream(filepath).pipe(request.post(url, fn))
        }
        catch(e){ fn(e) }
    }
789273
function task($function, $params = array(), $callback = null)
    {
        $retObj = new RPC_Result($this);
        $send = array('call' => $function, 'params' => $params);
        if (count($this->env) > 0)
        {
            //调用端环境变量
            $send['env'] = $this->env;
        }
        $this->request($send, $retObj);
        $retObj->callback = $callback;
        return $retObj;
    }
1216071
public static <T> BaseDTO<T> exec(Callable<BaseDTO<T>> callable, String msg, Object... param) {
        try {
            log.info("函数调用");
            BaseDTO<T> dto = callable.call();
            log.info("函数调用结果为：[{}]", dto);
            return dto;
        } catch (Exception e) {
            if (param == null || param.length == 0) {
                log.error(msg, e);
            } else {
                Object[] params = new Object[param.length + 1];
                System.arraycopy(param, 0, params, 0, param.length);
                params[param.length] = e;
                log.error(msg, params);
            }
            return BaseDTO.buildError();
        }
    }