Rebuild array back into newline delimited,
merging .gitignore, .npmignore extras &
comments (expcted output).

@param  {String} `str`
@return {Array}
@api private
330976
function format(git, npm) {
  git = Array.isArray(git) ? git.join('\n') : git;
  npm = Array.isArray(npm) ? npm.join('\n') : npm;

  var res = '';

  if (git) {
    res += git;
  }

  if (npm) {
    res += '\n\n' + comment + '\n'+ npm;
  }

  return res;
}
1250926
function(str) {
            var root, error = null;

            i = j = current = 0;
            chunks = [];
            input = str.replace(/\r\n/g, '\n');
            if (env.filename) {
                that.env.inputs[env.filename] = input;
            }

            // Split the input into chunks.
            chunks = (function (chunks) {
                var j = 0,
                    skip = /(?:@\{[\w-]+\}|[^"'`\{\}\/\(\)\\])+/g,
                    comment = /\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g,
                    string = /"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'|`((?:[^`]|\\.)*)`/g,
                    level = 0,
                    match,
                    chunk = chunks[0],
                    inParam;

                for (var i = 0, c, cc; i < input.length;) {
                    skip.lastIndex = i;
                    match = skip.exec(input);
                    if (match) {
                        if (match.index === i) {
                            i += match[0].length;
                            chunk.push(match[0]);
                        }
                    }
                    c = input.charAt(i);
                    comment.lastIndex = string.lastIndex = i;

                    match = string.exec(input)
                    if (match) {
                        if (match.index === i) {
                            i += match[0].length;
                            chunk.push(match[0]);
                            continue;
                        }
                    }

                    if (!inParam && c === '/') {
                        cc = input.charAt(i + 1);
                        if (cc === '/' || cc === '*') {
                            match = comment.exec(input);
                            if (match) {
                                if (match.index === i) {
                                    i += match[0].length;
                                    chunk.push(match[0]);
                                    continue;
                                }
                            }
                        }
                    }

                    switch (c) {
                        case '{':
                            if (!inParam) {
                                level ++;
                            }
                            else {
                                inParam = false;
                            }
                            chunk.push(c);
                            break;
                        case '}':
                            if (!inParam) {
                                level --;
                                chunk.push(c);
                                chunks[++j] = chunk = [];
                            }
                            else {
                                inParam = false;
                                chunk.push(c);
                            }
                            break;
                        case '(':
                            if (!inParam) {
                                inParam = true;
                            }
                            else {
                                inParam = false;
                            }
                            chunk.push(c);
                            break;
                        case ')':
                            if (inParam) {
                                inParam = false;
                            }
                            chunk.push(c);
                            break;
                        default:
                            chunk.push(c);
                    }

                    i++;
                }
                if (level !== 0) {
                    error = {
                        index: i - 1,
                        message: (level > 0) ? "missing closing `}`" : "missing opening `{`",
                        filename: env.filename
                    };
                }

                return chunks.map(function (c) { return c.join(''); });
            })([[]]);

            if (error) {
                util.error(env, error);
                throw new Error('N/A');
            }

            // Start with the primary rule.
            // The whole syntax tree is held under a Ruleset node,
            // with the `root` property set to true, so no `{}` are
            // output.
            root = new tree.Ruleset([], $(this.parsers.primary));
            root.root = true;

            // Get an array of Ruleset objects, flattened
            // and sorted according to specificitySort
            root.toList = (function() {
                return function(env) {
                    env.frames = env.frames || [];


                    // call populates Invalid-caused errors
                    var definitions = this.flatten([], [], env);
                    definitions.sort(specificitySort);
                    return definitions;
                };
            })();

            // Sort rules by specificity: this function expects selectors to be
            // split already.
            //
            // Written to be used as a .sort(Function);
            // argument.
            //
            // [1, 0, 0, 467] > [0, 0, 1, 520]
            var specificitySort = function(a, b) {
                var as = a.specificity;
                var bs = b.specificity;

                if (as[0] != bs[0]) return bs[0] - as[0];
                if (as[1] != bs[1]) return bs[1] - as[1];
                if (as[2] != bs[2]) return bs[2] - as[2];
                return bs[3] - as[3];
            };

            return root;
        }
1304421
def rebuild(str)
      extract_root_pivot(str)

      list = (get_array.select {|entry| entry.start_with?(@pivot)}).sort

      @cycler = list.empty? ? nil : list.cycle
    end
2095
function(str, options = {}) {
    var comment, current, data, lines, stack;
    lines = string.lines(str);
    current = data = {};
    stack = [current];
    comment = options.comment || ';';
    lines.forEach(function(line, _, __) {
      var depth, match, parent;
      if (!line || line.match(/^\s*$/)) {
        return;
      }
      // Category
      if (match = line.match(/^\s*(\[+)(.+?)(\]+)\s*$/)) {
        depth = match[1].length;
        // Add a child
        if (depth === stack.length) {
          parent = stack[depth - 1];
          parent[match[2]] = current = {};
          stack.push(current);
        }
        // Invalid child hierarchy
        if (depth > stack.length) {
          throw Error(`Invalid child ${match[2]}`);
        }
        // Move up or at the same level
        if (depth < stack.length) {
          stack.splice(depth, stack.length - depth);
          parent = stack[depth - 1];
          parent[match[2]] = current = {};
          return stack.push(current);
        }
      // comment
      } else if (comment && (match = line.match(RegExp(`^\\s*(${comment}.*)$`)))) {
        return current[match[1]] = null;
      // key value
      } else if (match = line.match(/^\s*(.+?)\s*=\s*(.+)\s*$/)) {
        return current[match[1]] = match[2];
      // else
      } else if (match = line.match(/^\s*(.+?)\s*$/)) {
        return current[match[1]] = null;
      }
    });
    return data;
  }
802360
function _clearRepeat(str) {
  let ret = '',
    i = 0,
    l = str.length,
    char;

  for (; i < l; i++) {
    char = str[i];
    if (ret.indexOf(char) < 0) {
      ret += char;
    }
  }

  return ret;
}
42690
def replace(pretty, old_str, new_str):
    
    out_str = ''
    line_number = 1
    changes = 0
    for line in pretty.splitlines(keepends=True):
        new_line = line.replace(old_str, new_str)
        if line.find(old_str) != -1:
            logging.debug('%s', line_number)
            logging.debug('< %s', line)
            logging.debug('> %s', new_line)
            changes += 1
        out_str += new_line
        line_number += 1

    logging.info('Total changes(%s): %s', old_str, changes)
    return out_str
1038786
function(line) {
        var newLine;

        // ex: [foo <- 1,2,3]
        // [        opening array
        //   (.*)   $1 array to concat into
        //   (<-)   $2
        //   (.*)   $3 content to be merged
        // ]        closing array
        var regexArr = /\[(.*)(\<\-)(.*)\]/;

        // ex: {foo <- foo: true, bar: 2}
        // {        opening object
        //   (.*)   $1 obj to merge into
        //   (<-)   $2
        //   (.*)   $3 content to be merged
        // }        closing object
        var regexObj = /\{(.*)(\<\-)(.*)\}/;

        newLine = line.replace(regexArr, function($0, $1, $2, $3) {
            return $1.trim() + '.concat([' + $3 + ']);';
        });

        return newLine.replace(regexObj, function($0, $1, $2, $3) {
            return $1.trim() + '.merge({' + $3 + '});';
        });
    }
71790
function parse (str, options) {
  var tokens = []
  var key = 0
  var index = 0
  var path = ''
  var defaultDelimiter = (options && options.delimiter) || DEFAULT_DELIMITER
  var delimiters = (options && options.delimiters) || DEFAULT_DELIMITERS
  var pathEscaped = false
  var res

  while ((res = PATH_REGEXP.exec(str)) !== null) {
    var m = res[0]
    var escaped = res[1]
    var offset = res.index
    path += str.slice(index, offset)
    index = offset + m.length

    // Ignore already escaped sequences.
    if (escaped) {
      path += escaped[1]
      pathEscaped = true
      continue
    }

    var prev = ''
    var next = str[index]
    var name = res[2]
    var capture = res[3]
    var group = res[4]
    var modifier = res[5]

    if (!pathEscaped && path.length) {
      var k = path.length - 1

      if (delimiters.indexOf(path[k]) > -1) {
        prev = path[k]
        path = path.slice(0, k)
      }
    }

    // Push the current path onto the tokens.
    if (path) {
      tokens.push(path)
      path = ''
      pathEscaped = false
    }

    var partial = prev !== '' && next !== undefined && next !== prev
    var repeat = modifier === '+' || modifier === '*'
    var optional = modifier === '?' || modifier === '*'
    var delimiter = prev || defaultDelimiter
    var pattern = capture || group

    tokens.push({
      name: name || key++,
      prefix: prev,
      delimiter: delimiter,
      optional: optional,
      repeat: repeat,
      partial: partial,
      pattern: pattern ? escapeGroup(pattern) : '[^' + escapeString(delimiter) + ']+?'
    })
  }

  // Push any remaining characters.
  if (path || index < str.length) {
    tokens.push(path + str.substr(index))
  }

  return tokens
}
802734
function fixIndent(str: string): string {
  const trimmedStr = str
    .replace(/^\n*/m, '') //  remove leading newline
    .replace(/[ \t]*$/, ''); // remove trailing spaces and tabs
  const indentMatch = /^[ \t]*/.exec(trimmedStr);
  invariant(Array.isArray(indentMatch));
  const indent = indentMatch[0]; // figure out indent
  return trimmedStr.replace(RegExp('^' + indent, 'mg'), ''); // remove indent
}
855726
function strCompact(str) {
        return this.trim(str).replace(/([\r\n\s])+/g, function (match, whitespace) {
            return whitespace === '　' ? whitespace : ' ';
        });
    }
1158559
function stringify (obj, replacer, spacer) {
  decirc(obj, '', [], undefined)
  var res = JSON.stringify(obj, replacer, spacer)
  while (arr.length !== 0) {
    var part = arr.pop()
    part[0][part[1]] = part[2]
  }
  return res
}
14797
function(str) {
  var deliminator_stack = [];
  var length = str.length;
  var i;
  var parts = [];
  var current_part = '';
  var opening_index;
  var closing_index;
  for (i = 0; i < length; i++) {
    opening_index = opening_deliminators.indexOf(str[i]);
    closing_index = closing_deliminators.indexOf(str[i]);
    if (is_space.test(str[i])) {
      if (deliminator_stack.length === 0) {
        if (current_part !== '') {
          parts.push(current_part);
        }
        current_part = '';
      } else {
        current_part += str[i];
      }
    } else {
      if (str[i] === '\\') {
        i++;
        current_part += str[i];
      } else {
        current_part += str[i];
        if (
          closing_index !== -1 &&
          closing_index === deliminator_stack[deliminator_stack.length - 1]
        ) {
          deliminator_stack.pop();
        } else if (opening_index !== -1) {
          deliminator_stack.push(opening_index);
        }
      }
    }
  }
  if (current_part !== '') {
    parts.push(current_part);
  }
  return parts;
}
1099687
function(str, delimiter){

	var retlist = null;

	if( ! us.isUndefined(str) ){
	    if( us.isUndefined(delimiter) ){
		delimiter = /\s+/;
	    }
	    
	    retlist = str.split(delimiter);
	}

	return retlist;
    }
241964
function stringRepeat (str, count) {
  var rest = '' + str
  if (str.repeat) {
    return str.repeat(count)
  }
  var list = isNaN(count) ? [] : new Array(parseInt(count))
  return list.join(rest) + (list.length > 0 ? rest : '')
}
638200
private String removeEnclosedCurlyBraces( String str ) {
        final char curlyReplacement = 6;

        char[] chars = str.toCharArray();
        int open = 0;
        for ( int i = 0; i < chars.length; i++ ) {
            if ( chars[i] == '{' ) {
                if ( open != 0 ) chars[i] = curlyReplacement;
                open++;
            }
            else if ( chars[i] == '}' ) {
                open--;
                if ( open != 0 ) {
                    chars[i] = curlyReplacement;
                }
            }
        }

        char[] res = new char[chars.length];
        int j = 0;
        for( int i = 0; i < chars.length; i++ ) {
            if( chars[i] != curlyReplacement ) {
                res[j++] = chars[i];
            }
        }

        return new String( Arrays.copyOf( res, j ) );
    }
1108606
protected String[] splitToChunks(String str)
    {
        String delimiter = "[|>]";
        String[] chunks = str.split(delimiter);
        return chunks;
    }
671817
function fixList(str) {
  str = str.replace(/([ ]{1,4}[+-] \[?[^)]+\)?)\n\n\* /gm, '$1\n* ');
  str = str.split('__{_}_*').join('**{*}**');
  return str;
}