@@ -24,28 +24,28 @@ var typeis = require('type-is')
2424 * Module exports. 
2525 */ 
2626
27- module . exports  =  generic 
27+ module . exports  =  createBodyParser 
2828
2929/** 
3030 * Use this to create a middleware that parses request bodies 
3131 * 
32-  * @param  {object } [options] 
32+  * @param  {function } parse 
33+  * @param  {object } options 
34+  * @param  {object } defaultOptions 
3335 * @return  {function } 
3436 * @public  
3537 */ 
3638
37- function  generic   ( parserOptions ,   parserOverrides )  { 
39+ function  createBodyParser   ( parse ,   options ,   defaultOptions )  { 
3840  // Squash the options and the overrides down into one object 
39-   var  opts  =  Object . create ( parserOptions ) 
40-   Object . assign ( opts ,  parserOverrides ) 
41+   var  opts  =  {  ...defaultOptions  ||  { } ,  ...options  } 
4142
4243  var  limit  =  typeof  opts . limit  !==  'number' 
4344    ? bytes . parse ( opts . limit  ||  '100kb' ) 
4445    : opts . limit 
4546  var  charset  =  opts . charset 
4647  var  inflate  =  opts . inflate  !==  false 
4748  var  verify  =  opts . verify  ||  false 
48-   var  parse  =  opts . parse  ||  defaultParse 
4949  var  defaultReqCharset  =  opts . defaultCharset  ||  'utf-8' 
5050  var  type  =  opts . type 
5151
@@ -63,7 +63,7 @@ function generic (parserOptions, parserOverrides) {
6363    ? charsetValidator ( charset ) 
6464    : charset 
6565
66-   return  function  genericParser   ( req ,  res ,  next )  { 
66+   return  function  ( req ,  res ,  next )  { 
6767    if  ( isFinished ( req ) )  { 
6868      debug ( 'body already parsed' ) 
6969      next ( ) 
@@ -114,10 +114,6 @@ function generic (parserOptions, parserOverrides) {
114114  } 
115115} 
116116
117- function  defaultParse  ( buf )  { 
118-   return  buf 
119- } 
120- 
121117/** 
122118 * Get the charset of a request. 
123119 * 
0 commit comments