lib/imapSimple.js
function ImapSimple(imap) {
    var self = this;
    self.imap = imap;

    // flag to determine whether we should suppress ECONNRESET from bubbling up to listener
    self.ending = false;

    // pass most node-imap `Connection` events through 1:1
    ['alert', 'mail', 'expunge', 'uidvalidity', 'update', 'close', 'end'].forEach(function (event) {
        self.imap.on(event, self.emit.bind(self, event));
    });

    // special handling for `error` event
    self.imap.on('error', function (err) {
        // if .end() has been called and an 'ECONNRESET' error is received, don't bubble
        if (err && self.ending && (err.code.toUpperCase() === 'ECONNRESET')) {
            return;
        }

        self.emit('error', err);
    });
}
function ImapSimple(imap) {
    var self = this;
    self.imap = imap;

    // flag to determine whether we should suppress ECONNRESET from bubbling up to listener
    self.ending = false;

    // pass most node-imap `Connection` events through 1:1
    ['alert', 'mail', 'expunge', 'uidvalidity', 'update', 'close', 'end'].forEach(function (event) {
        self.imap.on(event, self.emit.bind(self, event));
    });

    // special handling for `error` event
    self.imap.on('error', function (err) {
        // if .end() has been called and an 'ECONNRESET' error is received, don't bubble
        if (err && self.ending && (err.code.toUpperCase() === 'ECONNRESET')) {
            return;
        }

        self.emit('error', err);
    });
}
function ImapSimple ( imap ) { var self = this ; self . imap = imap ; // flag to determine whether we should suppress ECONNRESET from bubbling up to listener self . ending = false ; // pass most node-imap `Connection` events through 1:1 [ 'alert' , 'mail' , 'expunge' , 'uidvalidity' , 'update' , 'close' , 'end' ] . forEach ( function ( event ) { self . imap . on ( event , self . emit . bind ( self , event ) ) ; } ) ; // special handling for `error` event self . imap . on ( 'error' , function ( err ) { // if .end() has been called and an 'ECONNRESET' error is received, don't bubble if ( err && self . ending && ( err . code . toUpperCase ( ) === 'ECONNRESET' ) ) { return ; } self . emit ( 'error' , err ) ; } ) ; }
Constructs an instance of ImapSimple

@param {object} imap a constructed node-imap connection
@constructor
@class ImapSimple
Constructs an instance of ImapSimple