将字符串逗号切分返回对象

@param {string} source 源字符串
@return {Object}
333838
function splitStr2Obj(source) {
    var result = {};
    each(
        source.split(','),
        function (key) {
            result[key] = key;
        }
    );
    return result;
}
1287853
function deepCopy(source) {
	let result;
	let type = typeof source;
	if (type !== 'object' || source === null) {
		result = source;
	} else if (source instanceof Array) {
		result = [];
		for (let i = 0, l = source.length; i < l; i++) {
			result[i] = typeof source[i] === 'object' ? deepCopy(source[i]) : source[i];
		}
	} else {
		result = {};
		for (let k in source) {
			result[k] = typeof source[k] === 'object' ? deepCopy(source[k]) : source[k];
		}
	}
	return result;
}
513667
function copy(source) {
    var destination;
    if (Type.isDate(source)) {
        return new Date(source.getTime());
    } else if (Type.isRegExp(source)) {
        return new RegExp(source.source);
    } else if (isConstructor(source)) {
        try {
            destination = new source.constructor;
            Object.keys(source).forEach(function (key) {
                destination[key] = copy(source[key]);
            });
            return destination;
        } catch (e) {
            throw new Error('Core.copy: To many recursions on copy', e);
        }
    }
    return source;
}
313077
function eventSourceUnit (server) {
  var sources = {};

  function Source () {
    this.conn = [];
    this.history = [];
    this.lastMsgId = 0;
  }

  Source.prototype.removeConn = function(res) {
    var i = this.conn.indexOf(res);
    if (i !== -1) {
      this.conn.splice(i, 1);
    }
  };

  Source.prototype.sendSSE = function (res, id, event, message) {
    var data = '';
    if (event !== null) {
      data += 'event:' + event + '\n';
    }

    // Blank id resets the id counter.
    if (id !== null) {
      data += 'id:' + id + '\n';
    } else {
      data += 'id\n';
    }

    if (message) {
      data += 'data:' + message.split('\n').join('\ndata:') + '\n';
    }
    data += '\n';

    res.write(data);

    if (res.hasOwnProperty('xhr')) {
      clearTimeout(res.xhr);
      var self = this;
      res.xhr = setTimeout(function () {
        res.end();
        self.removeConn(res);
      }, 250);
    }
  };

  Source.prototype.emit = function (event, msg) {
    this.lastMsgId++;
    this.history.push({
      id: this.lastMsgId,
      event: event,
      msg: msg
    });

    for (var i = 0; i < this.conn.length; i++) {
      this.sendSSE(this.conn[i], this.lastMsgId, event, msg);
    }
  }

  Source.prototype.send = function (msg) {
    this.emit(null, JSON.stringify(msg));
  }

  function eventSource (channel) {
    if (channel[0] !== '/') { channel = '/$' + channel; }
    return sources[channel] = new Source();
  }

  server.eventSource = eventSource;


  return function eventSourceLayer (req, res, next) {
    if (sources[req.path] === undefined) return next();
    var source = sources[req.path];
    if (!source || req.headers.accept !== 'text/event-stream')
      return next();    // Don't bother if the client cannot handle it.

    // Remy Sharp's Polyfill support.
    if (req.headers['x-requested-with'] == 'XMLHttpRequest') {
      res.xhr = null;
    }

    res.setHeader('Content-Type', 'text/event-stream');
    res.setHeader('Cache-Control', 'no-cache');

    if (req.headers['last-event-id']) {
      var id = parseInt(req.headers['last-event-id']);
      for (var i = 0; i < source.history.length; i++)
        if (source.history[i].id > id)
          source.sendSSE(res, source.history[i].id,
              source.history[i].event, source.history[i].msg);
    } else res.write('id\n\n');      // Reset id.

    source.conn.push(res);

    // Every 15s, send a comment (avoids proxy dropping HTTP connection).
    var to = setInterval(function () {res.write(':\n');}, 15000);

    // This can only end in blood.
    req.on('close', function () {
      source.removeConn(res);
      clearInterval(to);
    });
  };
}
154623
function(obj) {
            var rest = slice.call(arguments, 1);

            for (var i = 0; i < rest.length; i++) {
                var source = rest[i];

                if (source) {
                    for (var prop in source) {
                        obj[prop] = source[prop];
                    }
                }
            }

            return obj;
        }
675154
function parse_javascript(file /*, options*/) {
  let source = fs.readFileSync(file, 'utf8');

  let nodes, list = {};

  try {
    nodes = parser.parse(source);
  } catch (err) {
    throw new Error(`${err} [${file}:${err.line},${err.column}]`);
  }

  // do pre-distribute early work
  _.each(nodes, node /*, id*/ => {
    let clone;

    // assign hierarchy helpers
    node.aliases  = [];
    node.children = [];

    // set source fiel of the node
    node.file = file;

    if (node.type === 'class') {
      node.subclasses = [];
    }

    // collect sections
    if (node.type === 'section') {
      list[node.id] = node;
      return;
    }

    // elements with undefined section get '' section,
    // and will be resolved later, when we'll have full
    // element list
    list[(node.section || '') + '.' + node.id] = node;

    // bound methods produce two methods with the same description but different signatures
    // E.g. Element.foo(@element, a, b) becomes
    // Element.foo(element, a, b) and Element#foo(a, b)
    if (node.type === 'method' && node.bound) {
      clone = _.clone(node);
      clone.id = node.id.replace(/(.+)\.(.+)$/, '$1#$2');

      // link to methods
      node.bound = clone.id;
      clone.bound = node.id;

      // insert bound method clone
      list[(node.section || '') + '.' + clone.id] = clone;
    }
  });

  // TODO: section.related_to should mark related element as belonging to the section
  //_.each(list, function (node, id) {
  //  var ref_id = '.' + node.related_to, ref;
  //  if ('section' === node.type && node.related_to && list[ref_id]) {
  //    ref = list[ref_id];
  //    ref.id = node.id + '.' + node.related_to;
  //    delete list[ref_id];
  //    list[ref.id] = ref;
  //  }
  //});

  return list;
}
147029
function convert(source) {
  let currentKey = "",
      currentValue = "",
      objectNames = [],
      output = {},
      parentObj = {},
      lines = source.split(NEW_LINE),
      splitAt;

  let currentObj = output;
  let parents = [];

  for (let i = 0; i < lines.length; i++) {
    let line = lines[i];
    if (line.charAt(0) === " ") {
      currentObj[currentKey] += line.substr(1);

    } else {
      splitAt = line.indexOf(":");

      if (splitAt < 0) {
        continue;
      }

      currentKey = line.substr(0, splitAt);
      currentValue = line.substr(splitAt + 1);

      switch (currentKey) {
        case "BEGIN":
          parents.push(parentObj);
          parentObj = currentObj;
          if (parentObj[currentValue] == null) {
            parentObj[currentValue] = [];
          }
          // Create a new object, store the reference for future uses
          currentObj = {};
          parentObj[currentValue].push(currentObj);
          break;
        case "END":
          currentObj = parentObj;
          parentObj = parents.pop();
          break;
        default:
          if(currentObj[currentKey]) {
            if(!Array.isArray(currentObj[currentKey])) {
              currentObj[currentKey] = [currentObj[currentKey]];
            }
            currentObj[currentKey].push(currentValue);
          } else {
            currentObj[currentKey] = currentValue;
          }
      }
    }
  }
  return output;
}
812890
function parseFunction (node) {
	const args = [];
	let index = 0;
	node.nodes.forEach((subNode) => {
		if (subNode.type === "div" && subNode.value === ",") {
			// 遇到`,`下标自加1
			index++;
			return;
		} else if (subNode.type === "function") {
			// 将参数中的`color-stop`,`from`,`to`三种function特殊处理
			if ((subNode.value === "from" || subNode.value === "to" || subNode.value === "color-stop")) {
				let colorStop = subNode.nodes.filter((colorStopInfo) => {
					// colorStop的子节点，除function和word外，都丢去
					return colorStopInfo.type === "function" || colorStopInfo.type === "word";
				}).map((colorStopInfo) => {
					// colorStop的子节点，转换为字符串
					return valueParser.stringify(colorStopInfo);
				});

				// 组装新的对象传递出去
				colorStop = {
					nodes: colorStop,
					type: "function",
					value: subNode.value,
				};

				// 不使用第三个数组维度，而是将其存在最上面的维度上
				args[index] = colorStop;
				return args[index];
			}
		} else if (subNode.type !== "word") {
			return;
		}

		if (!args[index]) {
			// 如果未初始化该数组维度，对其初始化
			args[index] = [];
		}
		// 未特殊处理的function，还有普通的word，将其转字符串
		args[index].push(valueParser.stringify(subNode));
	});
	// 返回转换后的数组
	return args;
}
163893
function compileSourcePreCode() {
    var $version = '##version##';

    var componentRenderers = {};

    function extend(target, source) {
        if (source) {
            Object.keys(source).forEach(function (key) {
                var value = source[key];
                if (typeof value !== 'undefined') {
                    target[key] = value;
                }
            });
        }

        return target;
    }

    function each(array, iterator) {
        if (array && array.length > 0) {
            for (var i = 0, l = array.length; i < l; i++) {
                if (iterator(array[i], i) === false) {
                    break;
                }
            }
        }
    }

    function contains(array, value) {
        var result;
        each(array, function (item) {
            result = item === value;
            return !result;
        });

        return result;
    }

    var HTML_ENTITY = {
        /* jshint ignore:start */
        '&': '&amp;',
        '<': '&lt;',
        '>': '&gt;',
        '"': '&quot;',
        /* eslint-disable quotes */
        "'": '&#39;'
        /* eslint-enable quotes */
        /* jshint ignore:end */
    };

    function htmlFilterReplacer(c) {
        return HTML_ENTITY[c];
    }

    function escapeHTML(source) {
        if (source == null) {
            return '';
        }

        if (typeof source === 'string') {
            return source ? source.replace(/[&<>"']/g, htmlFilterReplacer) : '';
        }

        return '' + source;
    }

    function _classFilter(source) {
        if (source instanceof Array) {
            return source.join(' ');
        }

        return source;
    }

    function _styleFilter(source) {
        if (typeof source === 'object') {
            var result = '';
            if (source) {
                Object.keys(source).forEach(function (key) {
                    result += key + ':' + source[key] + ';';
                });
            }

            return result;
        }

        return source;
    }

    function _xclassFilter(source) {
        if (source instanceof Array) {
            source = source.join(' ');
        }

        return source ? ' ' + source : '';
    }

    function _xstyleFilter(source) {
        var result;
        if (typeof source === 'object') {
            result = '';
            if (source) {
                Object.keys(source).forEach(function (key) {
                    result += key + ':' + source[key] + ';';
                });
            }
        }
        else {
            result = source;
        }

        return result ? ';' + result : '';
    }

    function attrFilter(name, value) {
        if (value) {
            return ' ' + name + '="' + value + '"';
        }

        return '';
    }

    function boolAttrFilter(name, value) {
        if (value && value !== 'false' && value !== '0') {
            return ' ' + name;
        }

        return '';
    }

    function callFilter(ctx, name, args) {
        var filter = ctx.proto.filters[name];
        if (typeof filter === 'function') {
            return filter.apply(ctx, args);
        }
    }
}
500363
function parseFunctionSourceElements() {
        var sourceElement, sourceElements = [], token, directive, firstRestricted, oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody;

        expect('{');

        while (index < length) {
            token = lookahead();
            if (token.type !== Token.StringLiteral) {
                break;
            }

            sourceElement = parseSourceElement();
            sourceElements.push(sourceElement);
            if (sourceElement.expression.type !== Syntax.Literal) {
                // this is not directive
                break;
            }
            directive = sliceSource(token.range[0] + 1, token.range[1] - 1);
            if (directive === 'use strict') {
                strict = true;
                if (firstRestricted) {
                    throwError(firstRestricted, Messages.StrictOctalLiteral);
                }
            } else {
                if (!firstRestricted && token.octal) {
                    firstRestricted = token;
                }
            }
        }

        oldLabelSet = labelSet;
        oldInIteration = inIteration;
        oldInSwitch = inSwitch;
        oldInFunctionBody = inFunctionBody;

        labelSet = {};
        inIteration = false;
        inSwitch = false;
        inFunctionBody = true;

        while (index < length) {
            if (match('}')) {
                break;
            }
            sourceElement = parseSourceElement();
            if (typeof sourceElement === 'undefined') {
                break;
            }
            sourceElements.push(sourceElement);
        }

        expect('}');

        labelSet = oldLabelSet;
        inIteration = oldInIteration;
        inSwitch = oldInSwitch;
        inFunctionBody = oldInFunctionBody;

        return {
            type: Syntax.BlockStatement,
            body: wrapBlock(sourceElements)
        };
    }
649700
@SuppressWarnings({"rawtypes", "unchecked"})
    public static Object getClone(Object source) {
        if (null == source) {
            return null;
        }
        Object target = BeanUtils.getOneLayerClone(source);

        try {
            // 此处使用了JAVA的内省机制（内省是 Java 语言对 Bean 类属性、事件的一种缺省处理方法）
            // 获得对像的BeanInfo 信息：
            BeanInfo bi = Introspector.getBeanInfo(source.getClass());
            // 获得属性的描述器
            PropertyDescriptor[] props = bi.getPropertyDescriptors();
            for (int i = 0; i < props.length; ++i) {
                if (null != props[i].getReadMethod()) {
                    Class propertyType = props[i].getPropertyType();
                    if (propertyType.equals(List.class)) {
                        List newList = new ArrayList();
                        // 此处使用了JAVA的反射机制通过获得方法的引用去执行方法，其中source:为要执行的方法所属的对象，
                        // 方法如果没有参数第二个参数则为null;
                        List valueList = (List) props[i].getReadMethod().invoke(source);
                        if (valueList == null) {
                            valueList = new ArrayList();
                        }
                        for (Object value : valueList) {
                            Object cloneValue = null;
                            if (value.getClass().getName().indexOf(ENTITY_CLASS_PACKAGE) >= 0) {
                                cloneValue = BeanUtils.getOneLayerClone(value);
                            } else {
                                cloneValue = value;
                            }
                            newList.add(cloneValue);
                        }
                        props[i].getWriteMethod().invoke(target, newList);
                    }
                    if (propertyType.equals(Set.class)) {
                        Set newSet = new HashSet();
                        Set valueSet = (Set) props[i].getReadMethod().invoke(source);
                        if (valueSet == null) {
                            valueSet = new HashSet();
                        }
                        for (Object value : valueSet) {
                            Object cloneValue = BeanUtils.getOneLayerClone(value);
                            newSet.add(cloneValue);
                        }
                        props[i].getWriteMethod().invoke(target, newSet);
                    } else {
                        // 如果是array 跳过 //FIXME
                        if (propertyType.equals(Arrays.class)) {
                            continue;
                        }
                        if (propertyType.toString().startsWith(ENTITY_CLASS_PACKAGE)) {
                            Object value = props[i].getReadMethod().invoke(source);
                            Object cloneValue = BeanUtils.getOneLayerClone(value);
                            props[i].getWriteMethod().invoke(target, cloneValue);
                        }
                    }
                }
            }
        } catch (Exception e) {
            logger.error("clone object exception object class:" + source.getClass(), e);
        }
        return target;
    }
691427
function lex(source) {
    var tokens = [];
    var chunk = clean(source);
    var total = chunk.length;
    var iterations = 0;

    while (chunk.length > 0) {
        for (var regexpName in REGEXPS) {
            var regexp = REGEXPS[regexpName];
            var match = regexp.exec(chunk);

            if (match) {
                var original = match[0];
                var str = original;
                if (regexpName === 'string') str = str.replace(/\\"/g, '"');
                tokens.push({ type: regexpName, string: str, original: original });
                // Need to slice the chunk at the original match length
                chunk = chunk.slice(match[0].length, chunk.length);
                break;
            }
        }

        // We've probably failed to parse correctly if we get here
        if (iterations++ > total) {
            var parts = [
                'Runiq: Lexer ran too many iterations!',
                '--- Failed at chunk: `' + chunk + '`'
            ];
            throw new Error(parts.join('\n'));
        }
    }

    return tokens;
}
470828
function compact(source) {
    if (!source) return null;

    if (isArray(source))
        return compactArray(source);

    if (typeof source == 'object')
        return compactObject(source);

    return source;
}
227325
function mix(target, source) {
        var args = _arrSlice.call(arguments),
            i = 1,
            key, self = arguments.callee,
            //如果最后参数是布尔，判定是否覆写同名属性
            ride = $.isBoolean(args[args.length - 1]) ? args.pop() : true;
        if(args.length === 1) {
            target = !this.window ? this : _cleanObj;
            i = 0;
        }

        while((source = args[i++])) {
            //source = [{a:1},{b:3}];
            if($.isArray(source)) {
                for(var n = 0, len = source.length; n < len; n++) {
                    self(target, source[n], ride);
                }

                continue;
            }
            //杂糅只允许对象
            for(key in source) {
                if(ride || !(key in target)) {
                    target[key] = source[key];
                }
            }
        }
        return target;
    }
1222465
function normalizeSourceSet(data) {
	var sourceSet = data.srcSet || data.srcset;

	if (Array.isArray(sourceSet)) {
		return sourceSet.join();
	}

	return sourceSet;
}
783007
function(object) {
      if (arguments.length > 1)
        return map(toArray(arguments), function(arg){
          return puts(arg)
        }).join(', ')
      if (object === undefined) return 'undefined'
      if (object === null) return 'null'
      if (object === true) return 'true'
      if (object === false) return 'false'
      if (object.an_instance_of) return 'an instance of ' + object.an_instance_of.name
      if (object.jquery && object.selector.length > 0) return 'selector ' + puts(object.selector)
      if (object.jquery) return object.get(0).outerHTML
      if (object.nodeName) return object.outerHTML
      switch (object.constructor) {
        case Function: return object.name || object 
        case String: 
          return '"' + object
            .replace(/"/g,  '\\"')
            .replace(/\n/g, '\\n')
            .replace(/\t/g, '\\t')
            + '"'
        case Array: 
          return inject(object, '[', function(b, v){
            return b + ', ' + puts(v)
          }).replace('[,', '[') + ' ]'
        case Object:
          object.__hit__ = true
          return inject(object, '{', function(b, k, v) {
            if (k == '__hit__') return b
            return b + ', ' + k + ': ' + (v && v.__hit__ ? '<circular reference>' : puts(v))
          }).replace('{,', '{') + ' }'
        default: 
          return object.toString()
      }
    }
1158448
function(s) {
    try {
        const re = new RegExp(s);
        return re.source;
    } catch (ex) {
        normalizeRegexSource.message = ex.toString();
    }
    return '';
}