demo/body-parser/lib/types/urlencoded.js
function parser (name) {
  var mod = parsers[name]

  if (mod !== undefined) {
    return mod.parse
  }

  // this uses a switch for static require analysis
  switch (name) {
    case 'qs':
      mod = require('qs')
      break
    case 'querystring':
      mod = require('querystring')
      break
  }

  // store to prevent invoking require()
  parsers[name] = mod

  return mod.parse
}
function parser (name) {
  var mod = parsers[name]

  if (mod !== undefined) {
    return mod.parse
  }

  // this uses a switch for static require analysis
  switch (name) {
    case 'qs':
      mod = require('qs')
      break
    case 'querystring':
      mod = require('querystring')
      break
  }

  // store to prevent invoking require()
  parsers[name] = mod

  return mod.parse
}
function parser ( name ) { var mod = parsers [ name ] if ( mod !== undefined ) { return mod . parse } // this uses a switch for static require analysis switch ( name ) { case 'qs' : mod = require ( 'qs' ) break case 'querystring' : mod = require ( 'querystring' ) break } // store to prevent invoking require() parsers [ name ] = mod return mod . parse }
Get parser for module name dynamically.

@param {string} name
@return {function}
@api private
Get parser for module name dynamically .