Parses a string value representing a key-value-map separated by sep1 and
sep2 into an Object.

Ex.:
- parseKeyValue('a=1;b=2', ';', '=') => { a: 1, b: 2 }

@private
337639
function parseKeyValue (str, sep1, sep2) {
  var result = {}
  str.split(sep1).forEach(function (kv) {
    if (kv.length > 0) {
      kv = kv.split(sep2, 2)
      result[kv[0]] = parseValue(kv[1])
    }
  })
  return result
}
416872
function parseObject(obj){
  obj = obj.vals;
  for (var key in obj) {
    var nodes = obj[key].nodes[0].nodes;
    if (nodes && nodes.length) {
      obj[key] = [];
      for (var i = 0, len = nodes.length; i < len; ++i) {
        obj[key].push(convert(nodes[i]));
      }
    } else {
      obj[key] = convert(obj[key].first);
    }
  }
  return obj;

  function convert(node){
    switch (node.nodeName) {
      case 'object':
        return parseObject(node);
      case 'boolean':
        return node.isTrue;
      case 'unit':
        return node.type ? node.toString() : +node.val;
      case 'string':
      case 'literal':
        return node.val;
      default:
        return node.toString();
    }
  }
}
556874
function parsePrimitives(info, name, value) {
  var index
  var length
  var result

  if (typeof value !== 'object' || !('length' in value)) {
    return parsePrimitive(info, name, value)
  }

  length = value.length
  index = -1
  result = []

  while (++index < length) {
    result[index] = parsePrimitive(info, name, value[index])
  }

  return result
}
917327
def extract_key_values(array_value, separators=(';', ',', ':'), **kwargs):
    
    items_sep, fields_sep, keys_sep = separators
    return items_sep.join(fields_sep.join(keys_sep.join(x) for x in sorted(it.items()))
                          for it in array_value)
1053616
function parseObjectArrayField(row, key, value) {

    var obj_array = [];

    if (value) {
        if (value.indexOf(',') !== -1) {
            obj_array = value.split(',');
        } else {
            obj_array.push(value.toString());
        };
    };

    // if (typeof(value) === 'string' && value.indexOf(',') !== -1) {
    //     obj_array = value.split(',');
    // } else {
    //     obj_array.push(value.toString());
    // };

    var result = [];

    obj_array.forEach(function(e) {
        if (e) {
            result.push(array2object(e.split(';')));
        }
    });

    row[key] = result;
}
8613
function extractKeyValue (line) {
  var kv = {
    key: undefined,
    value: undefined,
  };

  var matches = kvRE.exec(line);
  if (matches !== null && matches.length === 3) {
    kv.key = matches[1];
    kv.value = matches[2];
  }

  return kv;
}
1279670
function parseLoopStatement (input) {
  let current = 0
  let char = input[current]

  // parse through keys `each **foo, bar** in x`, which is everything before
  // the word "in"
  const keys = []
  let key = ''
  while (!`${char}${lookahead(3)}`.match(/\s(in|of)\s/)) {
    key += char
    next()

    // if we hit a comma, we're on to the next key
    if (char === ',') {
      keys.push(key.trim())
      key = ''
      next()
    }

    // if we reach the end of the string without getting "in/of", it's an error
    if (typeof char === 'undefined') {
      throw new Error("Loop statement lacking 'in' or 'of' keyword")
    }
  }
  keys.push(key.trim())

  // detect whether it's an in or of
  const loopType = lookahead(2)

  // space before, in/of, space after
  next(4)

  // the rest of the string is evaluated as the array/object to loop
  let expression = ''
  while (current < input.length) {
    expression += char
    next()
  }

  return {keys, expression, loopType}

  // Utility: Move to the next character in the parse
  function next (n = 1) {
    for (let i = 0; i < n; i++) { char = input[++current] }
  }

  // Utility: looks ahead n characters and returns the result
  function lookahead (n) {
    let counter = current
    const target = current + n
    let res = ''
    while (counter < target) {
      res += input[++counter]
    }
    return res
  }
}
1147453
function (key, value) {
            var self = this,
                _queryMap,
                currentValue;
            if (typeof key == 'string') {
                parseQuery(self);
                _queryMap = self._queryMap;
                currentValue = _queryMap[key];
                if (currentValue === undefined) {
                    currentValue = value;
                } else {
                    currentValue = [].concat(currentValue).concat(value);
                }
                _queryMap[key] = currentValue;
            } else {
                if (key instanceof Query) {
                    key = key.get();
                }
                for (var k in key) {
                    self.add(k, key[k]);
                }
            }
            return self;
        }
748477
function parse( value ) {
	var err;
	if ( !isString( value ) ) {
		return new TypeError( 'invalid input argument. Must provide a string primitive. Value: `' + value + '`.' );
	}
	try {
		return toml.parse( value );
	} catch ( error ) {
		err = error.message;
		err += ' Line: '+error.line+'.';
		err += ' Column: '+error.column+'.';
		return new SyntaxError( err );
	}
}
53471
function parseValue(expr) {
  switch(expr.kind) {
    case 'array':
      if (expr.items.length === 0) {
        return [];
      }
      var isKeyed = expr.items.every((item) => item.key !== null)
      var items = expr.items.map(parseValue)
      if (isKeyed) {
        items = items.reduce((acc, val) => Object.assign({}, acc, val), {})
      }
      return items
    case 'entry':
      if (expr.key) {
        return { [parseKey(expr.key)]: parseValue(expr.value) }
      }
      return parseValue(expr.value)
    case 'string':
      return expr.value
    case 'number':
      return parseInt(expr.value, 10)
    case 'boolean':
      return expr.value
    default:
      throw new Error(`Unexpected PHP value: "${expr.kind}", details: ${JSON.stringify(expr)}`)
  }
}
1340066
function parseString(str) {
    var obj = {};
    var pairs = str.split('&');
    var parts;
    var pair;

    for (var i = 0, len = pairs.length; i < len; ++i) {
        pair = pairs[i];
        parts = pair.split('=');
        obj[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);
    }

    return obj;
}
645908
def from_string(line):
        
        result = StringValueMap()
        
        if line == None or len(line) == 0:
            return result

        tokens = str(line).split(';')
        for token in tokens:
            if len(token) == 0:
                continue
            index = token.find('=')
            key = token[0:index] if index >= 0 else token
            value = token[index + 1:] if index >= 0 else None
            result.put(key, value)

        return result
972383
public static function splitIntoKeyValue(string $string, string $separator, array $keys): array
    {
        $parts = explode($separator, $string);
        $result = [];
        if (count($keys) > 0) {

            // Make sure arrays has equal number of items.
            if (count($parts) > count($keys)) {
                $parts = array_slice($parts, 0, count($keys));
            }
            if (count($keys) > count($parts)) {
                $keys = array_slice($keys, 0, count($parts));
            }

            $result = array_combine($keys, $parts);
        }
        return $result;
    }
678306
function parseObject( str ) {
	var obj = parseJSON( str );
	if ( obj instanceof Error ) {
		return new TypeError( 'invalid value. Unable to parse string as a JSON object. Value: `' + str + '`. Error: `' + obj.message + '`.' );
	}
	return obj;
}
986576
function parseQueryStringItemValue(key, value) {
  if (Array.isArray(value)) {
    // deduplicate and simplify arrays
    value = value.filter((v, idx) => value.indexOf(v) === idx);
    if (value.length === 1) value = value[0];
  } else if (value.indexOf(':') > 0) {
    value = value.split(',').reduce((result, pair) => {
      const parts = pair.split(':');
      result[parts[0]] = parseQueryStringItemValue(key, parts[1]);
      return result;
    }, {});
  } else if (value.indexOf(',') > 0) {
    value = value.split(',').map(v => {
      return parseQueryStringItemValue(key, v);
    });
  } else if (value.toLowerCase() === 'true' || value.toLowerCase() === 'false') {
    value = value.toLowerCase() === 'true';
  } else if (!Number.isNaN(value) && !STRING_OPTIONS.has(key)) {
    const numericValue = parseFloat(value);
    if (!Number.isNaN(numericValue)) {
      value = parseFloat(value);
    }
  }

  return value;
}
473473
function parseValues(obj) {
        Object.keys(obj).forEach(function (key) {
            obj[key] = parseValue(obj[key]);
        });
        return obj;
    }
1098138
function parseString(str) {
  var obj = {};
  var pairs = str.split('&');
  var pair;
  var pos;

  for (var i = 0, len = pairs.length; i < len; ++i) {
    pair = pairs[i];
    pos = pair.indexOf('=');
    if (pos == -1) {
      obj[decodeURIComponent(pair)] = '';
    } else {
      obj[decodeURIComponent(pair.slice(0, pos))] =
        decodeURIComponent(pair.slice(pos + 1));
    }
  }

  return obj;
}