index.js
function createWriteHead (prevWriteHead, listener) {
  var fired = false

  // return function with core name and argument list
  return function writeHead (statusCode) {
    // set headers from arguments
    var args = setWriteHeadHeaders.apply(this, arguments)

    // fire listener
    if (!fired) {
      fired = true
      listener.call(this)

      // pass-along an updated status code
      if (typeof args[0] === 'number' && this.statusCode !== args[0]) {
        args[0] = this.statusCode
        args.length = 1
      }
    }

    return prevWriteHead.apply(this, args)
  }
}
function createWriteHead (prevWriteHead, listener) {
  var fired = false

  // return function with core name and argument list
  return function writeHead (statusCode) {
    // set headers from arguments
    var args = setWriteHeadHeaders.apply(this, arguments)

    // fire listener
    if (!fired) {
      fired = true
      listener.call(this)

      // pass-along an updated status code
      if (typeof args[0] === 'number' && this.statusCode !== args[0]) {
        args[0] = this.statusCode
        args.length = 1
      }
    }

    return prevWriteHead.apply(this, args)
  }
}
function createWriteHead ( prevWriteHead , listener ) { var fired = false // return function with core name and argument list return function writeHead ( statusCode ) { // set headers from arguments var args = setWriteHeadHeaders . apply ( this , arguments ) // fire listener if ( ! fired ) { fired = true listener . call ( this ) // pass-along an updated status code if ( typeof args [ 0 ] === 'number' && this . statusCode !== args [ 0 ] ) { args [ 0 ] = this . statusCode args . length = 1 } } return prevWriteHead . apply ( this , args ) } }
Create a replacement writeHead method.

@param {function} prevWriteHead
@param {function} listener
@private
Create a replacement writeHead method .