lib/consumers/v1/first.js
function firstObj(stream, onEnd) {
  var data;

  /**
   * Send the correct data to the onEnd callback.
   *
   * @private
   * @param   {Error}     [err] - Optional error.
   * @returns {undefined}
   */
  var done = _.once(function (err) {

    if (err) {
      return onEnd(err);
    }

    return onEnd(null, data);
  });

  stream.once('data', function (chunk) {
    data = chunk;
  });
  stream.on('error', done);
  stream.on('end', done);
}
function firstObj(stream, onEnd) {
  var data;

  /**
   * Send the correct data to the onEnd callback.
   *
   * @private
   * @param   {Error}     [err] - Optional error.
   * @returns {undefined}
   */
  var done = _.once(function (err) {

    if (err) {
      return onEnd(err);
    }

    return onEnd(null, data);
  });

  stream.once('data', function (chunk) {
    data = chunk;
  });
  stream.on('error', done);
  stream.on('end', done);
}
function firstObj ( stream , onEnd ) { var data ; /**
   * Send the correct data to the onEnd callback.
   *
   * @private
   * @param   {Error}     [err] - Optional error.
   * @returns {undefined}
   */ var done = _ . once ( function ( err ) { if ( err ) { return onEnd ( err ) ; } return onEnd ( null , data ) ; } ) ; stream . once ( 'data' , function ( chunk ) { data = chunk ; } ) ; stream . on ( 'error' , done ) ; stream . on ( 'end' , done ) ; }
Get the first item in a stream.

@private
@deprecated
@static
@since    0.0.4
@category Consumers

@param    {Stream}    stream - Stream that will be read for this function.
@param    {Function}  onEnd  - Callback when the stream has been read completely.
@returns  {undefined}
Get the first item in a stream .