format: prettify entire project
This commit is contained in:
53
node_modules/body-parser/lib/utils.js
generated
vendored
53
node_modules/body-parser/lib/utils.js
generated
vendored
@ -1,12 +1,12 @@
|
||||
'use strict'
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var bytes = require('bytes')
|
||||
var contentType = require('content-type')
|
||||
var typeis = require('type-is')
|
||||
var bytes = require('bytes');
|
||||
var contentType = require('content-type');
|
||||
var typeis = require('type-is');
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
@ -14,8 +14,8 @@ var typeis = require('type-is')
|
||||
|
||||
module.exports = {
|
||||
getCharset,
|
||||
normalizeOptions
|
||||
}
|
||||
normalizeOptions,
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the charset of a request.
|
||||
@ -24,11 +24,11 @@ module.exports = {
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function getCharset (req) {
|
||||
function getCharset(req) {
|
||||
try {
|
||||
return (contentType.parse(req).parameters.charset || '').toLowerCase()
|
||||
return (contentType.parse(req).parameters.charset || '').toLowerCase();
|
||||
} catch {
|
||||
return undefined
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,10 +39,10 @@ function getCharset (req) {
|
||||
* @return {function}
|
||||
*/
|
||||
|
||||
function typeChecker (type) {
|
||||
return function checkType (req) {
|
||||
return Boolean(typeis(req, type))
|
||||
}
|
||||
function typeChecker(type) {
|
||||
return function checkType(req) {
|
||||
return Boolean(typeis(req, type));
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,32 +52,31 @@ function typeChecker (type) {
|
||||
* @param {string | string[] | function} defaultType default content type(s) or a function to determine it
|
||||
* @returns {object}
|
||||
*/
|
||||
function normalizeOptions (options, defaultType) {
|
||||
function normalizeOptions(options, defaultType) {
|
||||
if (!defaultType) {
|
||||
// Parsers must define a default content type
|
||||
throw new TypeError('defaultType must be provided')
|
||||
throw new TypeError('defaultType must be provided');
|
||||
}
|
||||
|
||||
var inflate = options?.inflate !== false
|
||||
var limit = typeof options?.limit !== 'number'
|
||||
? bytes.parse(options?.limit || '100kb')
|
||||
: options?.limit
|
||||
var type = options?.type || defaultType
|
||||
var verify = options?.verify || false
|
||||
var inflate = options?.inflate !== false;
|
||||
var limit =
|
||||
typeof options?.limit !== 'number' ?
|
||||
bytes.parse(options?.limit || '100kb')
|
||||
: options?.limit;
|
||||
var type = options?.type || defaultType;
|
||||
var verify = options?.verify || false;
|
||||
|
||||
if (verify !== false && typeof verify !== 'function') {
|
||||
throw new TypeError('option verify must be function')
|
||||
throw new TypeError('option verify must be function');
|
||||
}
|
||||
|
||||
// create the appropriate type checking function
|
||||
var shouldParse = typeof type !== 'function'
|
||||
? typeChecker(type)
|
||||
: type
|
||||
var shouldParse = typeof type !== 'function' ? typeChecker(type) : type;
|
||||
|
||||
return {
|
||||
inflate,
|
||||
limit,
|
||||
verify,
|
||||
shouldParse
|
||||
}
|
||||
shouldParse,
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user