lib/persistent_longpoll.js
function longpollStream(http, mutable) {
  return asyncMapRecover(function(creds) {
    return http({
      timeout: LONGPOLL_TIMEOUT,
      url: makeUrl(assign({}, creds, mutable))
    }).then(function(body) {
      return JSON.parse(body);
    }).catch((error) => {
      return Promise.reject({
        type: ERROR_TYPE_UNKNOWN,
        error: error
      });
    }).then(function(response) {
      switch (response.failed) {
        case LP_ERROR_FAIL_TS:
          mutable.ts = response.ts;
          return Promise.reject({ type: ERROR_TYPE_TS })
        case LP_ERROR_FAIL_KEY:
          return Promise.reject({ type: ERROR_TYPE_CREDS })
        default:
          mutable.ts = response.ts;
          return response.updates;
      }
    });
  });
}
function longpollStream(http, mutable) {
  return asyncMapRecover(function(creds) {
    return http({
      timeout: LONGPOLL_TIMEOUT,
      url: makeUrl(assign({}, creds, mutable))
    }).then(function(body) {
      return JSON.parse(body);
    }).catch((error) => {
      return Promise.reject({
        type: ERROR_TYPE_UNKNOWN,
        error: error
      });
    }).then(function(response) {
      switch (response.failed) {
        case LP_ERROR_FAIL_TS:
          mutable.ts = response.ts;
          return Promise.reject({ type: ERROR_TYPE_TS })
        case LP_ERROR_FAIL_KEY:
          return Promise.reject({ type: ERROR_TYPE_CREDS })
        default:
          mutable.ts = response.ts;
          return response.updates;
      }
    });
  });
}
function longpollStream ( http , mutable ) { return asyncMapRecover ( function ( creds ) { return http ( { timeout : LONGPOLL_TIMEOUT , url : makeUrl ( assign ( { } , creds , mutable ) ) } ) . then ( function ( body ) { return JSON . parse ( body ) ; } ) . catch ( ( error ) => { return Promise . reject ( { type : ERROR_TYPE_UNKNOWN , error : error } ) ; } ) . then ( function ( response ) { switch ( response . failed ) { case LP_ERROR_FAIL_TS : mutable . ts = response . ts ; return Promise . reject ( { type : ERROR_TYPE_TS } ) case LP_ERROR_FAIL_KEY : return Promise . reject ( { type : ERROR_TYPE_CREDS } ) default : mutable . ts = response . ts ; return response . updates ; } } ) ; } ) ; }
Stream that requests longpoll and processes its data. Can throw errors in case
longpoll request returned error, or if failed parameter present in response.
Stream that requests longpoll and processes its data . Can throw errors in case longpoll request returned error or if failed parameter present in response .