Fetches all the user's information. If no callback is provided
then more specific information can be requested

Example:
app.user(function(err, data) { ... })
app.user().stream(function(err,data){ ... })

@param {Function} cb
@api public
760687
function(cb) {

      if (typeof cb === "function") {
        var opts = {
          url: uri + 'user',
          method: 'GET',
          qs: qs,
          json: true
        };
        request(opts,function(e,r,b) {
          if (e) cb(e)
          else {
            if (r.statusCode==200) cb(null, b)
            else {
              cb({statusCode:r.statusCode,error:b.error})
            }
          }
        });
        return;
      }

      return {
        /**
         * Fetches the user's stream
         *
         * Example:
         *     app.user().stream(function(err,data){ ... })
         *
         * @param {Function} cb
         * @api public
         */
        stream: function(cb) {
          var opts = {
            url: uri + 'user/stream',
            method: 'GET',
            qs: qs,
            json: true
          };
          request(opts,function(e,r,b) {
            if (e) cb(e)
            else {
              if (r.statusCode==200) cb(null, b)
              else {
                cb({statusCode:r.statusCode,error:b.error})
              }
            }
          });
        },
        /**
         * Fetches the user's pucher channel
         *
         * Example:
         *     app.user().pusher_channel(function(err,data){ ... })
         *
         * @param {Function} cb
         * @api public
         */
        pusher_channel: function(cb) {
          var opts = {
            url: uri + 'user/pusherchannel',
            method: 'GET',
            qs: qs,
            json: true
          };
          request(opts,function(e,r,b) {
            if (e) cb(e)
            else {
              if (r.statusCode==200) cb(null, b.data)
              else {
                cb({statusCode:b.id||200,error:b.error})
              }
            }
          });
        },
      }
    }
303932
function getUserInfoRecursive(callback) {
                getUserInfoRetryCount++;

                if (getUserInfoRetryCount > getUserInfoRetry) {
                    getUserInfoTimeout && clearTimeout(getUserInfoTimeout);

                    getUserInfoRetryCount = 0;

                    fireEvent('error', {
                        code: 6101,
                        message: CHAT_ERRORS[6101],
                        error: null
                    });
                }
                else {
                    getUserInfoTimeout && clearTimeout(getUserInfoTimeout);

                    getUserInfoTimeout = setTimeout(function() {
                        getUserInfoRecursive(callback);
                    }, getUserInfoRetryCount * 10000);

                    return sendMessage({
                        chatMessageVOType: chatMessageVOTypes.USER_INFO,
                        typeCode: params.typeCode
                    }, {
                        onResult: function(result) {
                            var returnData = {
                                hasError: result.hasError,
                                cache: false,
                                errorMessage: result.errorMessage,
                                errorCode: result.errorCode
                            };

                            if (!returnData.hasError) {
                                getUserInfoTimeout && clearTimeout(getUserInfoTimeout);

                                var messageContent = result.result;
                                var currentUser = formatDataToMakeUser(messageContent);

                                /**
                                 * Add current user into cache database #cache
                                 */
                                if (canUseCache) {
                                    if (db) {
                                        db.users
                                            .where('id')
                                            .equals(currentUser.id)
                                            .toArray()
                                            .then(function(users) {
                                                if (users.length > 0 && users[0].id > 0) {
                                                    db.users
                                                        .update(currentUser.id, {
                                                            cellphoneNumber: currentUser.cellphoneNumber,
                                                            email: currentUser.email,
                                                            image: currentUser.image,
                                                            name: currentUser.name
                                                        })
                                                        .catch(function(error) {
                                                            fireEvent('error', {
                                                                code: error.code,
                                                                message: error.message,
                                                                error: error
                                                            });
                                                        });
                                                }
                                                else {
                                                    db.users.put(currentUser)
                                                        .catch(function(error) {
                                                            fireEvent('error', {
                                                                code: error.code,
                                                                message: error.message,
                                                                error: error
                                                            });
                                                        });
                                                }
                                            });
                                    }
                                    else {
                                        fireEvent('error', {
                                            code: 6601,
                                            message: CHAT_ERRORS[6601],
                                            error: null
                                        });
                                    }
                                }

                                resultData = {
                                    user: currentUser
                                };

                                returnData.result = resultData;
                                getUserInfoRetryCount = 0;

                                callback && callback(returnData);

                                /**
                                 * Delete callback so if server pushes response
                                 * before cache, cache won't send data again
                                 */
                                callback = undefined;
                            }
                        }
                    });
                }
            }
1058129
function streamOutput( callback ) {
	return function(err, filenames) {
		if (err) {
			callback(err, null);
		} else {
			// Create read streams from each input
			var streams = []
			for (var i=0; i<filenames.suffix.length; i++)
				streams.push([
					fs.createReadStream( filenames.basename + filenames.suffix[i]),
					filenames.suffix[i]
				]);
			// Callback with streams
			callback(err, streams);
		}
	}
}
1155560
def facebook_stream_fetch
      return unless facebook_status == ConnectionStatus::NORMAL
      streams = @graph.get_connections("me", "home")
      streams.each { |post| stream_print_queue << graph2item(post) }
      log(:info, "fetch stream ok")
    rescue Koala::Facebook::ServerError
      retry_wait
    rescue Koala::Facebook::APIError
      expired_session
    rescue Exception => e
      error e
    end
959571
function read (stream, opts, db, cb) {
  var schema = new exports.Schema;

  if (opts.onType) {
    schema.onType = opts.onType;
  }

  stream.once('error', function (err) {
    debug('aborting with error: ' + err);
    db.close(cb.bind(err));
  });

  stream.on('data', function (doc) {
    var err = schema.consume(doc);
    if (err) return abort(err, stream, db, cb);
  })

  stream.on('end', function () {
    debug('db closing');
    db.close(function () {
      debug('db closed');
      cb(null, schema);
    })
  })
}
234850
function(cb) {
      //console.log('tx running for ' + scope);
      // me.not_ready_ = true;
      // transaction should be active now
      var tx = me.mu_tx_.getTx();
      /**
       * @param {*} result result.
       * @param {boolean=} opt_is_error true if request has error.
       */
      var resultCallback2 = function(result, opt_is_error) {
        me.s_request_tx = tx; // so that we can abort it.
        if (opt_is_error) {
          goog.log.finer(me.logger, rq_label + ' ERROR');
          df.errback(result);
        } else {
          goog.log.finer(me.logger, rq_label + ' SUCCESS');
          df.callback(result);
        }
        me.s_request_tx = null;
      };
      me.r_no_++;
      rq_label = me.getLabel() + 'R' + me.r_no_;
      goog.log.finer(me.logger, rq_label + ' BEGIN');
      callback(tx, rq_label, resultCallback2);
      goog.log.finer(me.logger, rq_label + ' END');
      callback = null; // we don't call again.
    }
1297413
function cb(err) {
        if (callback) {
            if (err) return callback(err);
            callback(null, rec);
        }
        callback = null;
        if (!err) {
            that.emit('logged', rec);
        }
    }
1037928
function deleteUser (params, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      const { id, organizationId } = params
      const tasks = [
        (job, next) => {
          Joi.validate({ id, organizationId }, validationRules.deleteUser, (err) => {
            if (err) return next(Boom.badRequest(err))
            next()
          })
        },
        (job, next) => {
          job.id = id
          next()
        },
        (job, next) => {
          const sqlQuery = SQL`DELETE FROM user_policies WHERE user_id = ${id}`

          job.client.query(sqlQuery, utils.boomErrorWrapper(next))
        },
        (job, next) => {
          const sqlQuery = SQL`DELETE FROM team_members WHERE user_id = ${id}`

          job.client.query(sqlQuery, utils.boomErrorWrapper(next))
        },
        (job, next) => {
          const sqlQuery = SQL`DELETE FROM users WHERE id = ${id} AND org_id = ${organizationId}`

          job.client.query(sqlQuery, (err, result) => {
            if (err) return next(Boom.badImplementation(err))
            if (result.rowCount === 0) return next(Boom.notFound(`User ${id} not found`))

            next()
          })
        }
      ]

      db.withTransaction(tasks, (err, res) => {
        if (err) return cb(err)

        cb()
      })

      return promise
    }
505750
function read(cb) {
				if (callback) throw new Error("already getting");
				if (q.length > 0) {
						var item = q.shift();
						// recycle queue when empty to avoid maintaining arrays that have grown large and shrunk
						if (q.length === 0) q = [];
						exports.setImmediate(function () {
							cb(err, item);
						});
						if (pendingWrites.length > 0) {
								var wr = pendingWrites.shift();
								exports.setImmediate(function () {
									wr[0](err, wr[1]);
								});
							}
					} else {
						callback = cb;
					}
			}
43471
function(cb) {
        var timeout;
        this.chain(function(next) {
            function evaluate() {
                var ccb = cb.bind(api);
                var result = ccb();
                if (result) {
                    clearInterval(poll);
                    if (timeout !== undefined) clearTimeout(timeout);
                    next();
                }
            }
            var api = this;
            var poll = setInterval(evaluate, api._untilInterval || 30);
            // to set a timeout for condition to be met, set the _untilTimeout property to ms value
            if (api.untilTimeout) {
                timeout = setTimeout(function() {
                    if (poll !== undefined) {
                        clearInterval(poll);
                        // to catch timeout of until conditions, set onUntilTimeout handler
                        if (api.onUntilTimeout) api.onUntilTimeout(next);
                        // otherwise execution flow simply continues as if condition was met
                        else next();
                    }
                }, api.untilTimeout);
            }
        });
        return this;
    }
38419
function get(cb) {
    getRaw(function (err, num, muted) {
      timeouts.push(setTimeout(function () {
        cb(err, num, muted);
      }), 0);
    });
  }
97919
function readFromStream(stream, callback) {
  var buf = [];
  stream.on("data", onData);
  stream.on("end", onEnd);
  stream.on("error", onError);

  function onData(data) {
    buf.push(data);
  }

  function onEnd() {
    if (callback) callback(null, buf.join(""));
    callback = null;
  }

  function onError(err) {
    if (callback) callback(err);
    callback = null;
  }
}
679043
function (opts, cb) {
            var self = this;
            cb = cb || function () {
                };
            opts = opts || {};
            var url = this._getlisturi(opts);
            this.client.get({
                uri: url,
                data:opts
            }, cb);
        }
982234
function(link, cb){
            var options = {
                host: urlArr.hostname,
                port: urlArr.port,
                path: urlArr.path+"?link="+encodeURIComponent(link),
                method: 'GET'
            };
            
            var getRequest = protocol.request(options, function(res){
                var result = "";
                
                if(res.statusCode === 200){
                    res.on('error', function(error) {
                        if(typeof cb === "function")
                            cb(error);
                    });

                    res.on('data', function (chunk) {
                        result += chunk;
                    });

                    res.on('end', function (chunk) {
                        if(typeof cb === "function"){
                            var resultObj = JSON.parse(result);
                            var err = (resultObj.status === "error") ? resultObj["msg"] : null
                            cb(err, resultObj);
                        }                        
                    });
                }
                else{
                    if(typeof cb === "function")
                        cb("Request return HTTP "+res.statusCode);
                }
            });
            
            getRequest.end();
        }
656185
function(callback) {
        request.get(this.getUserUrl(), function(err, res, body) {
            if (body && body.lastModified) {
                body.lastModified = new Date(body.lastModified);
            }

            if (body && !body.user && body.publicKey) {
                body.user = body.publicKey;
            }

            callback(err, body, res);
        });

        return this;
    }
1144527
async function request(cb) {
  // get name of current service, stop if it's `config-srv` itself
  const name = nconf.get('server:name') || 'test-srv';
  let data = {};
  if (name === 'config-srv') return cb(null, data);

  // setup & connect with config-srv on first run
  // if (!client && fs.existsSync(fullProtoPath))
  const config = _.clone(nconf.get('config-srv'));
  let service;

  if (config.transports
    && config.transports.grpc
    && config.transports.service) {
    client = new grpcClient.Client(config);
    service = await co(client.connect());
  } else {
    throw new Error('Missing configuration details');
  }

  await co(service.get({
    filter: client.toStruct({ name: name })
  }));

  // TODO: continue
  // fetch the latest configuration data if possible
  client.get({ field: [{ name }] }, (err, res) => {
    if (err) return cb(err, null);
    if (res.data) data = res.data;

    // update/mutate the nconf store and return
    nconf.use('default', data);
    return cb(null, nconf);
  });
  return true;
}
871428
function (url, cb) {

            var request = new XMLHttpRequest();

            request.onload = function () {
                if (this.status >= 200 && this.status < 400) {
                    cb(this.response);
                }
                else {
                    Logger.log(Logger.LEVEL_SEVERE, "sever error: " + this.status);
                    cb(null);
                }
            };

            request.onerror = function (e) {
                Logger.log(Logger.LEVEL_SEVERE, "connection error: " + e);
                cb(null);
            };

            request.open("get", url, true);

            request.send();
        }