Populate `opts` as specified by environment specifies or defaults.

TODO (imlucas): Document options.

@param {Object} opts - user specified options
@param {Function} done - callback
@api private
558514
function configure(opts, done) {
  delete opts._;

  opts = defaults(opts, {
    topology: process.env.MONGODB_TOPOLOGY || 'standalone'
  });

  opts = defaults(opts, {
    name: opts.topology
  });

  opts = defaults(opts, {
    logpath: untildify(
      process.env.MONGODB_LOGPATH ||
        format('~/.mongodb/runner/%s.log', opts.name)
    ),
    pidpath: untildify(process.env.MONGODB_PIDPATH || '~/.mongodb/runner/pid'),
    port: process.env.MONGODB_PORT || 27017,
    mongodBin: process.env.MONGOD_BIN || 'mongod',
    mongosBin: process.env.MONGOS_BIN || 'mongos',
    storageEngine: process.env.MONGODB_STORAGE_ENGINE,
    auth_mechanism: process.env.MONGODB_AUTH_MECHANISM || 'none',
    purge: process.env.MONGODB_PURGE || true
  });

  // MongoDB < 3.0 doesn't understand the storageEngine argument and
  // will fail to start if provided!
  if (opts.version < '3.0') {
    delete opts.storageEngine;
  }

  if (opts.topology === 'replicaset') {
    opts = defaults(opts, {
      arbiters: process.env.MONGODB_ARBITERS || 0,
      secondaries: process.env.MONGODB_SECONDARIES || 2,
      passives: process.env.MONGODB_PASSIVES || 0
    });
  }

  if (opts.topology === 'cluster') {
    opts = defaults(opts, {
      shards: process.env.MONGODB_SHARDS || 1, // -> replsets
      routers: process.env.MONGODB_ROUTERS || 1, // -> mongoses
      configs: process.env.MONGODB_CONFIGS || 1,
      shardPort: process.env.MONGODB_SHARDS_PORT || 31000, // -> replsetStartPort
      configPort: process.env.MONGODB_CONFIGS_PORT || 35000, // -> configStartPort
      arbiters: process.env.MONGODB_ARBITERS || 0,
      secondaries: process.env.MONGODB_SECONDARIES || 2,
      passives: process.env.MONGODB_PASSIVES || 0
    });
  }

  debug('Ready to process spec', opts);

  if (opts.action === 'stop') {
    return done();
  }
  async.series(
    [
      mkdirp.bind(null, opts.pidpath),
      getDbPath.bind(null, opts),
      createLogsDirectory.bind(null, opts)
    ],
    done
  );
}
715440
function createReqIdHeaders(opts) {

    assert.object(opts, 'opts');
    assert.arrayOfString(opts.headers, 'opts.headers');

    var headers = opts.headers.concat(DEFAULT_HEADERS);

    return function reqIdHeaders(req, res, next) {

        for (var i = 0; i < headers.length; i++) {
            var val = req.header(headers[i]);

            if (val) {
                req.id(val);
                break;
            }
        }

        return next();
    };
}
772811
function Set(opts) {

    opts = opts || {};

    this.client = opts.client;
    this.zset = opts.zset || 'geo:locations';
    this.caching = opts.cache !== undefined ? opts.cache : false;
}
1017237
function opt(pattern, defval) {
        return new Pattern(pattern + '?', function (str, pos) {
            return pattern.exec(str, pos) || { res: defval, end: pos };
        });
    }
708067
function(opts) {
      opts = opts || {};
      var path = opts.path || this.path,
          callback = opts.callback,
          method = opts.method || this.method,
          ws = getWebsocketPlugin(),
          transports = app.config.transports,
          self = this,
          i = 0,
          error,
          response;

      if (ws) {
        if (transports && transports.length > 0) {
          async.whilst(
            function () {
              return (i < transports.length);
            },
            function (done) {
              self.doConnect(transports[i], method, path, function (err, res) {
                error = err;
                response = res;
                if (!err && res) {
                  i = transports.length;
                } else {
                  i++;
                  if (i < transports.length) {
                    delete self.request;
                  }
                }
                done();
              });
            },
            function (err) {
              callback(err || error, response);
            }
          );
        } else {
          error = 'no transport available';
          log.error('%s %s', app.name, error);
          callback(error);
        }
      } else {
        this.doConnect('http', method, path, callback);
      }
      return this;
    }
697689
function (opts) {
            var self = this;
            opts.meta.files = [];
            Y.each(this.data.files, function (v) {
                if (v.external) {
                    return;
                }
                opts.meta.files.push({
                    displayName: v.name,
                    name: self.filterFileName(v.name),
                    path: v.path || v.name
                });
            });

            var tree = {};
            var files = [];
            Y.each(this.data.files, function (v) {
                if (v.external) {
                    return;
                }
                files.push(v.name);
            });
            files.sort();
            Y.each(files, function (v) {
                var p = v.split('/'),
                    par;
                p.forEach(function (i, k) {
                    if (!par) {
                        if (!tree[i]) {
                            tree[i] = {};
                        }
                        par = tree[i];
                    } else {
                        if (!par[i]) {
                            par[i] = {};
                        }
                        if (k + 1 === p.length) {
                            par[i] = {
                                path: v,
                                name: self.filterFileName(v)
                            };
                        }
                        par = par[i];
                    }
                });
            });

            opts.meta.fileTree = tree;

            return opts;
        }
1332876
function (opts) {
            var that = this;

            return function () {
                return this.then(function () {
                    this.click('.js-cms-pagetree-options[data-node-id="' + opts.page + '"]');
                })
                .then(that.waitUntilActionsDropdownLoaded())
                .then(function () {
                    this.mouse.click('.js-cms-tree-item-copy[data-node-id="' + opts.page + '"]');
                })
                .wait(100);
            };
        }
720667
function(opts){
    opts = opts || {};
    this.serverId = opts.serverId;
    this.serverType = opts.serverType;

    this.settings = {};
    this.components = {};
    this._routes = {};

    this.event = new EventEmitter();

    this._base = path.join(__dirname, '../..');
}
941802
def complete_opt(self, text, line, begidx, endidx):
        
        tokens = line.split()
        if len(tokens) == 1:
            if text:
                return
            else:
                option = ""
        else:
            option = tokens[1]
        if len(tokens) == 1 or (len(tokens) == 2 and text):
            return [
                name[4:] + " " for name in dir(self) if name.startswith("opt_" + text)
            ]
        method = getattr(self, "complete_opt_" + option, None)
        if method is not None:
            return method(text, line, begidx, endidx)
546898
function resolve(opts, done) {
  debug('resolving paths for globs:\n', JSON.stringify(opts.globs));
  var tasks = opts.globs.map(function(pattern) {
    return function(cb) {
      debug('resolving `%s`...', pattern);
      glob(pattern, {}, function(err, files) {
        if (err) {
          return cb(err);
        }
        debug('resolved %d file(s) for `%s`', files.length, pattern);
        if (files.length > 0) {
          opts.files.push.apply(opts.files, files);
        }
        cb();
      });
    };
  });
  async.parallel(tasks, function(err) {
    if (err) {
      return done(err);
    }
    debug('checking and removing duplicate paths...');
    opts.files = unique(opts.files);
    debug('final result has `%d` files', opts.files.length);
    done(null, opts.files);
  });
}
1369536
function init (done) {
    var node = tools.match_ext(filename, 'node')
    var json = tools.match_ext(filename, 'json')

    done(null, {
      content: content,
      json: json,
      node: node,
      // all other files are considered as javascript files.
      js: !node && !json,
    })
  }
830512
function loglet(opt, _done) {
  var done = (typeof _done === 'function' ? _done : noop);
  if (typeof opt !== 'object' || !opt) {
    console.warn('loglet: missing options. Usage: loglet({key, secret})');
    return done(new Error('Invalid loglet.io configuration'));
  }
  if(typeof opt.key !== 'string') {
    console.warn('loglet: missing key. Usage: loglet({key, secret})');
    return done(new Error('Invalid loglet.io configuration'));
  }
  if (clientObj) {
    console.warn('loglet: already initialized.');
    return done();
  }
  opt = ObjectAssign({}, DEFAULT_OPTIONS, opt);
  clientObj = createConnection(this, opt, done, emit);
  loglet.on('connect', flushEvents);
  return loglet;
}
52499
function setupOptions(opts) {
    var options = Object.create(null);
    for (var opt in defaultOptions) {
        if (opts && Object.prototype.hasOwnProperty.call(opts, opt)) {
            var incomingOpt = opts[opt];
            options[opt] = typeof incomingOpt === 'function' ? incomingOpt() : incomingOpt;
        } else if (defaultOptions.hasOwnProperty(opt)) {
            var defaultOpt = defaultOptions[opt];
            options[opt] = typeof defaultOpt === 'function' ? defaultOpt() : defaultOpt;
        }
    }
    return options;
  }
1004954
function setResolved(opts, callback) {
    if (typeof opts === 'string') {
        opts = { dirname: opts };
    }

    var shrinkwrapFile = path.join(opts.dirname, 'npm-shrinkwrap.json');
    var createUri = opts.createUri || defaultCreateUri;
    var registries = opts.registries || ['registry.npmjs.org'];
    var rewriteResolved = opts.rewriteResolved || null;
    var rewriteFrom = opts.rewriteFrom || null;

    readJSON(shrinkwrapFile, onjson);

    function onjson(err, json) {
        if (err) {
            return callback(err);
        }

        var existingVersion = json['npm-shrinkwrap-version'];

        if (existingVersion && semver.gt(existingVersion, version)) {
            return callback(errors.InvalidNPMVersion({
                existing: existingVersion,
                current: version
            }));
        }

        json['npm-shrinkwrap-version'] = version;

        json['node-version'] = process.version;

        json = fixResolved(json, null);

        // if top level shrinkwrap has a `from` or `resolved`
        // field then delete them
        if (json.from) {
            json.from = undefined;
        }
        if (json.resolved) {
            json.resolved = undefined;
        }

        fs.writeFile(shrinkwrapFile,
            JSON.stringify(json, null, 2) + '\n', callback);
    }

    function fixResolved(json, name) {
        if (json.from && !json.resolved) {
            computeResolved(json, name);
        }

        // handle the case of no resolved & no from
        if (json.version && name && !json.resolved) {
            json.resolved = createUri(name, json.version);
        }

        if (rewriteResolved && json.resolved) {
            json.resolved = rewriteResolved(json.resolved);
        }

        if (rewriteFrom && json.from) {
            json.from = rewriteFrom(json.from, json.resolved);
        }

        if (json.dependencies) {
            Object.keys(json.dependencies).forEach(function (dep) {
                fixResolved(json.dependencies[dep], dep);
            });
            json.dependencies = json.dependencies;
        }

        return json;
    }

    /*  look for `from` fields and set a `resolved` field next
          to it if the `resolved` does not exist.

        This normalizes `npm shrinkwrap` so a resolved field
          always get's set.

    */
    function computeResolved(json, name) {
        var value = json.from;
        name = name || json.name;

        var uri = url.parse(value);

        // handle the case `from` is a privateRegistryURL
        if ((uri.protocol === 'http:' || uri.protocol === 'https:') &&
            registries.indexOf(uri.host) !== -1
        ) {
            json.resolved = value;
            return;
        }

        // from is {name}@{semver | uri}
        var parts = value.split('@');
        var rest = parts.slice(1).join('@');

        var secondUri = url.parse(rest);

        // from is a {name}@{semver}
        if (!secondUri.protocol) {
            // call createUri to generate a tarball uri
            // for json module name & version
            json.resolved = createUri(name, json.version);
            return;
        } else {
            // from is a git link.
            // do not try to set resolved
            return;
        }
    }
}
208861
function initArrays(optlist, parsedOptions){
	Object.keys(optlist).forEach(function(key) {
		if (optlist[key].type === Array && !(key in parsedOptions)) {
			parsedOptions[key] = [];
		}
	});
}
525735
function resolveForkOptions(opts) {
  opts = opts || {};

  var processExecArgv = process.execArgv.join(' ');
  var inspectorActive = processExecArgv.indexOf('--inspect') !== -1;
  var debugBrk = processExecArgv.indexOf('--debug-brk') !== -1;

  var execArgv = [];
  if (inspectorActive) {
    execArgv.push('--inspect=' + opts.debugPort);

    if (debugBrk) {
      execArgv.push('--debug-brk');
    }
  }

  return assign({}, opts, {
    forkArgs: opts.forkArgs,
    forkOpts: assign({}, opts.forkOpts, {
      execArgv: (opts.forkOpts && opts.forkOpts.execArgv || [])
      .concat(execArgv)
    })
  });
}
1028850
function RequestOptions(opts) {
        if (opts === void 0) { opts = {}; }
        var method = opts.method, headers = opts.headers, body = opts.body, url = opts.url, search = opts.search, params = opts.params, withCredentials = opts.withCredentials, responseType = opts.responseType;
        this.method = method != null ? normalizeMethodName(method) : null;
        this.headers = headers != null ? headers : null;
        this.body = body != null ? body : null;
        this.url = url != null ? url : null;
        this.params = this._mergeSearchParams(params || search);
        this.withCredentials = withCredentials != null ? withCredentials : null;
        this.responseType = responseType != null ? responseType : null;
    }