package scope in order to test the method
488185
List<String> getRuleFlowNames(HttpServletRequest req) {
        final String[] projectAndBranch = getProjectAndBranchNames(req);

        // Query RuleFlowGroups for asset project and branch
        List<RefactoringPageRow> results = queryService.query(
                DesignerFindRuleFlowNamesQuery.NAME,
                new HashSet<ValueIndexTerm>() {{
                    add(new ValueSharedPartIndexTerm("*",
                                                     PartType.RULEFLOW_GROUP,
                                                     TermSearchType.WILDCARD));
                    add(new ValueModuleNameIndexTerm(projectAndBranch[0]));
                    if (projectAndBranch[1] != null) {
                        add(new ValueBranchNameIndexTerm(projectAndBranch[1]));
                    }
                }});

        final List<String> ruleFlowGroupNames = new ArrayList<String>();
        for (RefactoringPageRow row : results) {
            ruleFlowGroupNames.add((String) row.getValue());
        }
        Collections.sort(ruleFlowGroupNames);

        // Query RuleFlowGroups for all projects and branches
        results = queryService.query(
                DesignerFindRuleFlowNamesQuery.NAME,
                new HashSet<ValueIndexTerm>() {{
                    add(new ValueSharedPartIndexTerm("*",
                                                     PartType.RULEFLOW_GROUP,
                                                     TermSearchType.WILDCARD));
                }});
        final List<String> otherRuleFlowGroupNames = new LinkedList<String>();
        for (RefactoringPageRow row : results) {
            String ruleFlowGroupName = (String) row.getValue();
            if (!ruleFlowGroupNames.contains(ruleFlowGroupName)) {
                // but only add the new ones
                otherRuleFlowGroupNames.add(ruleFlowGroupName);
            }
        }
        Collections.sort(otherRuleFlowGroupNames);

        ruleFlowGroupNames.addAll(otherRuleFlowGroupNames);

        return ruleFlowGroupNames;
    }
1193916
def scope(cls, f):
        """"""
        if not hasattr(cls, "scopes"):
            cls.scopes = copy(STANDARD_SCOPES)

        cls.scopes.append(f)

        def create_builder(self, *args, **kwargs):
            bldr = ScopeBuilder(cls, cls.scopes)
            return getattr(bldr, f.__name__)(*args, **kwargs)

        setattr(cls, f.__name__, classmethod(create_builder))
        return f
783643
function check(suppliedOptions){
    var options = assign(Object.create(defaultOptions), suppliedOptions || {});
    var packageJson = require(path.resolve(process.cwd(), options.package));
    var checkDevDependencies = !!options.checkDevDependencies;
    var checkDependencies = !!options.checkDependencies;
    var moduleTimes = {
        dependencies: {},
        devDependencies: {}
    };
    var loadTime = -1;

    if(packageJson.main){
        loadTime = execSync(execString + path.resolve(process.cwd(), packageJson.main), {encoding: "utf8"});
    }

    if(checkDependencies){
        Object.keys(packageJson.dependencies).forEach(function(depen){
            var time = execSync(execString + path.resolve(process.cwd(), "node_modules", depen), {
                encoding: "utf8",
                cwd: process.cwd()
            });

            moduleTimes.dependencies[depen] = parseFloat(time);
        });
    }

    if(checkDevDependencies){
        Object.keys(packageJson.devDependencies).forEach(function(depen){
            var time = execSync(execString + path.resolve(process.cwd(), "node_modules", depen), {
                encoding: "utf8",
                cwd: process.cwd()
            });

            moduleTimes.devDependencies[depen] = parseFloat(time);
        });
    }

    return {
        moduleTimes: moduleTimes,
        loadTime: loadTime
    };
}
297992
private Scope getMethodScope(boolean isDestroy, Method method) {
        Scope methodScope;
        if ( isDestroy ) {
            Destroy annotation = method.getAnnotation(Destroy.class);
            methodScope = annotation != null ? annotation.scope() : null;
        } else {
            Initialize annotation = method.getAnnotation(Initialize.class);
            methodScope = annotation != null ? annotation.scope() : null;
        }
        return methodScope;
    }
340559
def _ensure_scope(level, global_dict=None, local_dict=None, resolvers=(),
                  target=None, **kwargs):
    """"""
    return Scope(level + 1, global_dict=global_dict, local_dict=local_dict,
                 resolvers=resolvers, target=target)
469124
function () {
      let scope = context.getScope();
      while (scope) {
        const node = scope.block;
        // Ignore non functions
        const isFunction = /Function/.test(node.type);
        // Ignore classes methods
        const isNotMethod = !node.parent || node.parent.type !== 'MethodDefinition';
        // Ignore arguments (callback, etc.)
        const isNotArgument = !node.parent || node.parent.type !== 'CallExpression';
        if (isFunction && isNotMethod && isNotArgument) {
          return node;
        }
        scope = scope.upper;
      }
      return null;
    }
1252146
function Expectations(obj, method) {
    var debug = require('debug')(PREFIX + ':expectations:' + method);
    var timesCalled = 0;
    var calledWithArgs = {};

    function call() {
        calledWithArgs[timesCalled++] = _.cloneDeep(arguments);
    }

    function invocation(index) {
        if (!(index.toString() in calledWithArgs)) {
            throw new Error('invocation out of range');
        }
        var arg = calledWithArgs[index.toString()];
        return {
            withArg: withArg(arg)
        };
    }

    var self = {
        invocation: invocation,
        call: call
    };

    function checkArg(expected, values) {
        if (_.isArray(expected)) {
            var jsonExpected = JSON.stringify(expected);
            return _.some(_.filter(values, function(v) {
                return JSON.stringify(v) === jsonExpected;
            }));
        }
        if (_.isObject(expected)) {
            return _.some(_.filter(values, expected));
        }
        return _.includes(values, expected);
    }

    function checkArgs(expectedArgs, callArgs, evaluator) {
        var values = _.values(callArgs);
        var argResults = [];
        for (var argIndex = 0; argIndex < expectedArgs.length; argIndex++) {
            var expected = expectedArgs[argIndex];
            debug('expected', expected, 'in', values);
            var foundArg = checkArg(expected, values);
            argResults.push(foundArg);
        }
        return evaluator(argResults);
    }

    function checkAnyArgs(expectedArgs, callArgs) {
        return checkArgs(expectedArgs, callArgs, _.some);
    }

    function withArgs() {
        var args = _.values(arguments);
        assertArgsWithEvaluator(calledWithArgs, args, _.every);
    }

    function withSingleArg(arg) {
        var args = [arg];
        assertArgsWithEvaluator(calledWithArgs, args, _.some);
    }

    function withMatch(pattern) {
        debug(calledWithArgs);
        var matched = false;
        _.forEach(calledWithArgs, function(args) {
            if (matched) {
                return;
            }
            _.forEach(_.values(args), function(arg) {
                if (matched) {
                    return;
                }
                if (_.isObject(arg)) {
                    matched = objectPatternMatchProperties(arg, pattern);
                    debug('is object match?', matched, arg, pattern);
                    return;
                }
                matched = pattern.test(arg);
                debug('is match?', matched, arg, pattern);
            });
        });
        if (!matched) {
            assert.fail(calledWithArgs, pattern, 'Expected ' + method + ' to be called matching: ' + pattern);
        }
    }

    function matchExactly() {
        var expectedArgs = _.values(arguments);
        var matched = true;
        _.forEach(calledWithArgs, function(args) {
            _.forEach(_.values(args), function(arg, i) {
                if (!_.isEqual(arg, expectedArgs[i])) {
                    matched = false;
                    debug('is object match?', matched, arg, expectedArgs[i]);
                    return;
                }
                debug('is match?', matched, arg, expectedArgs[i]);
            });
        });
        if (!matched) {
            assert.fail(calledWithArgs, expectedArgs, 'Expected ' + method + ' to be called matchExactly args' + require('util').inspect(expectedArgs, {
                depth: 10
            }));
        }
    }

    function objectPatternMatchProperties(obj, pattern) {
        var matched = false;
        _.deepMapValues(obj, function(i) {
            if (!matched) {
                matched = pattern.test(i);
            }
            debug(i, matched);
        });
        return matched;
    }

    function assertArgsWithEvaluator(argsToCheck, args, evaluator) {
        var callResults = [];
        _.forEach(argsToCheck, function(value) {
            debug('checking', value, args);
            var argResult = checkArgs(args, value, evaluator);
            callResults.push(argResult);
        });
        var result = _.some(callResults);
        assert(result, 'Expected ' + method + ' to be called with: ' + args.join(', '));
    }

    function withArg(args) {
        return function(arg) {
            assert(checkAnyArgs([arg], args));
        };
    }

    function times(number, err) {
        if (!err) {
            err = 'Expected ' + method + ' to be called ' + utils.humanise(number) + ' but was ' + timesCalled;
        }
        assert.equal(timesCalled, number, err);
    }

    function calledLteGte(number, predicate, friendly, err) {
        if (!err) {
            err = 'Expected ' + method + ' to be called ' + friendly + ' ' + utils.humanise(number) + ' but was ' + timesCalled;
        }
        assert.ok(predicate(timesCalled, number), err);
    }

    function calledLt(number, err) {
        calledLteGte(number, _.lt, 'less than', err);
    }

    function calledLte(number, err) {
        calledLteGte(number, _.lte, 'less than or equal to', err);
    }

    function calledGt(number, err) {
        calledLteGte(number, _.gt, 'greater than', err);
    }

    function calledGte(number, err) {
        calledLteGte(number, _.gte, 'greater than or equal to', err);
    }

    function never(err) {
        times(0, err);
    }

    function calledOnce(err) {
        times(1, err);
    }

    function calledTwice(err) {
        times(2, err);
    }

    function reset() {
        timesCalled = 0;
        calledWithArgs = {};
    }

    function addNotMethods(obj) {
        function negate(func) {
            return function() {
                var args = _.values(arguments);
                try {
                    func.call(null, args);
                } catch (err) {
                    return self;
                }
                assert(false);
            };
        }

        var methods = {};
        var calledMethods = _.omit(utils.methods(obj.called), 'reset');
        _.forEach(calledMethods, function(method) {
            methods[method] = negate(obj.called[method]);
        });
        obj.called.not = methods;
        return obj;
    }

    self.called = {
        times: times,
        never: never,
        once: calledOnce,
        twice: calledTwice,
        lt: calledLt,
        lte: calledLte,
        gt: calledGt,
        gte: calledGte,
        reset: reset,
        matchExactly: matchExactly,
        withArgs: withArgs,
        withArg: withSingleArg,
        withMatch: withMatch
    };

    return (function() {
        return Object.freeze(addNotMethods(self));
    }());
}
383872
def shutit_method_scope(func):
	
	def wrapper(self, shutit):
		"""Wrapper to call a shutit module method, notifying the ShutIt object.
		"""
		ret = func(self, shutit)
		return ret
	return wrapper
693286
public void checkFunctionOrMethodDeclaration(Decl.FunctionOrMethod d) {
		// Construct initial environment
		Environment environment = new Environment();
		// Update environment so this within declared lifetimes
		environment = FlowTypeUtils.declareThisWithin(d, environment);
		// Check parameters and returns are not empty (i.e. are not equivalent
		// to void, as this is non-sensical).
		checkVariableDeclarations(d.getParameters(), environment);
		checkVariableDeclarations(d.getReturns(), environment);
		// Check any preconditions (i.e. requires clauses) provided.
		checkConditions(d.getRequires(), true, environment);
		// Check any postconditions (i.e. ensures clauses) provided.
		checkConditions(d.getEnsures(), true, environment);
		// FIXME: Add the "this" lifetime
		if (d.getModifiers().match(Modifier.Native.class) == null) {
			// Create scope representing this declaration
			EnclosingScope scope = new FunctionOrMethodScope(d);
			// Check type information throughout all statements in body.
			Environment last = checkBlock(d.getBody(), environment, scope);
			// Check return value
			checkReturnValue(d, last);
		} else {
			// NOTE: we obviously don't need to check the body of a native function or
			// method. Attempting to do so causes problems because checkReturnValue will
			// fail.
		}
	}
508688
private void checkNameVisibility(Scope scope, Node name) {
    if (!name.isName()) {
      return;
    }

    Var var = scope.getVar(name.getString());
    if (var == null) {
      return;
    }

    Visibility v = checkPrivateNameConvention(
        AccessControlUtils.getEffectiveNameVisibility(
            name, var, defaultVisibilityForFiles), name);

    switch (v) {
      case PACKAGE:
        if (!isPackageAccessAllowed(var, name)) {
          compiler.report(
              JSError.make(
                  name,
                  BAD_PACKAGE_PROPERTY_ACCESS,
                  name.getString(),
                  var.getSourceFile().getName()));
        }
        break;
      case PRIVATE:
        if (!isPrivateAccessAllowed(var, name)) {
          compiler.report(
              JSError.make(
                  name,
                  BAD_PRIVATE_GLOBAL_ACCESS,
                  name.getString(),
                  var.getSourceFile().getName()));
        }
        break;
      default:
        // Nothing to do for PUBLIC and PROTECTED
        // (which is irrelevant for names).
        break;
    }
  }
845996
void generatePackageInfo(Definition def, String outputDir, String subDir)
   {
      try
      {
         FileWriter fw;
         PackageInfoGen phGen;
         if (outputDir.equals("test"))
         {
            fw = Utils.createTestFile("package-info.java", def.getRaPackage(), def.getOutputDir());
            phGen = new PackageInfoGen();

         }
         else
         {

            if (subDir == null)
            {
               fw = Utils.createSrcFile("package-info.java", def.getRaPackage(), def.getOutputDir());
               phGen = new PackageInfoGen();
            }
            else
            {
               fw = Utils.createSrcFile("package-info.java", def.getRaPackage() + "." + subDir, def.getOutputDir());
               phGen = new PackageInfoGen(subDir);
            }
         }
         phGen.generate(def, fw);
         fw.close();
      }
      catch (IOException ioe)
      {
         ioe.printStackTrace();
      }
   }
16227
@Override
    public Object visit(Object context, ForVarDeclStatement statement, boolean strict) {
        Scope scope = (Scope) context;
        List<VariableDeclaration> decls = statement.getDeclarationList();
        for (VariableDeclaration each : decls) {
            each.accept(context, this, strict);
        }

        final Label startLabel = scope.getNewLabel();
        final Label doneLabel = scope.getNewLabel();

        scope.addInstruction(new LabelInstr(startLabel));
        // TEST
        scope.addInstruction(new BEQ((Operand) statement.getTest().accept(context, this, strict),
                BooleanLiteral.FALSE, doneLabel));

        // BODY
        statement.getBlock().accept(context, this, strict);

        // INCREMENT
        statement.getIncrement().accept(context, this, strict);

        scope.addInstruction(new Jump(startLabel));

        // END
        scope.addInstruction(new LabelInstr(doneLabel));

        return Undefined.UNDEFINED;
    }
602308
def assert_independent(package, *packages):
    
    assert packages, 'At least one package must be specified'
    import_package = 'from openquake.baselib.general import import_all\n' \
                     'print(import_all("%s"))' % package
    imported_modules = run_in_process(import_package)
    for mod in imported_modules:
        for pkg in packages:
            if mod.startswith(pkg):
                raise CodeDependencyError('%s depends on %s' % (package, pkg))
1241496
function(sandbox) {

    function stat(filename) {
        filename = path._makeLong(filename);
        const cache = stat.cache;
        if (cache !== null) {
            const result = cache.get(filename);
            if (result !== undefined) return result;
        }
        const result = internalModuleStat(filename);
        if (cache !== null) cache.set(filename, result);
        return result;
    }
    stat.cache = null;


    function Module(id, parent) {
        this.id = id;
        this.exports = {};
        this.parent = parent;
        if (parent && parent.children) {
            parent.children.push(this);
        }

        this.filename = null;
        this.loaded = false;
        this.children = [];
    }

    Module._cache = {};
    Module._pathCache = {};
    Module._extensions = {};
    var modulePaths = [];
    Module.globalPaths = [];

    Module.wrapper = ['(function (exports, require, module, __filename, __dirname) { ', '\n});'];
    Module.wrap = function (script) {
        return Module.wrapper[0] + script + Module.wrapper[1];
    };

// given a module name, and a list of paths to test, returns the first
// matching file in the following precedence.
//
// require("a.<ext>")
//   -> a.<ext>
//
// require("a")
//   -> a
//   -> a.<ext>
//   -> a/index.<ext>

// check if the directory is a package.json dir
    const packageMainCache = {};

    function readPackage(requestPath) {
        if (hasOwnProperty(packageMainCache, requestPath)) {
            return packageMainCache[requestPath];
        }

        const jsonPath = path.resolve(requestPath, 'package.json');
        const json = internalModuleReadFile(path._makeLong(jsonPath));

        if (json === undefined) {
            return false;
        }

        try {
            var pkg = packageMainCache[requestPath] = JSON.parse(json).main;
        } catch (e) {
            e.path = jsonPath;
            e.message = 'Error parsing ' + jsonPath + ': ' + e.message;
            throw e;
        }
        return pkg;
    }

    function tryPackage(requestPath, exts, isMain) {
        var pkg = readPackage(requestPath);

        if (!pkg) return false;

        var filename = path.resolve(requestPath, pkg);
        return tryFile(filename, isMain) ||
            tryExtensions(filename, exts, isMain) ||
            tryExtensions(path.resolve(filename, 'index'), exts, isMain);
    }

// check if the file exists and is not a directory
// if using --preserve-symlinks and isMain is false,
// keep symlinks intact, otherwise resolve to the
// absolute realpath.
    function tryFile(requestPath, isMain) {
        const rc = stat(requestPath);
        if (preserveSymlinks && !isMain) {
            return rc === 0 && path.resolve(requestPath);
        }
        return rc === 0 && fs.realpathSync(requestPath);
    }

// given a path check a the file exists with any of the set extensions
    function tryExtensions(p, exts, isMain) {
        for (var i = 0; i < exts.length; i++) {
            const filename = tryFile(p + exts[i], isMain);

            if (filename) {
                return filename;
            }
        }
        return false;
    }

    var warned = false;
    Module._findPath = function (request, paths, isMain) {
        if (path.isAbsolute(request)) {
            paths = [''];
        } else if (!paths || paths.length === 0) {
            return false;
        }

        const cacheKey = JSON.stringify({request: request, paths: paths});
        if (Module._pathCache[cacheKey]) {
            return Module._pathCache[cacheKey];
        }

        var exts;
        const trailingSlash = request.length > 0 &&
            request.charCodeAt(request.length - 1) === 47/*/*/;

        // For each path
        for (var i = 0; i < paths.length; i++) {
            // Don't search further if path doesn't exist
            const curPath = paths[i];
            if (curPath && stat(curPath) < 1) continue;
            var basePath = path.resolve(curPath, request);
            var filename;

            if (!trailingSlash) {
                const rc = stat(basePath);
                if (rc === 0) {  // File.
                    if (preserveSymlinks && !isMain) {
                        filename = path.resolve(basePath);
                    } else {
                        filename = fs.realpathSync(basePath);
                    }
                } else if (rc === 1) {  // Directory.
                    if (exts === undefined)
                        exts = Object.keys(Module._extensions);
                    filename = tryPackage(basePath, exts, isMain);
                }

                if (!filename) {
                    // try it with each of the extensions
                    if (exts === undefined)
                        exts = Object.keys(Module._extensions);
                    filename = tryExtensions(basePath, exts, isMain);
                }
            }

            if (!filename) {
                if (exts === undefined)
                    exts = Object.keys(Module._extensions);
                filename = tryPackage(basePath, exts, isMain);
            }

            if (!filename) {
                // try it with each of the extensions at "index"
                if (exts === undefined)
                    exts = Object.keys(Module._extensions);
                filename = tryExtensions(path.resolve(basePath, 'index'), exts, isMain);
            }

            if (filename) {
                Module._pathCache[cacheKey] = filename;
                return filename;
            }
        }
        return false;
    };

// 'node_modules' character codes reversed
    var nmChars = [115, 101, 108, 117, 100, 111, 109, 95, 101, 100, 111, 110];
    var nmLen = nmChars.length;
    if (process.platform === 'win32') {
        // 'from' is the __dirname of the module.
        Module._nodeModulePaths = function (from) {
            // guarantee that 'from' is absolute.
            from = path.resolve(from);

            // note: this approach *only* works when the path is guaranteed
            // to be absolute.  Doing a fully-edge-case-correct path.split
            // that works on both Windows and Posix is non-trivial.
            const paths = [];
            var p = 0;
            var last = from.length;
            for (var i = from.length - 1; i >= 0; --i) {
                const code = from.charCodeAt(i);
                if (code === 92/*\*/ || code === 47/*/*/) {
                    if (p !== nmLen)
                        paths.push(from.slice(0, last) + '\\node_modules');
                    last = i;
                    p = 0;
                } else if (p !== -1 && p < nmLen) {
                    if (nmChars[p] === code) {
                        ++p;
                    } else {
                        p = -1;
                    }
                }
            }

            return paths;
        };
    } else { // posix
        // 'from' is the __dirname of the module.
        Module._nodeModulePaths = function (from) {
            // guarantee that 'from' is absolute.
            from = path.resolve(from);
            // Return early not only to avoid unnecessary work, but to *avoid* returning
            // an array of two items for a root: [ '//node_modules', '/node_modules' ]
            if (from === '/')
                return ['/node_modules'];

            // note: this approach *only* works when the path is guaranteed
            // to be absolute.  Doing a fully-edge-case-correct path.split
            // that works on both Windows and Posix is non-trivial.
            const paths = [];
            var p = 0;
            var last = from.length;
            for (var i = from.length - 1; i >= 0; --i) {
                const code = from.charCodeAt(i);
                if (code === 47/*/*/) {
                    if (p !== nmLen)
                        paths.push(from.slice(0, last) + '/node_modules');
                    last = i;
                    p = 0;
                } else if (p !== -1 && p < nmLen) {
                    if (nmChars[p] === code) {
                        ++p;
                    } else {
                        p = -1;
                    }
                }
            }

            return paths;
        };
    }


// 'index.' character codes
    var indexChars = [105, 110, 100, 101, 120, 46];
    var indexLen = indexChars.length;
    Module._resolveLookupPaths = function (request, parent) {
        if (_NATIVE_MODULES.indexOf(request) >= 0) {
            return [request, []];
        }

        var reqLen = request.length;
        // Check for relative path
        if (reqLen < 2 ||
            request.charCodeAt(0) !== 46/*.*/ ||
            (request.charCodeAt(1) !== 46/*.*/ &&
            request.charCodeAt(1) !== 47/*/*/)) {
            var paths = modulePaths;
            if (parent) {
                if (!parent.paths)
                    paths = parent.paths = [];
                else
                    paths = parent.paths.concat(paths);
            }

            // Maintain backwards compat with certain broken uses of require('.')
            // by putting the module's directory in front of the lookup paths.
            if (request === '.') {
                if (parent && parent.filename) {
                    paths.unshift(path.dirname(parent.filename));
                } else {
                    paths.unshift(path.resolve(request));
                }
            }

            return [request, paths];
        }

        // with --eval, parent.id is not set and parent.filename is null
        if (!parent || !parent.id || !parent.filename) {
            // make require('./path/to/foo') work - normally the path is taken
            // from realpath(__filename) but with eval there is no filename
            var mainPaths = ['.'].concat(Module._nodeModulePaths('.'), modulePaths);
            return [request, mainPaths];
        }

        // Is the parent an index module?
        // We can assume the parent has a valid extension,
        // as it already has been accepted as a module.
        const base = path.basename(parent.filename);
        var parentIdPath;
        if (base.length > indexLen) {
            var i = 0;
            for (; i < indexLen; ++i) {
                if (indexChars[i] !== base.charCodeAt(i))
                    break;
            }
            if (i === indexLen) {
                // We matched 'index.', let's validate the rest
                for (; i < base.length; ++i) {
                    const code = base.charCodeAt(i);
                    if (code !== 95/*_*/ &&
                        (code < 48/*0*/ || code > 57/*9*/) &&
                        (code < 65/*A*/ || code > 90/*Z*/) &&
                        (code < 97/*a*/ || code > 122/*z*/))
                        break;
                }
                if (i === base.length) {
                    // Is an index module
                    parentIdPath = parent.id;
                } else {
                    // Not an index module
                    parentIdPath = path.dirname(parent.id);
                }
            } else {
                // Not an index module
                parentIdPath = path.dirname(parent.id);
            }
        } else {
            // Not an index module
            parentIdPath = path.dirname(parent.id);
        }
        var id = path.resolve(parentIdPath, request);

        // make sure require('./path') and require('path') get distinct ids, even
        // when called from the toplevel js file
        if (parentIdPath === '.' && id.indexOf('/') === -1) {
            id = './' + id;
        }

        return [id, [path.dirname(parent.filename)]];
    };


// Check the cache for the requested file.
// 1. If a module already exists in the cache: return its exports object.
// 2. If the module is native: call `NativeModule.require()` with the
//    filename and return the result.
// 3. Otherwise, create a new module for the file and save it to the cache.
//    Then have it load  the file contents before returning its exports
//    object.
    Module._load = function (request, parent, isMain) {

        var filename = Module._resolveFilename(request, parent, isMain);

        events.emit('require', request, filename);

        if (!userOptions.reload) {
            var cachedModule = Module._cache[filename];
            if (cachedModule) {
                if (_NATIVE_MODULES.indexOf(filename) >= 0) return cachedModule;
                else return cachedModule.exports;
            }
        }

//************************** override list

        if (_NATIVE_MODULES.indexOf(filename) >= 0) {
            var res = NativeModuleRequire(filename);
            if (_.isArray(userOptions._useNativeModulesCopyList)) {
                if (userOptions._useNativeModulesCopyList.indexOf(filename) >= 0)
                    res = _.cloneDeep(res);
            }
            Module._cache[filename] = res;
            return res;
        }

        var module = new Module(filename, parent);

        if (isMain) {
            process.mainModule = module;
            module.id = '.';
        }

        Module._cache[filename] = module;

        tryModuleLoad(module, filename);

        return module.exports;
    };

    function tryModuleLoad(module, filename) {
        var threw = true;
        try {
            module.load(filename);
            threw = false;
        } finally {
            if (threw) {
                delete Module._cache[filename];
            }
        }
    }

    Module._resolveFilename = function (request, parent, isMain) {
        if (_NATIVE_MODULES.indexOf(request) >= 0) {
            return request;
        }

        var resolvedModule = Module._resolveLookupPaths(request, parent);
        var id = resolvedModule[0];
        var paths = resolvedModule[1];

        var filename = Module._findPath(request, paths, isMain);
        if (!filename) {
            var err = new Error("Cannot find module '" + request + "'");
            err.code = 'MODULE_NOT_FOUND';
            throw err;
        }
        return filename;
    };


// Given a file name, pass it to the proper extension handler.
    Module.prototype.load = function (filename) {

        assert(!this.loaded);
        this.filename = filename;
        this.paths = Module._nodeModulePaths(path.dirname(filename));

        var extension = path.extname(filename) || '.js';
        if (!Module._extensions[extension]) extension = '.js';
        Module._extensions[extension](this, filename);
        this.loaded = true;
    };


// Loads a module at the given file path. Returns that module's
// `exports` property.
    Module.prototype.require = function (path) {

        assert(path, 'missing path');
        assert(typeof path === 'string', 'path must be a string');

        // This is the require we need to change !!!!!!
        events.emit('beforeRequire', path);

        if (userOptions.Blacklist.indexOf(path) >= 0) {
            throw new Error('Use of module (' + path + ') is restricted.');
        }
        if (userOptions.Whitelist.length > 0 && userOptions.Whitelist.indexOf(path) < 0) {
            throw new Error('Module (' + path + ') is not available.');
        }
        if (!userOptions.allowExternalModules && _NATIVE_MODULES.indexOf(path) < 0) {
            throw new Error('Use of external modules is restricted, have (' + path + ')');
        }

        var resultModule = Module._load(path, this, /* isMain */ false);

        events.emit('afterRequire', resultModule);

        return resultModule;
    };


// Resolved path to process.argv[1] will be lazily placed here
// (needed for setting breakpoint when called with --debug-brk)
    var resolvedArgv;


// Run the file contents in the correct scope or sandbox. Expose
// the correct helper variables (require, module, exports) to
// the file.
// Returns exception, if any.
    Module.prototype._compile = function (content, filename) {
        // Remove shebang
        var contLen = content.length;
        if (contLen >= 2) {
            if (content.charCodeAt(0) === 35/*#*/ &&
                content.charCodeAt(1) === 33/*!*/) {
                if (contLen === 2) {
                    // Exact match
                    content = '';
                } else {
                    // Find end of shebang line and slice it off
                    var i = 2;
                    for (; i < contLen; ++i) {
                        var code = content.charCodeAt(i);
                        if (code === 10/*\n*/ || code === 13/*\r*/)
                            break;
                    }
                    if (i === contLen)
                        content = '';
                    else {
                        // Note that this actually includes the newline character(s) in the
                        // new output. This duplicates the behavior of the regular expression
                        // that was previously used to replace the shebang line
                        content = content.slice(i);
                    }
                }
            }
        }

        // create wrapper function
        var wrapper = Module.wrap(content);

        var compiledWrapper;
        if (userOptions.useSandbox && sandbox) {

            if (!vm.isContext(sandbox)) vm.createContext(sandbox);
            compiledWrapper = vm.runInContext(wrapper, sandbox,{
                filename: filename,
                lineOffset: 0,
                displayErrors: true
            });
        } else {

            compiledWrapper = vm.runInThisContext(wrapper, {
                filename: filename,
                lineOffset: 0,
                displayErrors: true
            });
        }

        var dirname = path.dirname(filename);
        var require = internalModule.makeRequireFunction.call(this);
        var args = [this.exports, require, this, filename, dirname];
        var depth = internalModule.requireDepth;
        if (depth === 0) stat.cache = new Map();
        var result = compiledWrapper.apply(this.exports, args);
        if (depth === 0) stat.cache = null;
        return result;
    };


// Native extension for .js
    Module._extensions['.js'] = function (module, filename) {
        var content = fs.readFileSync(filename, 'utf8');
        module._compile(internalModule.stripBOM(content), filename);
    };


// Native extension for .json
    Module._extensions['.json'] = function (module, filename) {
        var content = fs.readFileSync(filename, 'utf8');
        try {
            module.exports = JSON.parse(internalModule.stripBOM(content));
        } catch (err) {
            err.message = filename + ': ' + err.message;
            throw err;
        }
    };


//Native extension for .node
    Module._extensions['.node'] = function (module, filename) {
        return process.dlopen(module, path._makeLong(filename));
    };


    Module._initPaths = function () {
        const isWindows = process.platform === 'win32';

        var homeDir;
        if (isWindows) {
            homeDir = process.env.USERPROFILE;
        } else {
            homeDir = process.env.HOME;
        }

        var paths = [path.resolve(process.execPath, '..', '..', 'lib', 'node')];

        if (homeDir) {
            paths.unshift(path.resolve(homeDir, '.node_libraries'));
            paths.unshift(path.resolve(homeDir, '.node_modules'));
        }

        var nodePath = process.env['NODE_PATH'];
        if (nodePath) {
            paths = nodePath.split(path.delimiter).filter(function (path) {
                return !!path;
            }).concat(paths);
        }

        modulePaths = paths;

        // clone as a read-only copy, for introspection.
        Module.globalPaths = modulePaths.slice(0);
    };

    Module._initPaths();


//----- Apply New Extensions ----

    var extentionList = userOptions._extensions;
    for (var ext in extentionList) {

        Module._extensions[ext] = function (module, filename) {

            var source = stripBOM(fs.readFileSync(filename, 'utf8'));
            if (extentionList[ext].every(function (method) {
                    var userResult = null;
                    userResult = method(source, filename);

                    if (!userResult || userResult === null) userResult = source;

                    if (!util.isString(userResult)) {   // stop operation, return this value
                        module.exports = userResult;
                        return false;
                    } else {
                        source = userResult;   // set the newly set ret value
                        return true;
                    }
                })) module._compile(source, filename);
        };
    }

//------ Apply New Search Paths
    var paths = userOptions._pathList;

    if (paths.length > 0) {

        var nodePath = process.env['NODE_PATH'];
        var DefaultPaths = process.env['NODE_PATH'];
        if (!nodePath) nodePath = ""; else nodePath += path.delimiter;
        for (var i = 0; i < paths.length; i++) {
            nodePath += paths[i] + path.delimiter;
        }
        process.env['NODE_PATH'] = nodePath;
        Module._initPaths();
        process.env['NODE_PATH'] = DefaultPaths;
    }

//---- End Apply New Paths
    function resolve(request) {
        return Module._resolveFilename(request, self);
    }
    var res = Module.prototype.require;
    res.resolve = resolve;
    res.main = process.mainModule;
    res.extensions = Module._extensions;
    res.cache = Module._cache;

    return res;
}
289150
function(context, childPkg){
		var curAddress = childPkg.origFileUrl;
		var parentAddress = utils.path.parentNodeModuleAddress(childPkg.origFileUrl);
		while(parentAddress) {
			var packageAddress = parentAddress+"/"+childPkg.name+"/package.json";
			var parentPkg =	context.paths[packageAddress];
			if(parentPkg && SemVer.valid(parentPkg.version)) {
				if(SemVer.satisfies(parentPkg.version, childPkg.version)) {
					return parentPkg.fileUrl;
				} else {
					return curAddress;
				}
			}
			parentAddress = utils.path.parentNodeModuleAddress(packageAddress);
			curAddress = packageAddress;
		}
		return curAddress;
	}
294850
function getPackageInfoFrom(string) {
  if (string[0] === '@') {
    const [scope, rawName] = string.split('/');
    const { name, version } = getVersionFromString(rawName);
    return {
      name: `${scope}/${name}`,
      version,
    };
  }

  return getVersionFromString(string);
}
445518
function mock () {
    // flag set if any library is successfully mocked
    var mocked = false

    // attempt to load mockable libraries
    _.each(automock.module, (module, name) => {
        // catch errors on libraries that are not available
        try {
            // load library to be mocked
            var library = require(module.libraryName)
            // apply automock function on library
            library.automock(module.automock)
            // set success flag
            mocked = true
        }
        catch (ex) {
            console.log(ex)
        }
    })

    // throw error if no libraries found
    if (!mocked) {
        throw new Error('immutable-automock: no mockable libraries found')
    }

    // return class instance for chaining
    return automock
}