loads a WebAssembly dynamic library, returns a promise. imports is an optional imports object
767207
function loadWebAssembly(filename, imports) {
  // Fetch the file and compile it
  return fetch(filename)
    .then(response => response.arrayBuffer())
    .then(buffer => WebAssembly.compile(buffer))
    .then(module => {
      // create the imports for the module, including the
      // standard dynamic library imports
      imports = imports || {};
      imports.env = imports.env || {};
      imports.env.memoryBase = imports.env.memoryBase || 0;
      imports.env.tableBase = imports.env.tableBase || 0;

      // note: just take really memory for now...
      if (!imports.env.memory)
        imports.env.memory = new WebAssembly.Memory({ initial: 256 });

      if (!imports.env.table)
        imports.env.table = new WebAssembly.Table({ initial: 0, element: 'anyfunc' });

      // create the instance
      const instance = new WebAssembly.Instance(module, imports);
      return Promise.resolve({ instance, imports });
    });
}
578959
function importerAsync(options, handler) {
    var modulePath, recursive = false, parent = '';

    if (typeof options === 'string') {
        modulePath = options;

    } else {
        modulePath = options.path;
        recursive = options.recursive || recursive;
        parent = options.parent || parent;
        if (!modulePath) throw new Error("module directory path must be given.");
    }

    // absolute path? or relevant path?
    if (modulePath.indexOf('/') != 0) {
        // relevant. join with parent module's path
        modulePath = path.join(path.dirname(module.parent.parent.filename), modulePath);
    }

    fs.readdir(modulePath, function(err, files) {
        files.forEach(function(name) {
            if (name.lastIndexOf('.js') != name.length - 3) return;

            if (recursive && fs.lstatSync(path.join(modulePath, name)).isDirectory()) {
                importerAsync({
                    path: path.join(modulePath, name),
                    recursive: true,
                    parent: path.join(parent, name)
                }, handler);
            }

            name = name.substring(0, name.lastIndexOf('.')); // remove ext
            var moduleObj = require(path.join(modulePath, name));
            if (handler) handler(moduleObj, path.join(parent, name));
        });
    });
}
508773
function load(file, options) {
	if (options.cache && rr.cache['rvc!' + file]) {
		return Promise.resolve(rr.cache['rvc!' + file]);
	}

	return requireJSAsync(file).then(function (Component) {
		// flush requireJS's cache
		_.forEach(requireJS.s.contexts._.defined, function (value, key, array) {
			if (key.substr(0, 4) === 'rvc!') {
				delete array[key];
			}
		});

		return utils.wrap(utils.selectTemplate(options, Component), options).then(function (template) {
			var basePath = path.relative(options.settings.views, path.dirname(file));
			Component.defaults.template = options.template = template;

			return Promise.join(utils.buildComponentsRegistry(options), utils.buildPartialsRegistry(basePath, options), function (components, partials) {
				_.assign(Component.components, components);
				_.assign(Component.partials, partials);
				options.components = {};
				options.partials = {};

				if (options.cache) {
					rr.cache['rvc!' + file] = Component;
				}

				return Component;
			});
		});
	});
}
1252548
function main(options = util.getDefaultOptions()) {
  createLogger(options.debug);
  log.info(`Preparing '${options.sdk}' schemas in version '${options.version || 'latest'}'...`);

  let allLibs = {};

  // do the downloading and encapsulate in Promise
  const dlPromise = new Promise((resolve, reject) => {
    download.allLibsFile(options)
      .then((allLibsJSON) => {
        allLibs = allLibsJSON;
        download.schemas(options, allLibs)
          .then((values) => {
            resolve(values);
          })
          .catch((e) => {
            reject(e);
          });
      })
      .catch((e) => {
        reject(e);
      });
  });


  dlPromise.then(() => {
    log.info('Yay, all schema files were successfully downloaded!');
    if (options.upgrade) {
      upgrade(options, allLibs);
    }
    if (options.link) {
      link(options, allLibs);
    }
  }, (e) => {
    log.error('Damn... Something went all wrong while downloading the schema files!');
    log.error(`Are you sure the version '${options.version}' is still available on '${options.sdk}' download pages?`);
    log.error(e);
  });
}
45169
function createSingleCompiler(webpackConfig: WebpackCompiler): Promise<any> {
  return new Promise((resolve, reject) => {
    try {
      webpack(webpackConfig, (err, stats) => {
        if (err || stats.hasErrors()) {
          debug(err);
          return reject(err);
        }

        return resolve();
      });
    } catch (e) {
      return reject(e);
    }
  });
}
1053444
function bundlerFactory(loader, options) {
  function bundlerDelegate(modules) {
    return bundler(loader, options || {}, modules);
  }

  bundlerDelegate.bundle = function(names) {
    return loader.fetch(names).then(bundlerDelegate);
  };

  return bundlerDelegate;
}
1220063
function(context, pkg){
		var deps = crawl.getDependencyMap(context.loader, pkg, true);

		var pluginsPromise = crawl.loadPlugins(context, pkg, true, deps, true);
		var stealPromise = crawl.loadSteal(context, pkg, true, deps);

		return Promise.all([pluginsPromise, stealPromise]);
	}
489732
async function(request, modules_root, options){
        /*
            extract request details for this request
        */
        var request_details = await this.utils.promise_to_decompose_request(
            request, // a relative path, absolute path, or module name
            modules_root, // defines where to look for modules
            options.relative_path_root, // defines where the relative path should start from
            options.search_for_dependencies // modules can define to not search for dependencies on their own, overriding the user
        );

        /*
            load dependencies into cache before loading the main file
                - recursive operation
        */
        if(request_details.search_for_dependencies){
            // this is the main (and most obvious) downside to synchronous_require; waiting until all dependencies load.
            var dependency_relative_path_root = request_details.path.substring(0, request_details.path.lastIndexOf("/")) + "/";
            await this.promise_dependencies_are_loaded(request_details.dependencies, dependency_relative_path_root, request_details.search_for_dependencies); // wait untill dependencies are loaded
        }

        /*
            retreive content with loader functions
                - handles scoping and env setup of js files (retreives content based on CommonJS exports)
                - supports js, css, html, json, txt, etc
        */
        var content = await this.utils.loader_functions[request_details.type](request_details.path);

        /*
            resolve with content
        */
        return content;
    }
663393
function _initStorage(options) {
	        var self = this;
	        var dbInfo = {};
	        if (options) {
	            for (var i in options) {
	                dbInfo[i] = options[i];
	            }
	        }

	        dbInfo.keyPrefix = dbInfo.name + '/';

	        if (dbInfo.storeName !== self._defaultConfig.storeName) {
	            dbInfo.keyPrefix += dbInfo.storeName + '/';
	        }

	        self._dbInfo = dbInfo;

	        return new Promise(function (resolve, reject) {
	            resolve(__webpack_require__(3));
	        }).then(function (lib) {
	            dbInfo.serializer = lib;
	            return Promise.resolve();
	        });
	    }
568882
function wrap(err, js) {
		if (err) { return next(err); }

		var deps = exports.dependencies(id, js), params = [], undef = '';

		// make sure require, exports, and module are properly passed into the factory
		if (/\brequire\b/.test(js)) { params.push('require'); }
		if (/\bexports\b/.test(js)) { params.push('exports'); }
		if (/\bmodule\b/.test(js)) { params.push('module'); }

		// make sure code follows the `exports` path instead of `define` path once wrapped
		if (/\bdefine\.amd\b/.test(js)) { undef = 'var define;'; }

		if (deps.length) {
			deps = ',' + JSON.stringify(params.concat(deps));
		} else if (params.length) {
			params = [ 'require', 'exports', 'module' ];
		}

		js = 'define(' + JSON.stringify(id) + deps + ',function(' + params + ')' +
				'{' + js + '\n' + undef + '}' + // rely on hoisting for define
			');\n';
		next(null, js);
	}
1082222
function(apiName, swaggerPath) {
        return new Promise(function(resolve, reject) {
            fs.readFile(swaggerPath, function(err, data) {
                if (err) return reject(err);
                
                resolve(APIG.importRestApi({
                    body: data,
                    failOnWarnings: false
                }).promise());
            });
        });
    }
742675
function evaluateLoadedModule(loader, load) {
      console.assert(load.status == 'linked', 'is linked ' + load.name);

      doEnsureEvaluated(load.module, [], loader);
      return load.module.module;
    }
319202
function collectImports(items, children) {
	const result = Promise.map(items, (item) => {
		const name = item.name;
		const parent = cbuild.path2url(item.path);
		const pos = name.indexOf('.') + 1;
		const ext = name.substr(pos);

		if(!item.isFile || !pos || ext != 'ts') return(null);

		const result = fs.readFileAsync(
			item.path,
			{ encoding: 'utf-8' }
		).then((source) => {
			const importList = [];

			for(let line of source.split(/[;\n]+\s*/)) {
				const match = line.match(/^import[ \t]+([ \t$*,-.0-9A-Z_a-z{}]+[ \t]+from[ \t+])?['"]([^'"]+)['"]/);

				if(match) importList.push(match[2]);
			}

			const result = Promise.map(importList, (relative, resolved) =>
				Promise.try(
					() => System.normalize(relative, parent, parent)
				).then((result) => {
					let ready;

					result = result.replace(/\!.*/, '');

					if(result.substr(0, 5) == 'npm:/') {
						resolved = path.resolve(basePath, result.substr(5));

						ready = fs.statAsync(
							resolved
						).catch((err) => {
							resolved += '.js';
							return(fs.statAsync(resolved));
						}).catch((err) => {
							resolved = result;
							return(cbuild.findPackage(result.substr(5), parent, '/'));
						});
					} else {
						resolved = cbuild.url2path(result);

						ready = fs.statAsync(
							resolved
						).catch((err) => {
							resolved += '.ts';
							return(fs.statAsync(resolved));
						});
					}

					return(ready);
				}).then((result) => {
					if(resolved.substr(0, 5) == 'npm:/') resolved = result;

					let isModule = false;
					let name = '';

					for(let part of resolved.replace(/\!.*/, '').split('/')) {
						if(part.toLowerCase() == 'node_modules') {
							// New deepest node_modules directory was found.
							// Start looking for name of NPM package
							// actually containing this file.
							isModule = true;
							name = '';
						} else if(isModule) {
							if(part.charAt(0) == '@') {
								// Handle scoped packages:
								// After scope name the package name still follows.
								name = part + '/';
							} else {
								// Get package name and stop appending to it.
								name += part;
								isModule = false;
							}
						}
					}

					return(name);
				}).catch((err) => {
					// console.log(err);
				})
			);

			return(result);
		});

		return(result);
	}).then((parsedImportList) => {
		const nameTbl = {};

		// Dependencies of source files in this directory.

		for(let dependencyList of parsedImportList) {
			for(let dependency of dependencyList || []) {
				if(dependency) nameTbl[dependency] = true;
			}
		}

		// Dependencies of files in subdirectories.

		for(let dependencyList of children) {
			for(let dependency of dependencyList || []) {
				nameTbl[dependency] = true;
			}
		}

		return(Object.keys(nameTbl).sort());
	});

	return(result);
}
1190150
function(next) {
            core.allowPackages.forEach(function(pkg) {
                try {
                    var mod = path.dirname(require.resolve(pkg)).replace(/\/lib$/, "");
                    core.packages[pkg] = { path: mod };
                    if (lib.statSync(mod + "/etc").isDirectory()) {
                        core.packages[pkg].etc = 1;
                        var cfg = lib.readFileSync(mod + "/etc/config");
                        if (cfg) {
                            config = cfg + "\n" + config;
                            core.packages[pkg].config = 1;
                            core.parseConfig(cfg, 1);
                        }
                    }
                    ["modules","locales","views","web"].forEach(function(x) {
                        if (lib.statSync(mod + "/" + x).isDirectory()) {
                            core.path[x].unshift(mod + "/" + x);
                            core.packages[pkg][x] = 1;
                        }
                    });
                    logger.debug("init:", "npm package:", pkg, core.packages[pkg]);
                } catch(e) {
                    logger.error("init:", "npm package:", pkg, e);
                }
            });
            next();
        }
870316
function resolve() {
    var promises = [];
    var args = flatten(arguments);
    for (var i = 0; i < args.length; i ++) {
      promises.push(Esquire.resolve(args[i], true, true));
    }

    /* Await for resolution of dependencies */
    return Promise.all(promises).then(function(result) {
      var modules = {};
      for (var i = 0; i < result.length; i ++) {
        var resolved = result[i];
        for (var name in resolved) {
          var module = resolved[name];
          if (module.$$dynamic) continue;
          modules[name] = resolved[name];
        }
      }
      return modules;
    });
  }
1239847
function loadNunjucks(filtersModule) {
  if (fs.existsSync(filtersModule)) {
    try {
      const filters = require(filtersModule);
      nj = templater.loadNjEnv(filters.sync, filters.async);
    } catch (e) {
      console.log('Failed to load Nunjucks environment: ', e);
      process.exit(1);
    }
  }
  else {
    try {
      nj = templater.loadNjEnv();
    } catch (e) {
      console.log('Failed to load Nunjucks environment: ', e);
      process.exit(1);
    }
  }
}
561226
function load(build) {
  // Resolve all paths.
  if (build.packageFile)
    build.packageFile = build.resolvePath(build.packageFile);
  if (build.sourceDir)
    build.sourceDir = build.resolvePath(build.sourceDir);
  if (build.destDir)
    build.destDir = build.resolvePath(build.destDir);
  if (build.localesDir)
    build.localesDir = build.resolvePath(build.localesDir);
  if (build.engine.nunjucks.extensionsFile)
    build.engine.nunjucks.extensionsFile = 
      build.resolvePath(build.engine.nunjucks.extensionsFile);
  if (build.engine.nunjucks.filtersFile)
    build.engine.nunjucks.filtersFile = 
      build.resolvePath(build.engine.nunjucks.filtersFile);
  if (build.contextFile)
    build.contextFile = build.resolvePath(build.contextFile);
  // Load stuff.
  loadPackage(build);
  loadLocales(build);
  loadViewContext(build);
  loadNunjucksFiles(build);
}