copied mostly from node-glob cc @isaacs
176431
function isNotAPattern(pattern) {
  let set = new Minimatch(pattern).set;
  if (set.length > 1) {
    return false;
  }

  for (let j = 0; j < set[0].length; j++) {
    if (typeof set[0][j] !== 'string') {
      return false;
    }
  }

  return true;
}
1063421
function(nodePath) {
        createdGlobals = {};
        filenameNoExtCache = null;

        var node = nodePath.node;
        var contents = node.body;
        node.body = [t.expressionStatement(t.callExpression(
          t.memberExpression(
            t.functionExpression(null, [], t.blockStatement(contents)),
            t.identifier('call'),
            false
          ),
          [t.identifier('this')]
        ))];
      }
406002
function runGlob(args, opts, cb) {
  var dotIdx = args.indexOf('.');
  if (dotIdx !== -1) {
    args.splice(dotIdx, 1);
  }
  glob(args, opts, function(err, globbed) {
    if (Array.isArray(globbed) && dotIdx !== -1) globbed.push('.');
    cb(err, globbed);
  });
}
560393
function globalyzer(pattern, opts = {}) {
  let base = parent(pattern, opts);
  let isGlob = isglob(pattern, opts);
  let glob;

  if (base != '.') {
    glob = pattern.substr(base.length);
    if (glob.startsWith('/')) glob = glob.substr(1);
  } else {
    glob = pattern;
  }

  if (!isGlob) {
    base = path.dirname(pattern);
    glob = base !== '.' ? pattern.substr(base.length) : pattern;
  }

  if (glob.startsWith('./')) glob = glob.substr(2);
  if (glob.startsWith('/')) glob = glob.substr(1);

  return { base, glob, isGlob };
}
947781
function(localStorage,paths,namespace) {

	var pathGraph = '',
		nodeGraph = '',
		rootNodeGraph = '',
		i = 0,
		l = 0;
	
	var toIdentifier = function(src) {
		if (src.match(/\:/)) {
			var x = src.split(':');
			return x[0].replace(/[^0-9a-zA-Z]/g,'_')+':'+x[1];
		}
		return src.replace(/[^0-9a-zA-Z]/g,'_');
	};

	var toNode = function(src) {
		var kr = '',
			r = [];
			var getInnerRec = function(item) {
				var r = [],
					k = '';
				for (k in item) {
					if (item.hasOwnProperty(k)) {
						r.push(''+k+':'+JSON.stringify(item[k])
							.replace(/"/g,'\\"')
							.replace(/\{/g,'\\{')
							.replace(/\}/g,'\\}')
							.replace(/\|/g,'|')
							.replace(/\(/g,'(')
							.replace(/\)/g,')')
						);
					}
				}
				return r.join('|');
			};
		var item = JSON.parse(localStorage.getItem(namespace + '.'+src.replace(/\:.*/,'')));
		if (src.match(/\:/)) {
			for (kr in item) {
				if (item.hasOwnProperty(kr)) {
					r.push(
						(r.length ? '' : src.replace(/\:.*/,'') + '|') +
						'{ <'+kr+"> "+kr+" |{"+getInnerRec(item[kr])+'}}'
					);
				}
			}
			return toIdentifier(src) + ' [label="'+r.join('|')+'"];';
		}
		return toIdentifier(src) + ' [label="'+src+'|'+getInnerRec(item)+'"]' + ";\n";
	};
	
	for (i=0, l=paths.length; i<l; i++) {
		if (paths[i].from.match(/\:/)) {
			rootNodeGraph = rootNodeGraph + toNode(paths[i].from);
		} else {
			nodeGraph = nodeGraph + toNode(paths[i].from);
		}
		if (paths[i].to) {
			var tmp = paths[i].from.split(/[\.\:]/);
			nodeGraph = nodeGraph + toNode(tmp[0]+'.'+tmp[1]+'.'+paths[i].to);
			pathGraph = pathGraph + 
				toIdentifier(paths[i].from) + 
				' -> ' +
				toIdentifier(tmp[0]+'.'+tmp[1]+'.'+paths[i].to) +
				(paths[i].hasOwnProperty('via') ? '[label="'+paths[i].via+'"]' : '') +
				";\n";
		}
	}

	var str = 'digraph { graph [ dpi = 50 ]; rankdir="LR"; node[shape=record]; % }';
	str = str.replace('%','subgraph clusterStore { label=Roots; '+rootNodeGraph+' } %');
	str = str.replace('%',nodeGraph+' %');
	str = str.replace('%',pathGraph+' ');

	return str;
}
72977
function ls_ (req, depth, cb) {
  if (typeof cb !== "function") cb = depth, depth = 1
  mkdir(npm.cache, function (er) {
    if (er) return log.er(cb, "no cache dir")(er)
    function dirFilter (f, type) {
      return type !== "dir" ||
        ( f && f !== npm.cache + "/" + req
         && f !== npm.cache + "/" + req + "/" )
    }
    find(path.join(npm.cache, req), dirFilter, depth, function (er, files) {
      if (er) return cb(er)
      return cb(null, files.map(function (f) {
        f = f.substr(npm.cache.length + 1)
        f = f.substr((f === req ? path.dirname(req) : req).length)
             .replace(/^\//, '')
        return f
      }))
    })
  })
}
401292
function getExternals() {
    var fs = require('fs');
    var nodeModules = {};

    fs.readdirSync('node_modules').forEach(function (module) {
      if (module !== '.bin') {
        nodeModules[module] = true;
      }
    });

    var nodeModulesTransform = function(context, request, callback) {
      // search for a '/' indicating a nested module
      var slashIndex = request.indexOf("/");
      var rootModuleName;
      if (slashIndex == -1) {
        rootModuleName = request;
      } else {
        rootModuleName = request.substr(0, slashIndex);
      }

      // Match for root modules that are in our node_modules
      if (nodeModules.hasOwnProperty(rootModuleName)) {
        callback(null, "commonjs " + request);
      } else {
        callback();
      }
    };
    return nodeModulesTransform;
}
256163
function getNodeProps(node, key, opts, renderer) {
    var props = { key: key }, undef;

    // `sourcePos` is true if the user wants source information (line/column info from markdown source)
    if (opts.sourcePos && node.sourcepos) {
        props['data-sourcepos'] = flattenPosition(node.sourcepos);
    }

    var type = normalizeTypeName(node.type);

    switch (type) {
        case 'html_inline':
        case 'html_block':
            props.isBlock = type === 'html_block';
            props.escapeHtml = opts.escapeHtml;
            props.skipHtml = opts.skipHtml;
            break;
        case 'code_block':
            var codeInfo = node.info ? node.info.split(/ +/) : [];
            if (codeInfo.length > 0 && codeInfo[0].length > 0) {
                props.language = codeInfo[0];
                props.codeinfo = codeInfo;
            }
            break;
        case 'code':
            props.children = node.literal;
            props.inline = true;
            break;
        case 'heading':
            props.level = node.level;
            break;
        case 'softbreak':
            props.softBreak = opts.softBreak;
            break;
        case 'link':
            props.href = opts.transformLinkUri ? opts.transformLinkUri(node.destination) : node.destination;
            props.title = node.title || undef;
            if (opts.linkTarget) {
                props.target = opts.linkTarget;
            }
            break;
        case 'image':
            props.src = opts.transformImageUri ? opts.transformImageUri(node.destination) : node.destination;
            props.title = node.title || undef;

            // Commonmark treats image description as children. We just want the text
            props.alt = node.react.children.join('');
            node.react.children = undef;
            break;
        case 'list':
            props.start = node.listStart;
            props.type = node.listType;
            props.tight = node.listTight;
            break;
        default:
    }

    if (typeof renderer !== 'string') {
        props.literal = node.literal;
    }

    var children = props.children || (node.react && node.react.children);
    if (Array.isArray(children)) {
        props.children = children.reduce(reduceChildren, []) || null;
    }

    return props;
}
193058
def dump_tree(node, name=None, initial_indent='', indentation='    ',
              maxline=120, maxmerged=80,
              # Runtime optimization
              iter_node=iter_node, special=ast.AST,
              list=list, isinstance=isinstance, type=type, len=len):
    
    def dump(node, name=None, indent=''):
        level = indent + indentation
        name = name and name + '=' or ''
        values = list(iter_node(node))
        if isinstance(node, list):
            prefix, suffix = '%s[' % name, ']'
        elif values:
            prefix, suffix = '%s%s(' % (name, type(node).__name__), ')'
        elif isinstance(node, special):
            prefix, suffix = name + type(node).__name__, ''
        else:
            return '%s%s' % (name, repr(node))
        node = [dump(a, b, level) for a, b in values if b != 'ctx']
        oneline = '%s%s%s' % (prefix, ', '.join(node), suffix)
        if len(oneline) + len(indent) < maxline:
            return '%s' % oneline
        if node and len(prefix) + len(node[0]) < maxmerged:
            prefix = '%s%s,' % (prefix, node.pop(0))
        node = (',\n%s' % level).join(node).lstrip()
        return '%s\n%s%s%s' % (prefix, level, node, suffix)
    return dump(node, name, initial_indent)
118088
function globInjectTask(gulp, options) {
  'use strict';
  var sources = gulp.src(options.files);

  return gulp.src(options.src)
    .pipe(inject(sources, options.config))
    .pipe(gulp.dest(options.dest));
}
985256
def find_all_globals(node, globs):
    """"""
    for n in node:
        if isinstance(n, SyntaxTree):
            globs = find_all_globals(n, globs)
        elif n.kind in read_write_global_ops:
            globs.add(n.pattr)
    return globs
638614
function cloneItree(itree, excludeKeys) {
    const clone = {};
    excludeKeys = _.castArray(excludeKeys);
    excludeKeys.push('ref');

    _.each(itree, (v, k) => {
        if (!_.includes(excludeKeys, k)) {
            clone[k] = _.cloneDeep(v);
        }
    });

    return clone;
}
598608
function RawNode(raw, config, app) {
  utils.define(this, 'isRawNode', true);
  util.run(config, 'rawNode', raw);
  this.files = [];
  var paths = {};

  raw.options = utils.extend({}, config.options, raw.options);
  var opts = resolvePaths(raw.options);
  var filter = filterFiles(opts);

  var srcFiles = utils.arrayify(raw.src);
  if (opts.glob !== false && utils.hasGlob(raw.src)) {
    srcFiles = utils.glob.sync(raw.src, opts);
  }

  srcFiles = srcFiles.filter(filter);

  if (config.options.mapDest) {
    var len = srcFiles.length, i = -1;
    while (++i < len) {
      var node = new FilesNode(srcFiles[i], raw, config);
      app.emit('files', 'filesNode', node);
      app.emit('filesNode', node);
      var dest = node.dest;

      if (!node.src && !node.path) {
        continue;
      }

      var src = resolveArray(node.src, opts);
      if (paths[dest]) {
        paths[dest].src = paths[dest].src.concat(src);
      } else {
        node.src = utils.arrayify(src);
        this.files.push(node);
        paths[dest] = node;
      }
    }

    if (!this.files.length) {
      node = raw;
      raw.src = [];
      this.files.push(raw);
    }

  } else {
    createNode(srcFiles, raw, this.files, config);
  }
}
1126193
function _monkeyPatchMainCc(compiler, complete) {
  let finalContents;

  let mainPath = path.join(compiler.dir, 'src', 'node.cc');
  let mainC = fs.readFileSync(mainPath, {
    encoding: 'utf8',
  });

  // content split, and original start/end
  let constant_loc = 1;
  let lines = mainC.split('\n');
  let startLine = lines.indexOf('  // TODO use parse opts');
  let endLine = lines.indexOf('  option_end_index = i;'); // pre node 0.11.6 compat
  let isPatched = lines.indexOf('// NEXE_PATCH_IGNOREFLAGS');

  if (isPatched !== -1) {
    _log('already patched node.cc');
    return complete();
  }

  /**
   * This is the new method of passing the args. Tested on node.js 0.12.5
   * and iojs 2.3.1
   **/
  if (endLine === -1 && startLine === -1) {
    // only if the pre-0.12.5 failed.
    _log('using the after 0.12.5 method of ignoring flags.');

    startLine = lines.indexOf(
      "  while (index < nargs && argv[index][0] == '-') {",
    ); // beginning of the function
    endLine = lines.indexOf('  // Copy remaining arguments.');
    endLine--; // space, then it's at the }

    constant_loc = lines.length + 1;
  } else {
    _log('using 0.10.x > method of ignoring flags');
    lines[endLine] = '  option_end_index = 1;';
  }

  /**
   * This is the method for 5.5.0
   **/
  if (endLine === -1 || startLine === -1) {
    _log('using the after 5.5.0 method of ignoring flags.');

    startLine = lines.indexOf(
      "  while (index < nargs && argv[index][0] == '-' && !short_circuit) {",
    ); // beginning of the function
    endLine = lines.indexOf('  // Copy remaining arguments.');
    endLine--; // space, then it's at the }

    constant_loc = lines.length + 1;
  }

  // other versions here.
  if (endLine === -1 || startLine === -1) {
    // failsafe.
    _log('error', 'Failed to find a way to patch node.cc to ignoreFlags');
    _log('startLine =', startLine, '| endLine =', endLine);
    if (!/^1(1|2)\./.test(compiler.version)) {
      process.exit(1);
    }
  }

  // check if it's been done
  lines[constant_loc] = '// NEXE_PATCH_IGNOREFLAGS';

  for (var i = startLine; i < endLine; i++) {
    lines[i] = undefined; // set the value to undefined so it's skipped by the join
  }

  _log('patched node.cc');

  finalContents = lines.join('\n');

  // write the file contents
  fs.writeFile(
    mainPath,
    finalContents,
    {
      encoding: 'utf8',
    },
    function(err) {
      if (err) {
        _log('error', 'failed to write to', mainPath);
        return process.exit(1);
      }

      return complete();
    },
  );
}
1137659
function generateBannerNode() {
    const _ = require('lodash');
    const srcmap = require('./srcmap');

    const dependencies = (() => {
        var modules = [];
        config.include_modules.forEach(function (target) {
            const pkgPath = path.join(__dirname, '../..', target, 'package.json');
            const pkg = require(pkgPath);
            modules.push({
                name: pkg.name,
                version: pkg.version,
            });
        });

        const include = fs.readFileSync(path.join(__dirname, '..', 'BANNER-INCLUDES')).toString();
        return _.template(include)({ modules: modules });
    })();

    const bannerText = banner('', null)
        .replace(' */', dependencies)
        .replace(/\ufeff/gm, '')
    ;

    return srcmap.getNodeFromCode(bannerText);
}
1103524
function getGlobs() {

  // Look globally and locally for matching glob pattern
  const dirs = [
    `${process.cwd()}/node_modules/`, // local (where they ran the command from)
    `${__dirname}/..`,  // global, if scoped package (where this code exists)
    `${__dirname}/../..`, // global, if not scoped package
  ];

  let globs = [];

  dirs.forEach(dir => {
    const legacyPattern = path.join(dir, '*/skyux-builder*/package.json');
    const newPattern = path.join(dir, '@skyux-sdk/builder*/package.json');

    logger.verbose(`Looking for modules in ${legacyPattern} and ${newPattern}`);

    globs = globs.concat([
      ...glob.sync(legacyPattern),
      ...glob.sync(newPattern)
    ]);
  });

  return globs;
}
512157
function extractMetaNodes(profile) {
        const topLevelNodes = profile.resultRoot.children;
        for (let i = 0; i < topLevelNodes.length && !(profile.gcNode && profile.programNode && profile.idleNode); i++) {
            const node = topLevelNodes[i];
            if (node.functionName === '(garbage collector)')
                profile.gcNode = node;
            else if (node.functionName === '(program)')
                profile.programNode = node;
            else if (node.functionName === '(idle)')
                profile.idleNode = node;
        }
    }