Helper function to avoid code repetition
549491
function(dependencies) {
        var _dependencies = dependencies || {};
        var _numberOfOudatedPackages = Object.keys(_dependencies).length;
        var _minor = semver.allMinor(dependencies, 'latest');
        var _major = semver.allMajor(dependencies, 'latest');
        var _patch = semver.allPatch(dependencies, 'latest`');
        var _passing = (
          options['up-to-dateness'].number >= _numberOfOudatedPackages &&
          _major.passing === true &&
          _minor.passing === true &&
          _patch.passing === true
        );

        return {
          passing: _passing,
          outdated: _.merge(_major.outdated, _minor.outdated, _patch.outdated)
        };
      }
374502
function repeatString(string, nb) {
    var s = string,
        l,
        i;

    if (nb <= 0)
      return '';

    for (i = 1, l = nb | 0; i < l; i++)
      s += string;
    return s;
  }
918650
function dummyMarkdown() {
    var codeBlock = /^```/;
    var quoteBlock = /^>/;
    var listBlock = /^\* /;

    var commentInline = '<!--.*-->';
    var codeInline = '`.+`';

    function split(content) {
        var pattern = new RegExp([commentInline, codeInline].join('|'), 'g');
        var result = null;
        var last = 0;
        var output = [];

        while ((result = pattern.exec(content)) !== null) {
            output.push({ transform: true, content: content.slice(last, result.index)});
            output.push({ transform: false, content: result[0]});
            last = pattern.lastIndex;
        }

        output.push({ transform: true, content: content.slice(last)});

        return output;
    }

    return function (input) {
        var output = [];
        var lines = input.split('\n');

        for (var l = 0; l < lines.length; l++) {
            var line = lines[l];
            var e;
            var content;

            if (codeBlock.test(line)) {
                e = l + 1;
                while (!codeBlock.test(lines[e])) {
                    e++;
                }

                output.push({ transform: false, content: lines.slice(l, e + 1).join('\n') + '\n\n' });
                l = e;
            } else if (quoteBlock.test(line)) {
                e = l + 1;
                while (quoteBlock.test(lines[e])) {
                    e++;
                }

                content = [line].concat(lines.slice(l + 1, e).map(function (nextLine) {
                    return nextLine.slice(2);
                })).join(' ') + '\n\n';

                output = output.concat(split(content));
                l = e - 1;
            } else if (listBlock.test(line)) {
                e = l + 1;
                while (lines[e] !== '') {
                    if (!listBlock.test(lines[e])) {
                        lines[e - 1] += ' ' + lines[e];
                        lines[e] = '';
                    }
                    e++;
                }

                content = lines.slice(l, e).filter(function (line) {
                    return line !== '';
                }).join('\n') + '\n';

                output = output.concat(split(content));
                l = e - 1;
            } else if (line !== '') {
                e = l + 1;
                while (lines[e] !== '') {
                    e++;
                }

                content = lines.slice(l, e).join(' ') + '\n\n';

                output = output.concat(split(content));
                l = e - 1;
            }
        }

        return output;
    };
}
1111070
function cleanCode(ast) {
        // Coalese BlockStatements
        treeWalk(ast, function (node, descend, path) {
            descend();
            if (node.type === 'ArrowFunctionExpression' && node.body.type === 'BlockStatement' && node.body.body.length === 1 && node.body.body[0].type === 'ReturnStatement') {
                node.body = node.body.body[0].argument;
            } else {
                var block, child;
                // If this node is a block with vanilla BlockStatements (no controlling entity), merge them
                if (block = examine(node).isBlockStatement) {
                    // Remove any empty statements from within the block
                    // For ES6, this needs more care, as blocks containing 'let/const/class' have a scope of their own
                    for (var i = 0;i < block.length; i++) {
                        if ((child = examine(block[i]).isBlockStatement) && !containsBlockScopedDeclarations(child)) {
                            if (!containsBlockScopedDeclarations(block[i])) 
                                [].splice.apply(block, [i,1].concat(child));
                        }
                    }
                }
            }
        });
        // Truncate BlockStatements with a Jump (break;continue;return;throw) inside
        treeWalk(ast, function (node, descend, path) {
            descend();
            if (examine(node).isJump) {
                var ref = path[0];
                if ('index' in ref) {
                    var i = ref.index + 1;
                    var ctn = ref.parent[ref.field];
                    while (i < ctn.length) {
                        // Remove any statements EXCEPT for function/var definitions
                        if (ctn[i].type === 'VariableDeclaration' || examine(ctn[i]).isFunction && ctn[i].id) 
                            i += 1;
                         else 
                            ctn.splice(i, 1);
                    }
                }
            }
        });
        /* Inline continuations that are only referenced once */
        // Find any continuations that have a single reference
        treeWalk(ast, function (node, descend, path) {
            descend();
            if (node.$thisCall && continuations[node.name]) {
                if (continuations[node.name].ref) {
                    delete continuations[node.name]; //    Multiple ref
                } else {
                    continuations[node.name].ref = node.$thisCall;
                }
            }
        });
        var calls = Object.keys(continuations).map(function (c) {
            return continuations[c].ref;
        });
        if (calls.length) {
            // Replace all the calls to the continuation with the body from the continuation followed by 'return;'
            treeWalk(ast, function (node, descend, path) {
                descend();
                if (calls.indexOf(node) >= 0) {
                    if (path[1].self.type === 'ReturnStatement') {
                        var sym = node.$thisCallName;
                        var repl = cloneNode(continuations[sym].def.body.body);
                        continuations[sym].$inlined = true;
                        if (!examine(path[1].self).isJump) 
                            repl.push({
                            type: 'ReturnStatement'
                        });
                        path[1].replace(repl);
                    }
                }
            });
            var defs = Object.keys(continuations).map(function (c) {
                return continuations[c].$inlined && continuations[c].def;
            });
            // Remove all the (now inline) declarations of the continuations
            treeWalk(ast, function (node, descend, path) {
                descend();
                if (defs.indexOf(node) >= 0) {
                    path[0].remove();
                }
            });
        }
        // Hoist generated FunctionDeclarations within ES5 Strict functions (actually put them at the
        // end of the scope-block, don't hoist them, it's just an expensive operation)
        if (!looksLikeES6) {
            var useStrict = isStrict(ast);
            (function (ast) {
                treeWalk(ast, function (node, descend, path) {
                    if (node.type === 'Program' || node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') {
                        var wasStrict = useStrict;
                        useStrict = useStrict || isStrict(node);
                        if (useStrict) {
                            descend();
                            var functionScope = node.type === 'Program' ? node : node.body;
                            var functions = scopedNodes(functionScope, function (n, path) {
                                if (n.type === 'FunctionDeclaration') {
                                    return path[0].parent !== functionScope;
                                }
                            },['isScope']);
                            functions = functions.map(function (path) {
                                return path[0].remove();
                            });
                            [].push.apply(functionScope.body, functions);
                        } else {
                            descend();
                        }
                        useStrict = wasStrict;
                    } else {
                        descend();
                    }
                });
            })(ast);
        }
        /*
        function replaceSymbols(ast,from,to) {
            treeWalk(ast,function(node,descend,path){
                descend() ;
                if (node.type=='Identifier' && node.name==from) {
                    node.name = to ;
                }
            }) ;
            return ast ;
        }

        // Find declarations of functions of the form:
        //     function [sym]() { return _call_.call(this) }
        // or
        //     function [sym]() { return _call_() }
        // and replace with:
        //    _call_
        // If the [sym] exists and is referenced elsewhere, replace those too. This
        // needs to be done recursively from the bottom of the tree upwards.
        // NB: If _call_ is in the parameter list for the function, this is NOT a correct optimization


        // The symbol folding above might generate lines like:
        //    $return.$asyncbind(this,$error)
        // these can be simplified to:
        //    $return
        */
        // Remove all the 'hidden' node info generated during transformation
        treeWalk(ast, function (node, descend, path) {
            descend();
            Object.keys(node).filter(function (k) {
                return k[0] === '$';
            }).forEach(function (k) {
                delete node[k];
            });
        });
        return ast;
    }
1163248
function repeat_string(str, i) {
        if (i <= 0) return "";
        if (i == 1) return str;
        var d = repeat_string(str, i >> 1);
        d += d;
        if (i & 1) d += str;
        return d;
}
846938
function repeat(string, times) {
            var result = ""
            // Optimized repeat function concatenates concatenated
            // strings.
            while (times > 0) {
                if (times & 1) result += string
                times >>= 1
                string += string
            }
            return result
        }
965673
def _maybe_repeat(self, x):
    
    if isinstance(x, list):
      assert len(x) == self.n
      return x
    else:
      return [x] * self.n
140247
def reject_recursive_repeats(to_wrap):
    
    to_wrap.__already_called = {}

    @functools.wraps(to_wrap)
    def wrapped(*args):
        arg_instances = tuple(map(id, args))
        thread_id = threading.get_ident()
        thread_local_args = (thread_id,) + arg_instances
        if thread_local_args in to_wrap.__already_called:
            raise ValueError('Recursively called %s with %r' % (to_wrap, args))
        to_wrap.__already_called[thread_local_args] = True
        try:
            wrapped_val = to_wrap(*args)
        finally:
            del to_wrap.__already_called[thread_local_args]
        return wrapped_val
    return wrapped
1214952
function clean(code) {

    try {
        const ast = babylon.parse(code, {
            // parse in strict mode and allow module declarations
            sourceType: 'module',
            plugins: [
                // enable jsx and flow syntax
                'jsx',
                'flow'
            ]
        });

        const cleanAst = strip(ast).program;

        const resultCode = generate(cleanAst, {}).code;

        return resultCode.replace(/(\/\*\$ | \#\*\/)/g, '');

    } catch (e) {
        console.log(code);
        throw e;
    }
}
31257
function repeat(ch, count)
{
    var s = '';
    for(var i = 0; i < count; i++)
        s += ch;
    return s;
}
564008
def _avoid_duplicate_arrays(types):
    
    arrays = [t for t in types if isinstance(t, dict) and t["type"] == "array"]
    others = [t for t in types if not (isinstance(t, dict) and t["type"] == "array")]
    if arrays:
        items = set([])
        for t in arrays:
            if isinstance(t["items"], (list, tuple)):
                items |= set(t["items"])
            else:
                items.add(t["items"])
        if len(items) == 1:
            items = items.pop()
        else:
            items = sorted(list(items))
        arrays = [{"type": "array", "items": items}]
    return others + arrays
1157465
def _clean_code(self, code):
        
        lines = code.split("\n")
        min_indent = 100
        for line in lines:
            if line.strip() != "":
                indent = len(line) - len(line.lstrip())
                min_indent = min(indent, min_indent)
        if min_indent > 0:
            lines = [line[min_indent:] for line in lines]
        code = "\n".join(lines)
        return code
667032
def _clean_code(code):
    
    lines = []
    # cleanup lines, the parser is very sensitive to extra spaces,...
    for l in code.splitlines():
        # remove last .
        if l.endswith('.'):
            l = l[:-1]
        # the parser doe not like VALUE xxx.
        if "VALUE" in l:
            l = l[:l.find("VALUE")]
        # the parser does not like extra spaces between "PIC X(xxx)" and "."
        indent = len(l) - len(l.lstrip())
        tokens = l.split(" ")
        while "" in tokens:
            tokens.remove("")
        if tokens and not tokens[-1].endswith("."):
            tokens[-1] += "."
        lines.append(" " * indent + " ".join(tokens))

    return lines
1359857
function DuplicateCommandError(msg, more) {
  // Pass the constructor to V8's
  // captureStackTrace to clean up the output
  Error.captureStackTrace(this, DuplicateCommandError);

  // If defined, store a custom error message
  if (msg) {
    this.message = msg;
  }

  // If defined, store more infos
  if (more) {
    this.more = more;
  }
}
1212753
def optimized(code, silent=True, ignore_errors=True):
    """"""
    return constant_fold(code, silent=silent, ignore_errors=ignore_errors)
321059
function uniq(srcArr, pathStr, isDeep) {
      if (isUdf(isDeep)) isDeep = true;
      if (isBol(pathStr)) isDeep = pathStr, pathStr = UDF;
      pathStr = typeVal(pathStr, 'str');
      var tmpArr = srcArr.slice(), i = -1;
      while (++i < tmpArr.length - 1) {
        for (var j = i + 1; j < tmpArr.length; j++) {
          var isDuplicate;
          if (pathStr) {
            var val1 = get(tmpArr[i], pathStr), val2 = get(tmpArr[j], pathStr);
            isDuplicate = isDeep ? isDeepEqual(val1, val2) : val1 === val2;
          } else {
            isDuplicate = isDeep ? isDeepEqual(tmpArr[i], tmpArr[j]) : tmpArr[i] === tmpArr[j];
          }
          if (isDuplicate) tmpArr.splice(j--, 1);
        }
      }
      return tmpArr;
    }
796961
def fix_repeating_arguments(self):
        """"""
        either = [list(child.children) for child in transform(self).children]
        for case in either:
            for e in [child for child in case if case.count(child) > 1]:
                if type(e) is Argument or type(e) is Option and e.argcount:
                    if e.value is None:
                        e.value = []
                    elif type(e.value) is not list:
                        e.value = e.value.split()
                if type(e) is Command or type(e) is Option and e.argcount == 0:
                    e.value = 0
        return self