demo/body-parser/index.js
function loadParser (parserName) {
  var parser = parsers[parserName]

  if (parser !== undefined) {
    return parser
  }

  // this uses a switch for static require analysis
  switch (parserName) {
    case 'json':
      parser = require('./lib/types/json')
      break
    case 'raw':
      parser = require('./lib/types/raw')
      break
    case 'text':
      parser = require('./lib/types/text')
      break
    case 'urlencoded':
      parser = require('./lib/types/urlencoded')
      break
  }

  // store to prevent invoking require()
  return (parsers[parserName] = parser)
}
function loadParser (parserName) {
  var parser = parsers[parserName]

  if (parser !== undefined) {
    return parser
  }

  // this uses a switch for static require analysis
  switch (parserName) {
    case 'json':
      parser = require('./lib/types/json')
      break
    case 'raw':
      parser = require('./lib/types/raw')
      break
    case 'text':
      parser = require('./lib/types/text')
      break
    case 'urlencoded':
      parser = require('./lib/types/urlencoded')
      break
  }

  // store to prevent invoking require()
  return (parsers[parserName] = parser)
}
function loadParser ( parserName ) { var parser = parsers [ parserName ] if ( parser !== undefined ) { return parser } // this uses a switch for static require analysis switch ( parserName ) { case 'json' : parser = require ( './lib/types/json' ) break case 'raw' : parser = require ( './lib/types/raw' ) break case 'text' : parser = require ( './lib/types/text' ) break case 'urlencoded' : parser = require ( './lib/types/urlencoded' ) break } // store to prevent invoking require() return ( parsers [ parserName ] = parser ) }
Load a parser module.
@private
Load a parser module .