thanks https://www.tomas-dvorak.cz/posts/nodejs-request-without-dependencies/
510203
function nodeGet(url) {
  // return new pending promise
  return new Promise(function (resolve, reject) {
    // select http or https module, depending on reqested url
    var lib = url.startsWith("https") ? require("https") : require("http");
    var request = lib.get(url, function (response) {
      // handle http errors
      if (response.statusCode < 200 || response.statusCode > 299) {
        reject(new Error("Failed to load page, status code: " + response.statusCode));
      }
      // temporary data holder
      var body = [];
      // on every content chunk, push it to the data array
      response.on("data", function (chunk) {
        return body.push(chunk);
      });
      // we are done, resolve promise with those joined chunks
      response.on("end", function () {
        return resolve(body.join(""));
      });
    });
    // handle connection errors of the request
    request.on("error", function (err) {
      return reject(err);
    });
  });
}
225108
function requireGraphqlRelay() {
  if (graphqlRelay) return graphqlRelay;

  try {
    graphqlRelay = require('graphql-relay');
  }
  catch (ex) {
    // Nothing
  }

  if (!graphqlRelay) {
    // Go up until graphql-relay is found
    // Inspired by https://www.npmjs.com/package/parent-require
    for (let parent = module.parent; parent && !graphqlRelay; parent = parent.parent) {
      try {
        graphqlRelay = parent.require('graphql-relay');
      }
      catch (ex) {
        // Nothing
      }
    }

    // No pity
    if (!graphqlRelay) throw new Error('semantic-graphql was not able to find "graphql-relay" as a dependency of your project. Run "npm install graphql-relay" or set the "relay" option to false.');
  }

  return graphqlRelay;
}
265492
function CircularDependencyError(dependencies) {
    var message = "Detected circular dependency in ";
    for (var i in dependencies) message += dependencies[i] + " -> ";
    message += dependencies[0];
    this.$$message = message;
    EsquireError.call(this, message);
  }
660765
function request(url, options, callback) {
	var debug = require('debug')('wayback:http');
	debug('req', url);

	callback = typeof callback === 'undefined' ? options : callback;

	// @see https://www.npmjs.com/package/fetch
	var stream = new fetch(url, typeof options === 'object' ? options : undefined);

	stream.on('error', function(err) {
		debug('error', err);
		callback(err, null);
	});

	stream.on('meta', function(meta) {
		debug('resp', 'HTTP ' + meta.status);
		debug('resp', meta.responseHeaders);
		callback(null, stream);
	});
}
742699
function isCompatibleNpmPackage(pkgName) {
    if (pkgName !== 'cordova' && pkgName.indexOf('cordova@') !== 0) {
        return Q(NodeCompatibilityResult.Compatible);
    }
    
    // Get the version of npm and the version of cordova requested. If the
    // cordova version <= 5.3.3, and the Node version is 5.0.0, the build
    // is going to fail, but silently, so we need to be loud now.
    return getVersionForNpmPackage(pkgName).then(function (cordovaVersion) {
        if (!semver.valid(cordovaVersion)) {
            // Assume true, since we don't know what version this is and the npm install will probably fail anyway
            return Q(NodeCompatibilityResult.Compatible);
        }
        
        var nodeVersion = process.version;
        
        if (!semver.valid(nodeVersion)) {
            return Q(NodeCompatibilityResult.Compatible);
        }
        
        if (semver.lt(cordovaVersion, '5.4.0') && semver.gte(nodeVersion, '5.0.0')) {
            return Q(NodeCompatibilityResult.IncompatibleVersion5);
        } else if (process.platform == 'darwin' && semver.lt(cordovaVersion, '5.3.3') && semver.gte(nodeVersion, '4.0.0')) {
            return Q(NodeCompatibilityResult.IncompatibleVersion4Ios);
        } else {
            return Q(NodeCompatibilityResult.Compatible);
        }
    });
}
860723
function init(app) {
    var keys = Object.keys(DependenciesMap);
    var allDeps = _.uniq(_.flatten(_.values(DependenciesMap)));

    allDeps.forEach(function (d) {
        if (!_.contains(keys, d)) {
            throw new Error("Unresolved dependency: " + d)
        }
    });


    keys.forEach(function (k) {
        var dep = DependenciesMap[k];
        if (_.contains(dep, k)) {
            throw new Error('Circular dependency: key: ' + k);
        }

        if (dep.length == 0) {
            HandlerArray.push(getHandler(app, k, PluginsData[k]));
        }
    });

    async.series(HandlerArray, function (err, end) {
        if (err)
            throw err;

        saveSchemas(app);
    });
}
186017
function resolveDependencies (pkg, cb) {
  if (!pkg) return topCb(new Error(
    "Package not found to resolve dependencies"))
  // link foo-1.0.3 to ROOT/.npm/{pkg}/{version}/node_modules/foo

  // see if it's bundled already
  var bundleDir = path.join( npm.dir, pkg.name, pkg.version
                           , "package", "node_modules" )
   , deps = pkg.dependencies && Object.keys(pkg.dependencies) || []
  log.verbose([pkg, deps], "deps being resolved")
  fs.readdir(bundleDir, function (er, bundledDeps) {
    if (er) bundledDeps = []
    bundledDeps.forEach(function (bd) {
      var i = deps.indexOf(bd)
      if (i !== -1) deps.splice(i, 1)
    })

    asyncMap(deps, function (i, cb) {
      var req = { name:i, version:pkg.dependencies[i] }
      log.verbose(req.name+"@"+req.version, "required")

      // see if we have this thing installed.
      fs.readdir(path.join(npm.dir, req.name), function (er, versions) {
        if (er) return cb(new Error(
          "Required package: "+req.name+"("+req.version+") not found."+
          "\n(required by: "+pkg._id+")"))
        // TODO: Get the "stable" version if there is one.
        // Look that up from the registry.
        var satis = semver.maxSatisfying(versions, req.version)
        if (satis) return cb(null, {name:req.name, version:satis})
        return cb(new Error(
          "Required package: "+req.name+"("+req.version+") not found. "+
          "(Found: "+JSON.stringify(versions)+")"+
          "\n(required by: "+pkg._id+")"))
      })
    }, function (er, found) {
      // save the resolved dependencies on the pkg data for later
      pkg._resolvedDeps = found
      cb(er, found)
    })
  })
}
1353970
function ( question, callback ) {
  var domain = require( 'domain' );
  var d = domain.create();

  return new Promise( function ( resolve, reject ) {

    d.on( 'error', function ( err ) {
      if ( err.code === 'ENXIO' ) {
        // when using a graphical interface like github
        // there is no way we can create a tty stream
        // hence we assume that the user wanted to say yes
        // at least that will operate on the code
        console.error( 'could not open TTY... assuming the user wanted to say yes' );
        callback && callback( 'yes' );
        resolve();
      }
    } );

    d.run( function () {
      var readline = require( 'readline' );

      var tty = fs.createReadStream( '/dev/tty', 'utf8' );

      var r = readline.createInterface( {
        input: tty,
        output: nodeProcess.stdout,
        terminal: false
      } );

      r.question( question + '\n\n' +
          whiteString( '>> continue? ' ) +
          grayString( '(' ) +
          grayString( 'yes' ) +
          grayString( '|' ) +
          whiteString( 'NO' ) +
          grayString( ') : ' ), function ( answer ) {

          var yes = answer.trim() === 'yes';

          callback && callback( null, yes );

          if ( yes ) {
            resolve( answer );
          } else {
            reject();
          }
          tty.close();
        } );
    } );

  } );
}
690306
function fetchUnmetDependencies() {
        var runAgain = false;
        for (var id in dependencyMap) {
            _.forEach(dependencyMap[id], function (depId) {
                if (!dependencyMap[depId] && !injectedMap[depId]) {
                    try {
                        loadExternalModule(id, depId);
                    } catch (err) {
                        throw new Error('Error loading dependency ' + depId + ' for ' + id + ': ' + err.message);
                    }

                    runAgain = true;
                }
            });
        }

        if (runAgain) { //continue until all we don't have any more unmet dependencies
            fetchUnmetDependencies();
        }
    }
272832
function() {
  var inc = function(importance) {
    return gulp.src([
      './package.json',
      './bower.json'
    ])
    .pipe($.bump({type: importance}))
    .pipe(gulp.dest('./'))
    .pipe($.filter('package.json'))
    .pipe($.git.commit('Release v' + semver.inc(
        require(path.dirname(module.parent.filename) + '/package.json').version,
        importance)))
    .pipe($.tagVersion())
    .pipe($.git.push('origin', 'master', { args: '--tags' }));
  };

  gulp.task('post-install-patch', [
    'lint:blocker',
    'jsvalidate:blocker:clean'
  ], function() {
    return inc('patch');
  });
  gulp.task('post-install-feature', [
    'lint:blocker',
    'jsvalidate:blocker:clean'
  ], function() {
    return inc('minor');
  });
  gulp.task('post-install-release', [
    'lint:blocker',
    'jsvalidate:blocker:clean'
  ], function() {
    return inc('major');
  });
  gulp.task('patch', ['install-dev-dep'], function() {
    return gulp.start('post-install-patch');
  });
  gulp.task('feature', ['install-dev-dep'], function() {
    return gulp.start('post-install-feature');
  });
  gulp.task('release', ['install-dev-dep'], function() {
    return gulp.start('post-install-release');
  });
}
330887
function add() {
            vm.error = undefined;
            service.add({
                description: vm.description
            }, function() {
                _fetch();
            }, function() {
                vm.error = 'An error occurred when adding a todo';
            });
            vm.description = '';
        }
1220918
function nodeModulesResolverFn(normalizedId) {
		if (!nodeModulesAt) {
			throw new Error('Before you can load external dependencies, you must specify where node_modules can be found by ' +
				'setting the \'nodeModulesAt\' option when creating the context');
		}

		var extId = normalizedId.id;

		var modulePath = path.join(nodeModulesAt, extId);
		if (!externalDepExists[modulePath]) {
			// yes I know the docs don't like this method.
			// But it's a little better user experience than trying to require a file that isn't there.
			if (fs.existsSync(modulePath)) {
				externalDepExists[modulePath] = true; // cache it so we avoid the lookup next time

			} else {
				var msg = 'Could not find external dependency [' + extId + '] at path [' + modulePath + ']';
				throw new Error(buildMissingDepMsg(msg, extId, allExternalIds()));
			}

		}

		return require(modulePath);
	}
26887
function collectDependencies(){
	const files = glob.sync(posix.resolve(__dirname, "../Tone/!(shim)/!(Tone).js"));
	const modules = files.map(f => f.slice(0, -3));
	let reqString = modules.map(r => {
		const relativePath = posix.relative(posix.resolve(__dirname, "../Tone"), r);
		// const exportName = r.split("/")[r.split("/").length - 1];
		// return `export { default as ${exportName} } from "./${relativePath}";`;
		// return `import "./${relativePath}";`;
		return `require("./${relativePath}");`;
	}).join("\n");
	// reqString += "\nexport { default } from \"./core/Tone\";\n";
	reqString += "\nmodule.exports = require(\"./core/Tone\").default;\n";
	fs.writeFileSync(posix.resolve(__dirname, "../Tone/index.js"), reqString);
}
131897
function (is_ignore_errors) {

		var file_paths = [];

		// root of dependence source directory
		file_paths.push('./commands.json');
		// root of denhub-device directory
		file_paths.push(__dirname + '/../commands.json');

		var file = null;
		for (var i = 0, l = file_paths.length; i < l; i++) {
			try {
				file = require('fs').readFileSync(file_paths[i]);
			} catch (e) {
				continue;
			}
			if (file) break;
		}

		if (!file && !is_ignore_errors) {
			console.log(colors.bold.red('Error: Could not read the commands file.'));
			console.log(file_paths.join('\n'));
			console.log(colors.bold('If you never created it, please try the following command:'));
			console.log('$ denhub-device-generator --init\n');
			process.exit(255);
		}

		var commands = {};
		if (file) {
			try {
				commands = JSON.parse(file);
			} catch (e) {
				if (!is_ignore_errors) throw e;
				commands = null;
			}
		}

		return commands;

	}
1104986
async function downloadDependencies(rootFolder, dependencyList) {
    const includeFolder = path.join(rootFolder, constants.INCLUDE_DIR);
    fs.removeSync(includeFolder);
    const contentPath = path.join(includeFolder, 'content.json');

    // Create new content.json
    createFile({
        name: contentPath,
        source: JSON.stringify(dependencyList),
    });

    // Extensions
    const extensions = eaft.getCodeExtensions();

    // Download new dependencies
    for (const dependency of Reflect.ownKeys(dependencyList)) {
        const dependencies = dependencyList[dependency].dependencies;
        const package = dependencyList[dependency].packageName;
        const version = dependencyList[dependency].version;
        const isRootDependency = dependencyList[dependency].isRootDependency;

        // Use package name as dependency if it is a root dependency
        let dependencyName;
        if (isRootDependency) {
            dependencyName = package;
        } else {
            dependencyName = dependency;
        }
        const packagePath = path.join(includeFolder, dependencyName);

        // Get library code
        url = `${constants.FIREBASE_DATABASE_URL}/package/${package}/version/${version}/code.json`;
        const library = await request({
            url,
            method: "GET",
            json: true,
            headers: {
                "content-type": "application/json",
            },
        });

        // Write library files
        for (const file of library.files) {
            const extension = eaft.getExtensionFromFiletype(file.type, extensions);
            const fileName = `${file.name}${extension}`;
            const source = processSource(file.source, dependencyList, dependency);
            createFile({
                name: path.join(packagePath, fileName),
                source,
            });
        }
    }
}
1372930
function requireDependencies() {
    bower = require("bower");
    path = require("path");
    async = require("async");
    colors = require("colors");
    rimraf = require("rimraf").sync;
    validator = require('bower-json');
    BowerAssets = require("./lib/bower_assets");
    AssetCopier = require("./lib/asset_copier");
    LayoutsManager = require("./lib/layouts_manager");
  }
718781
async function apiDemo () {
    try {
        // Grab the volume
        const volume = await api.volume ();
        console.log ("Current volume: " + volume);

        // Skip to next track
        await api.next ();
        console.log ("Skipped to next track.");

        // View current track
        const track = await api.currentTrack ();
        console.log (`Playing: ${track.artist} - ${track.name}`);

        // Jump to the middle
        const midTime = track.duration / 2;
        await api.position (midTime);
        console.log ("Jumped to the middle of the track");

        // Where are we at now?
        const position = await api.position ();
        console.log ("We're now at " + position + " seconds");

        // Lets play some Calvin Harris
        await api.play ("spotify:track:5bcTCxgc7xVfSaMV3RuVke");
        console.log ("Played Calvin Harris");

        // Pause da tunes
        await api.pause ();
        console.log ("Pausing the playback...");

        // Continue playing
        await api.play ();
        console.log ("Aand resuming. The music is important!");

        // Mute
        await api.mute ();
        console.log ("Muted the client");

        // And unmute
        await api.unmute ();
        console.log ("But we want to hear the music!");

        // Now open the window, we might want to do a search
        await api.focusWindow ();
        console.log ("Gotta open this window right here");

        // Or, enable shuffling
        await api.setShuffling (true);
        // or setRepeat (true)

        // Are we repeating?
        const repeatState = await api.repeating ();
        console.log ("We are " + ((repeatState) ? "" : "not ") + "repeating!");
    } catch (err) {
        console.log (err.stack);
    }
}