循环遍历数组集合

@inner
@param {Array} source 数组源
@param {function(Array,Number):boolean} iterator 遍历函数
187878
function each(source, iterator) {
        if (source instanceof Array) {
            for (var i = 0, len = source.length; i < len; i++) {
                if (iterator(source[i], i) === false) {
                    break;
                }
            }
        }
    }
790620
function(v, i) {
      if (v === undefined || v === null) return;
      failed += !iterator.call(context, v, type, level, i);
    }
306460
function merge(need, options, level){
    // 如果没有传第三个参数，默认无限递归右边覆盖左边
    if (level == undefined) level = -1;
    if (options === undefined) options = {};
    if (need.length == 1) return need[0];
    var res = {};
    for (var i = 0; i < need.length; i++){
        _merge(res, need[i], options, level - 1);
    }
    return res;
}
712063
function arraySum (array, iterate, context) {
  var result = 0
  var toNumber = XEUtils.toNumber
  context = context || this
  baseExports.each(array, iterate ? baseExports.isFunction(iterate) ? function () {
    result += toNumber(iterate.apply(context, arguments))
  } : function (val) {
    result += toNumber(val[iterate])
  } : function (val) {
    result += toNumber(val)
  })
  return result
}
1008980
function parseSource(source, engine) {
        var commandOpen = engine.options.commandOpen;
        var commandClose = engine.options.commandClose;
        var commandSyntax = engine.options.commandSyntax;

        var stack = new Stack();
        var analyseContext = {
            engine: engine,
            targets: [],
            stack: stack,
            target: null,
            deps: {}
        };

        // text节点内容缓冲区，用于合并多text
        var textBuf = [];

        /**
         * 将缓冲区中的text节点内容写入
         *
         * @inner
         */
        function flushTextBuf() {
            var text;
            if (textBuf.length > 0 && (text = textBuf.join(''))) {
                var textNode = new TextNode(text, engine);
                textNode.beforeAdd(analyseContext);

                stack.top().addChild(textNode);
                textBuf = [];

                if (engine.options.strip
                    && analyseContext.current instanceof Command
                ) {
                    textNode.value = text.replace(/^[\x20\t\r]*\n/, '');
                }
                analyseContext.current = textNode;
            }
        }

        var NodeType;

        parseTextBlock(
            source, commandOpen, commandClose, 0,

            function (text) { // <!--...-->内文本的处理函数
                var match = commandSyntax.exec(text);
                var nodeName;

                // 符合command规则，并且存在相应的Command类，说明是合法有含义的Command
                // 否则，为不具有command含义的普通文本
                if (match
                    && (nodeName = match[2] || 'target')
                    && (NodeType = engine.commandTypes[nodeName.toLowerCase()])
                    && typeof NodeType === 'function'
                ) {
                    // 先将缓冲区中的text节点内容写入
                    flushTextBuf();

                    var currentNode = analyseContext.current;
                    if (engine.options.strip && currentNode instanceof TextNode) {
                        currentNode.value = currentNode.value
                            .replace(/\r?\n[\x20\t]*$/, '\n');
                    }

                    if (match[1]) {
                        currentNode = autoCloseCommand(analyseContext, NodeType);
                    }
                    else {
                        currentNode = new NodeType(match[3], engine);

                        if ('function' === typeof currentNode.init) {
                            currentNode.init(analyseContext);
                        }

                        currentNode.beforeOpen(analyseContext);
                        currentNode.open(analyseContext);
                    }

                    analyseContext.current = currentNode;
                }
                else if (!/^\s*\/\//.test(text)) {
                    // 如果不是模板注释，则作为普通文本，写入缓冲区
                    textBuf.push(commandOpen, text, commandClose);
                }

                NodeType = null;
            },

            function (text) { // <!--...-->外，普通文本的处理函数
                // 普通文本直接写入缓冲区
                textBuf.push(text);
            }
        );


        flushTextBuf(); // 将缓冲区中的text节点内容写入
        autoCloseCommand(analyseContext);

        var deps = [];
        for (var key in analyseContext.deps) {
            deps.push(key);
        }

        return {
            targets: analyseContext.targets,
            deps: deps
        };
    }
1038967
function(c, type, level) {
    if (c.values === undefined || c.values === null) return true;

    var failed = 0;

    // Value iterator function. Gets the value and index as arguments.
    // Collects boolean results.
    var viter = function(v, i) {
      if (v === undefined || v === null) return;
      failed += !iterator.call(context, v, type, level, i);
    };

    c.values.forEach(viter);

    return failed === 0;
  }
309886
function elint (files, options) {
  co(function * () {
    const fileList = yield walker(files, options)

    // 没有匹配到任何文件，直接退出
    if (!fileList.es.length && !fileList.style.length) {
      process.exit()
    }

    // linters 对象，方便后续操作
    const linters = {
      es: eslint,
      style: stylelint
    }

    // 处理 fix 和 forceFix
    const isGit = yield isGitHooks()

    if (isGit) {
      options.fix = false
    }
    if (options.forceFix) {
      options.fix = true
    }

    debug('parsed options: %o', options)

    const { type } = options
    const argus = JSON.stringify(options)
    let workers = []

    if (type) {
      // 明确指定 type，例如 elint lint es "*.js"
      workers.push(linters[type](argus, ...fileList[type]))
    } else {
      /**
       * 没有明确指定 type，根据文件类型判断支持哪些 linter
       * 使用 _.toPairs 兼容 node v6
       */
      _.toPairs(linters).forEach(([linterType, linter]) => {
        if (!fileList[linterType].length) {
          return
        }

        workers.push(linter(argus, ...fileList[linterType]))
      })
    }

    // 添加 notifier
    workers.push(notifier.notify())

    Promise.all(workers).then(results => {
      const notifierResult = results.pop()
      const lintResults = results

      const outputs = []
      let success = true

      lintResults.forEach(result => {
        const output = JSON.parse(result.stdout)
        outputs.push(output)
        success = success && output.success
      })

      console.log(report(outputs))

      if (notifierResult) {
        console.log(notifierResult)
      }

      process.exit(success ? 0 : 1)
    })
  })
}
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 };
  }
523932
function Compiler(moduleConfig, moduleCombineConfigs, moduleMapConfigs) {
    this._moduleConfig = moduleConfig;
    this._moduleCombineConfigs = moduleCombineConfigs || this._moduleConfig.combine || {};
    this._moduleMapConfigs = helper.createKVSortedIndex(moduleMapConfigs, 1);

    u.each(this._moduleMapConfigs, function (item) {
        item.v = helper.createKVSortedIndex(item.v);
    });

    this._idToFileMap = {};

    /**
     * 二维数组.
     * @type {Array.<Array.<string>>}
     */
    this._aliasModules = [];

    /**
     * key 是 module id
     * value 是 _aliasModules 的 index
     * @type {Object.<string, number>}
     */
    this._aliasModulesMap = {};

    /**
     * 缓存模块的定义信息.
     * @type {Object.<string, ModuleDefinition>}
     */
    this._moduleDefinitions = {};
}
371541
function () {

    var keys = Object.keys(wating);

    /*
     * 检测依赖关系，
     * FIXME 暂时未处理循环依赖.以及始终不满足执行条件的情况.
     */
    keys.forEach(function (name) {
        var args = [];
        var factory = wating[name][0];
        var depends = wating[name][1];
        var done = wating[name][2];

        var canDo = depends.every(function (name) {

            // 插件系统中内容优先，资源池中置后
            var value = working[name] || Resource[name];

            if (value) {
                args.push(value);
                return true;
            }

            return false;
        });

        if (canDo) {
            // 先移除，防止callback中检测依赖时产生的循环
            delete wating[name];

            //  判断异步及同步
            if (done) {
                args.push(done);
                factory.apply( {}, args);
            } else {
                try {
                    var value = working[name] = factory.apply( {}, args);

                    oldDefineOfPlugin.call(Plugin, name, value);
                }catch(err) {
                    stdLog(['%s, can not start the plug-in [%s], \nstack:', err.stack, name], 'crash');
                    process.exit(0);
                    return;
                }
            }
        }
    });
}
470250
function(sources, reg) {
        /*如果原文件中有责返回该文件*/
        if (src[reg]) {
            return [src[reg]];
        } else if (reg === '**') {
            // do nothing
        } else if (typeof reg === 'string') {
            reg = _.glob(reg);
        }
        return sources.filter(function(file) {
            reg.lastIndex = 0;
            return (reg === '**' ||
            reg.test(file.subpath))
        });
    }
1183958
function (source, callback, context) {
            var results = [];
            var i = source.length;
            while (i--) {
                results[i] = callback.call(context || source, source[i], i);
            }
            return results;
        }
1171178
@SuppressWarnings("rawtypes")
    private static Object getOneLayerClone(Object source) {
        if (null == source) {
            return null;
        }
        Object target = null;
        try {
            Constructor con = source.getClass().getConstructor();
            target = con.newInstance();
            // 把一个集合类中的数据拷贝到另一集合类中
            PropertyUtils.copyProperties(target, source);

        } catch (Exception e) {
            logger.error("clone object exception object class:" + source.getClass(), e);
        }
        return target;
    }
281219
function(source) {
            if($.isArray(source) && source.length && source[0].value !== undefined) {
                for(var i = 0; i<source.length; i++) {
                    if(source[i].value !== undefined) {
                        source[i].id = source[i].value;
                        delete source[i].value;
                    }
                }
            }
            return source;            
        }
1110448
function Iterator(iterator) {

    if (Array.isArray(iterator) || typeof iterator == "string")
        return Iterator.iterate(iterator);

    iterator = Object(iterator);

    if (!(this instanceof Iterator))
        return new Iterator(iterator);

    this.next = this.send =
        iterator.send || iterator.next || iterator;

    if (
        Object.prototype.toString.call(this.next) !=
        "[object Function]"
    )
        throw new TypeError();

}
1044812
public static void merge(String source, String target) throws IOException{
        final AtomicLong count = new AtomicLong();
        final AtomicLong lines = new AtomicLong();
        try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(target),"utf-8"))){
            Files.walkFileTree(Paths.get(source), new SimpleFileVisitor<Path>(){

                    @Override
                    public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                        LOGGER.info("处理文件："+file);
                        try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file.toFile()),"utf-8"));){
                            String line;
                            while( (line = reader.readLine()) != null ){
                                count.addAndGet(line.length());
                                lines.incrementAndGet();
                                writer.write(line+"\n");
                            }
                        }
                        return FileVisitResult.CONTINUE;
                    }
                    
                });
        }
        LOGGER.info("语料库行数："+lines.get());
        LOGGER.info("语料库字符数目："+count.get());
    }
704383
function iterator2array(it) {
    // workaround around https://github.com/instea/react-native-popup-menu/issues/41#issuecomment-340290127
    var arr = [];

    for (var next = it.next(); !next.done; next = it.next()) {
      arr.push(next.value);
    }

    return arr;
  }