Code coverage report for nock/lib/socket.js

Statements: 95.45% (21 / 22)      Branches: 83.33% (5 / 6)      Functions: 100% (5 / 5)      Lines: 95.45% (21 / 22)      Ignored: none     

All files » nock/lib/ » socket.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43    1     1   1 336   336   336 336 9 9   336 2 1 1 1               336 336   336   336     1   1 1    
'use strict';
 
var EventEmitter = require('events').EventEmitter,
    debug        = require('debug')('nock.socket');
 
module.exports = Socket;
 
function Socket() {
  var socket = new EventEmitter();
 
  socket.writable = true;
 
  socket.setNoDelay = noop;
  socket.setTimeout = function(timeout, fn) {
    this.timeout = timeout;
    this.timeoutFunction = fn;
  }
  socket._checkTimeout = function(delay) {
    if (this.timeout && delay > this.timeout) {
      debug('socket timeout');
      Eif (this.timeoutFunction) {
        this.timeoutFunction();
      }
      else {
        this.emit('timeout');
      }
    }
  }
 
  socket.setKeepAlive = noop;
  socket.destroy = noop;
 
  socket.getPeerCertificate = getPeerCertificate;
 
  return socket;
}
 
function noop() {}
 
function getPeerCertificate() {
  return new Buffer((Math.random() * 10000 + Date.now()).toString()).toString('base64');
}